mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-08 21:10:05 +00:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
784bd20ee0 | ||
|
|
61db1e0609 | ||
|
|
5c589a6af3 | ||
|
|
275cd6dbd3 | ||
|
|
d874e07889 | ||
|
|
1648cf28d5 | ||
| a4aaeba31c | |||
|
|
6bf68a315c | ||
|
|
c0f78d0c1e | ||
|
|
e0aebc169f | ||
|
|
9a50e5cb63 | ||
|
|
a51923dad7 | ||
|
|
9aee77f0e3 | ||
|
|
c32d037063 | ||
|
|
94f7492c31 | ||
|
|
d29e0a0f57 | ||
|
|
8d7cc11db5 | ||
|
|
28e9d1cc6b | ||
|
|
375cec48ca | ||
| 7d826685f7 | |||
| f42f6bca00 |
34
.github/workflows/build.yml
vendored
34
.github/workflows/build.yml
vendored
@@ -12,7 +12,7 @@ jobs:
|
|||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [lts/fermium]
|
node-version: [lts/hydrogen]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@@ -22,17 +22,17 @@ jobs:
|
|||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: npm
|
cache: npm
|
||||||
|
|
||||||
# - name: Check npm audit
|
- name: Check npm audit
|
||||||
# run: npm audit --production --audit-level=low
|
run: npm audit --production --audit-level=low
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
|
|
||||||
# - name: Check code style
|
- name: Check code style
|
||||||
# run: npm run lint
|
run: npm run lint
|
||||||
|
|
||||||
# - name: Run unit tests
|
- name: Run unit tests
|
||||||
# run: npm test
|
run: npm test
|
||||||
|
|
||||||
- name: Build Package
|
- name: Build Package
|
||||||
run: npm run package:lib
|
run: npm run package:lib
|
||||||
@@ -72,27 +72,19 @@ jobs:
|
|||||||
npm install -g replace-in-files-cli
|
npm install -g replace-in-files-cli
|
||||||
cd sasjs-tests
|
cd sasjs-tests
|
||||||
replace-in-files --regex='"@sasjs/adapter".*' --replacement='"@sasjs/adapter":"latest",' ./package.json
|
replace-in-files --regex='"@sasjs/adapter".*' --replacement='"@sasjs/adapter":"latest",' ./package.json
|
||||||
npm i --legacy-peer-deps
|
npm i
|
||||||
replace-in-files --regex='"serverUrl".*' --replacement='"serverUrl":"${{ secrets.SASJS_SERVER_URL }}",' ./public/config.json
|
replace-in-files --regex='"serverUrl".*' --replacement='"serverUrl":"${{ secrets.SASJS_SERVER_URL }}",' ./public/config.json
|
||||||
replace-in-files --regex='"userName".*' --replacement='"userName":"${{ secrets.SASJS_USERNAME_DEV }}",' ./public/config.json
|
replace-in-files --regex='"userName".*' --replacement='"userName":"${{ secrets.SASJS_USERNAME }}",' ./public/config.json
|
||||||
replace-in-files --regex='"password".*' --replacement='"password":"${{ secrets.SASJS_PASSWORD_DEV }}",' ./public/config.json
|
replace-in-files --regex='"password".*' --replacement='"password":"${{ secrets.SASJS_PASSWORD }}",' ./public/config.json
|
||||||
replace-in-files --regex='"serverType".*' --replacement='"serverType":"SASJS",' ./public/config.json
|
replace-in-files --regex='"serverType".*' --replacement='"serverType":"SASJS",' ./public/config.json
|
||||||
# npm run update:adapter
|
npm run update:adapter
|
||||||
pm2 start --name sasjs-test npm -- start
|
pm2 start --name sasjs-test npm -- start
|
||||||
cat ./public/config.json
|
|
||||||
cat ../cypress.json
|
|
||||||
|
|
||||||
- name: Sleep for 10 seconds
|
|
||||||
uses: jakejarvis/wait-action@master
|
|
||||||
with:
|
|
||||||
time: '10s'
|
|
||||||
|
|
||||||
- name: Run cypress on sasjs
|
- name: Run cypress on sasjs
|
||||||
run: |
|
run: |
|
||||||
ss -lntu
|
|
||||||
replace-in-files --regex='"sasjsTestsUrl".*' --replacement='"sasjsTestsUrl":"http://localhost:3000",' ./cypress.json
|
replace-in-files --regex='"sasjsTestsUrl".*' --replacement='"sasjsTestsUrl":"http://localhost:3000",' ./cypress.json
|
||||||
replace-in-files --regex='"username".*' --replacement='"username":"${{ secrets.SASJS_USERNAME_DEV }}",' ./cypress.json
|
replace-in-files --regex='"username".*' --replacement='"username":"${{ secrets.SASJS_USERNAME }}",' ./cypress.json
|
||||||
replace-in-files --regex='"password".*' --replacement='"password":"${{ secrets.SASJS_PASSWORD_DEV }}",' ./cypress.json
|
replace-in-files --regex='"password".*' --replacement='"password":"${{ secrets.SASJS_PASSWORD }}",' ./cypress.json
|
||||||
sh ./sasjs-tests/sasjs-cypress-run.sh ${{ secrets.MATRIX_TOKEN }} https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
|
sh ./sasjs-tests/sasjs-cypress-run.sh ${{ secrets.MATRIX_TOKEN }} https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
|
||||||
|
|
||||||
# For some reason if coverage report action is run before other commands, those commands can't access the directories and files on which they depend on
|
# For some reason if coverage report action is run before other commands, those commands can't access the directories and files on which they depend on
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ const testingFinishTimeout = Cypress.env('testingFinishTimeout')
|
|||||||
|
|
||||||
context('sasjs-tests', function () {
|
context('sasjs-tests', function () {
|
||||||
this.beforeAll(() => {
|
this.beforeAll(() => {
|
||||||
cy.task('log', 'beforeAll')
|
|
||||||
cy.task('log', `sasjsTestsUrl: ${sasjsTestsUrl}`)
|
|
||||||
|
|
||||||
cy.visit(sasjsTestsUrl)
|
cy.visit(sasjsTestsUrl)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -16,66 +13,35 @@ context('sasjs-tests', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('Should have all tests successfull', (done) => {
|
it('Should have all tests successfull', (done) => {
|
||||||
cy.task('log', `Should have all tests successfull`)
|
|
||||||
|
|
||||||
cy.get('body').then(($body) => {
|
cy.get('body').then(($body) => {
|
||||||
cy.task('log', `22`)
|
|
||||||
cy.wait(1000).then(() => {
|
cy.wait(1000).then(() => {
|
||||||
const startButton = $body.find(
|
const startButton = $body.find(
|
||||||
'.ui.massive.icon.primary.left.labeled.button'
|
'.ui.massive.icon.primary.left.labeled.button'
|
||||||
)[0]
|
)[0]
|
||||||
|
|
||||||
// ui massive icon primary left labeled button
|
|
||||||
|
|
||||||
cy.task('log', `startButton: ${startButton}`)
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!startButton ||
|
!startButton ||
|
||||||
(startButton && !Cypress.dom.isVisible(startButton))
|
(startButton && !Cypress.dom.isVisible(startButton))
|
||||||
) {
|
) {
|
||||||
cy.task('log', `34`)
|
|
||||||
cy.task('log', `username: ${username}`)
|
|
||||||
cy.task('log', `password: ${password}`)
|
|
||||||
|
|
||||||
const userNameInput = cy.get('input[placeholder="User Name"]')
|
|
||||||
const passwordInput = cy.get('input[placeholder="Password"]')
|
|
||||||
|
|
||||||
cy.task('log', `userNameInput: ${userNameInput}`)
|
|
||||||
cy.task('log', `passwordInput: ${passwordInput}`)
|
|
||||||
|
|
||||||
cy.get('input[placeholder="User Name"]').type(username)
|
cy.get('input[placeholder="User Name"]').type(username)
|
||||||
cy.get('input[placeholder="Password"]').type(password)
|
cy.get('input[placeholder="Password"]').type(password)
|
||||||
const submitBtn = cy.get('.submit-button')
|
|
||||||
|
|
||||||
cy.task('log', `submitBtn: ${submitBtn}`)
|
|
||||||
cy.get('.submit-button').click()
|
cy.get('.submit-button').click()
|
||||||
}
|
}
|
||||||
|
|
||||||
cy.get('input[placeholder="User Name"]', { timeout: 40000 })
|
cy.get('input[placeholder="User Name"]', { timeout: 40000 })
|
||||||
.should('not.exist')
|
.should('not.exist')
|
||||||
.then(() => {
|
.then(() => {
|
||||||
cy.task('log', `46`)
|
|
||||||
cy.get('.ui.massive.icon.primary.left.labeled.button')
|
cy.get('.ui.massive.icon.primary.left.labeled.button')
|
||||||
.click()
|
.click()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
cy.task('log', `50`)
|
|
||||||
|
|
||||||
const loadingButton = $body.find(
|
|
||||||
'.ui.massive.loading.primary.button'
|
|
||||||
)[0]
|
|
||||||
|
|
||||||
cy.task('log', `loadingButton: ${loadingButton}`)
|
|
||||||
|
|
||||||
cy.get('.ui.massive.loading.primary.button', {
|
cy.get('.ui.massive.loading.primary.button', {
|
||||||
timeout: testingFinishTimeout
|
timeout: testingFinishTimeout
|
||||||
})
|
})
|
||||||
.should('not.exist')
|
.should('not.exist')
|
||||||
.then(() => {
|
.then(() => {
|
||||||
cy.task('log', `56`)
|
|
||||||
cy.get('span.icon.failed')
|
cy.get('span.icon.failed')
|
||||||
.should('not.exist')
|
.should('not.exist')
|
||||||
.then(() => {
|
.then(() => {
|
||||||
cy.task('log', `60`)
|
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -85,46 +51,46 @@ context('sasjs-tests', function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// it('Should have all tests successfull with debug on', (done) => {
|
it('Should have all tests successfull with debug on', (done) => {
|
||||||
// cy.get('body').then(($body) => {
|
cy.get('body').then(($body) => {
|
||||||
// cy.wait(1000).then(() => {
|
cy.wait(1000).then(() => {
|
||||||
// const startButton = $body.find(
|
const startButton = $body.find(
|
||||||
// '.ui.massive.icon.primary.left.labeled.button'
|
'.ui.massive.icon.primary.left.labeled.button'
|
||||||
// )[0]
|
)[0]
|
||||||
|
|
||||||
// if (
|
if (
|
||||||
// !startButton ||
|
!startButton ||
|
||||||
// (startButton && !Cypress.dom.isVisible(startButton))
|
(startButton && !Cypress.dom.isVisible(startButton))
|
||||||
// ) {
|
) {
|
||||||
// cy.get('input[placeholder="User Name"]').type(username)
|
cy.get('input[placeholder="User Name"]').type(username)
|
||||||
// cy.get('input[placeholder="Password"]').type(password)
|
cy.get('input[placeholder="Password"]').type(password)
|
||||||
// cy.get('.submit-button').click()
|
cy.get('.submit-button').click()
|
||||||
// }
|
}
|
||||||
|
|
||||||
// cy.get('.ui.fitted.toggle.checkbox label')
|
cy.get('.ui.fitted.toggle.checkbox label')
|
||||||
// .click()
|
.click()
|
||||||
// .then(() => {
|
.then(() => {
|
||||||
// cy.get('input[placeholder="User Name"]', { timeout: 40000 })
|
cy.get('input[placeholder="User Name"]', { timeout: 40000 })
|
||||||
// .should('not.exist')
|
.should('not.exist')
|
||||||
// .then(() => {
|
.then(() => {
|
||||||
// cy.get('.ui.massive.icon.primary.left.labeled.button')
|
cy.get('.ui.massive.icon.primary.left.labeled.button')
|
||||||
// .click()
|
.click()
|
||||||
// .then(() => {
|
.then(() => {
|
||||||
// cy.get('.ui.massive.loading.primary.button', {
|
cy.get('.ui.massive.loading.primary.button', {
|
||||||
// timeout: testingFinishTimeout
|
timeout: testingFinishTimeout
|
||||||
// })
|
})
|
||||||
// .should('not.exist')
|
.should('not.exist')
|
||||||
// .then(() => {
|
.then(() => {
|
||||||
// cy.get('span.icon.failed')
|
cy.get('span.icon.failed')
|
||||||
// .should('not.exist')
|
.should('not.exist')
|
||||||
// .then(() => {
|
.then(() => {
|
||||||
// done()
|
done()
|
||||||
// })
|
})
|
||||||
// })
|
})
|
||||||
// })
|
})
|
||||||
// })
|
})
|
||||||
// })
|
})
|
||||||
// })
|
})
|
||||||
// })
|
})
|
||||||
// })
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -39,11 +39,4 @@ module.exports = (on, config) => {
|
|||||||
return launchOptions
|
return launchOptions
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
on('task', {
|
|
||||||
log(message) {
|
|
||||||
console.log(message)
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script src="https://cdn.jsdelivr.net/combine/npm/chart.js@2.9.3,npm/jquery@3.5.1,npm/@sasjs/adapter@1"></script>
|
<script src="https://cdn.jsdelivr.net/combine/npm/chart.js@2.9.3,npm/jquery@3.5.1,npm/@sasjs/adapter@4"></script>
|
||||||
<script>
|
<script>
|
||||||
var sasJs = new SASjs.default({
|
var sasJs = new SASjs.default({
|
||||||
appLoc: "/Public/app/readme"
|
appLoc: "/Public/app/readme"
|
||||||
|
|||||||
19659
sasjs-tests/package-lock.json
generated
19659
sasjs-tests/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -4,15 +4,14 @@
|
|||||||
"homepage": ".",
|
"homepage": ".",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sasjs/adapter": "4.3.5",
|
|
||||||
"@sasjs/test-framework": "1.5.7",
|
"@sasjs/test-framework": "1.5.7",
|
||||||
"@types/jest": "^26.0.20",
|
"@types/jest": "^26.0.20",
|
||||||
"@types/node": "^14.14.41",
|
"@types/node": "^14.14.41",
|
||||||
"@types/react": "^17.0.1",
|
"@types/react": "^16.0.1",
|
||||||
"@types/react-dom": "^17.0.0",
|
"@types/react-dom": "^16.0.0",
|
||||||
"@types/react-router-dom": "^5.1.7",
|
"@types/react-router-dom": "^5.1.7",
|
||||||
"react": "^17.0.1",
|
"react": "^16.0.1",
|
||||||
"react-dom": "^17.0.1",
|
"react-dom": "^16.0.1",
|
||||||
"react-router-dom": "^5.2.0",
|
"react-router-dom": "^5.2.0",
|
||||||
"react-scripts": "^5.0.1",
|
"react-scripts": "^5.0.1",
|
||||||
"typescript": "^4.1.3"
|
"typescript": "^4.1.3"
|
||||||
@@ -22,7 +21,7 @@
|
|||||||
"build": "react-scripts build",
|
"build": "react-scripts build",
|
||||||
"test": "react-scripts test",
|
"test": "react-scripts test",
|
||||||
"eject": "react-scripts eject",
|
"eject": "react-scripts eject",
|
||||||
"update:adapter": "cd .. && npm run package:lib && cd sasjs-tests && npm i ../build/sasjs-adapter-5.0.0.tgz --legacy-peer-deps",
|
"update:adapter": "cd .. && npm run package:lib && cd sasjs-tests && npm i ../build/sasjs-adapter-5.0.0.tgz",
|
||||||
"deploy:tests": "rsync -avhe ssh ./build/* --delete $SSH_ACCOUNT:$DEPLOY_PATH || npm run deploy:tests-win",
|
"deploy:tests": "rsync -avhe ssh ./build/* --delete $SSH_ACCOUNT:$DEPLOY_PATH || npm run deploy:tests-win",
|
||||||
"deploy:tests-win": "scp %DEPLOY_PATH% ./build/*",
|
"deploy:tests-win": "scp %DEPLOY_PATH% ./build/*",
|
||||||
"deploy": "npm run update:adapter && npm run build && npm run deploy:tests"
|
"deploy": "npm run update:adapter && npm run build && npm run deploy:tests"
|
||||||
@@ -43,6 +42,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"node-sass": "7.0.3"
|
"node-sass": "9.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"userName": "",
|
"userName": "",
|
||||||
"password": "",
|
"password": "",
|
||||||
"sasJsConfig": {
|
"sasJsConfig": {
|
||||||
"serverUrl": "https://sas9.4gl.io",
|
"serverUrl": "",
|
||||||
"appLoc": "/Public/app/adapter-tests/services",
|
"appLoc": "/Public/app/adapter-tests/services",
|
||||||
"serverType": "SASJS",
|
"serverType": "SASJS",
|
||||||
"debug": false,
|
"debug": false,
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://cli.sasjs.io/sasjsconfig-schema.json",
|
"$schema": "https://cli.sasjs.io/sasjsconfig-schema.json",
|
||||||
"serviceConfig": {
|
"serviceConfig": {
|
||||||
"serviceFolders": [
|
"serviceFolders": ["sasjs/common"]
|
||||||
"sasjs/common"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"defaultTarget": "4gl",
|
"defaultTarget": "4gl",
|
||||||
"targets": [
|
"targets": [
|
||||||
@@ -28,4 +26,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const Login = (): ReactElement<{}> => {
|
|||||||
const handleSubmit = useCallback(
|
const handleSubmit = useCallback(
|
||||||
(e: any) => {
|
(e: any) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
appContext.adapter.logIn(username, password).then((res: any) => {
|
appContext.adapter.logIn(username, password).then((res) => {
|
||||||
appContext.setIsLoggedIn(res.isLoggedIn)
|
appContext.setIsLoggedIn(res.isLoggedIn)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import * as formatDataModule from '../../../utils/formatDataForRequest'
|
|||||||
import * as fetchLogsModule from '../../../utils/fetchLogByChunks'
|
import * as fetchLogsModule from '../../../utils/fetchLogByChunks'
|
||||||
import { PollOptions } from '../../../types'
|
import { PollOptions } from '../../../types'
|
||||||
import { ComputeJobExecutionError, NotFoundError } from '../../../types/errors'
|
import { ComputeJobExecutionError, NotFoundError } from '../../../types/errors'
|
||||||
import { Logger, LogLevel } from '@sasjs/utils'
|
import { Logger, LogLevel } from '@sasjs/utils/logger'
|
||||||
|
|
||||||
const sessionManager = new (<jest.Mock<SessionManager>>SessionManager)()
|
const sessionManager = new (<jest.Mock<SessionManager>>SessionManager)()
|
||||||
const requestClient = new (<jest.Mock<RequestClient>>RequestClient)()
|
const requestClient = new (<jest.Mock<RequestClient>>RequestClient)()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Logger, LogLevel } from '@sasjs/utils'
|
import { Logger, LogLevel } from '@sasjs/utils/logger'
|
||||||
import { RequestClient } from '../../../request/RequestClient'
|
import { RequestClient } from '../../../request/RequestClient'
|
||||||
import { mockAuthConfig, mockJob } from './mockResponses'
|
import { mockAuthConfig, mockJob } from './mockResponses'
|
||||||
import { pollJobState } from '../pollJobState'
|
import { pollJobState } from '../pollJobState'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Logger, LogLevel } from '@sasjs/utils'
|
import { Logger, LogLevel } from '@sasjs/utils/logger'
|
||||||
import { RequestClient } from '../../../request/RequestClient'
|
import { RequestClient } from '../../../request/RequestClient'
|
||||||
import * as fetchLogsModule from '../../../utils/fetchLogByChunks'
|
import * as fetchLogsModule from '../../../utils/fetchLogByChunks'
|
||||||
import * as writeStreamModule from '../writeStream'
|
import * as writeStreamModule from '../writeStream'
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
fileExists,
|
fileExists,
|
||||||
readFile,
|
readFile,
|
||||||
deleteFile
|
deleteFile
|
||||||
} from '@sasjs/utils'
|
} from '@sasjs/utils/file'
|
||||||
|
|
||||||
describe('writeStream', () => {
|
describe('writeStream', () => {
|
||||||
const filename = 'test.txt'
|
const filename = 'test.txt'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { prefixMessage } from '@sasjs/utils/error'
|
import { prefixMessage } from '@sasjs/utils/error'
|
||||||
import { RequestClient } from '../request/RequestClient'
|
import { RequestClient } from '../request/RequestClient'
|
||||||
import { getTokenRequestErrorPrefix } from './getTokenRequestErrorPrefix'
|
import { getTokenRequestErrorPrefix } from './getTokenRequestErrorPrefix'
|
||||||
import { ServerType } from '@sasjs/utils'
|
import { ServerType } from '@sasjs/utils/types'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exchanges the auth code for an access token for the given client.
|
* Exchanges the auth code for an access token for the given client.
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { RequestClient } from '../request/RequestClient'
|
|||||||
import { CertificateError } from '../types/errors'
|
import { CertificateError } from '../types/errors'
|
||||||
import { getTokenRequestErrorPrefix } from './getTokenRequestErrorPrefix'
|
import { getTokenRequestErrorPrefix } from './getTokenRequestErrorPrefix'
|
||||||
|
|
||||||
// TODO: update func docs
|
|
||||||
/**
|
/**
|
||||||
* Exchange the auth code for access / refresh tokens for the given client / secret pair.
|
* Exchange the auth code for access / refresh tokens for the given client / secret pair.
|
||||||
* @param requestClient - the pre-configured HTTP request client.
|
* @param requestClient - the pre-configured HTTP request client.
|
||||||
@@ -31,10 +30,11 @@ export async function getAccessTokenForViya(
|
|||||||
Authorization: 'Basic ' + token,
|
Authorization: 'Basic ' + token,
|
||||||
Accept: 'application/json'
|
Accept: 'application/json'
|
||||||
}
|
}
|
||||||
const dataJson = {
|
|
||||||
|
const dataJson = new URLSearchParams({
|
||||||
grant_type: 'authorization_code',
|
grant_type: 'authorization_code',
|
||||||
code: authCode
|
code: authCode
|
||||||
}
|
})
|
||||||
const data = new URLSearchParams(dataJson)
|
const data = new URLSearchParams(dataJson)
|
||||||
|
|
||||||
const authResponse = await requestClient
|
const authResponse = await requestClient
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { prefixMessage } from '@sasjs/utils/error'
|
import { prefixMessage } from '@sasjs/utils/error'
|
||||||
import { RequestClient } from '../request/RequestClient'
|
import { RequestClient } from '../request/RequestClient'
|
||||||
import { getTokenRequestErrorPrefix } from './getTokenRequestErrorPrefix'
|
import { getTokenRequestErrorPrefix } from './getTokenRequestErrorPrefix'
|
||||||
import { ServerType } from '@sasjs/utils'
|
import { ServerType } from '@sasjs/utils/types'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exchanges the refresh token for an access token for the given client.
|
* Exchanges the refresh token for an access token for the given client.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { AuthConfig } from '@sasjs/utils'
|
import { AuthConfig } from '@sasjs/utils/types'
|
||||||
import { generateToken, mockSasjsAuthResponse } from './mockResponses'
|
import { generateToken, mockSasjsAuthResponse } from './mockResponses'
|
||||||
import { RequestClient } from '../../request/RequestClient'
|
import { RequestClient } from '../../request/RequestClient'
|
||||||
import { getAccessTokenForSasjs } from '../getAccessTokenForSasjs'
|
import { getAccessTokenForSasjs } from '../getAccessTokenForSasjs'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { AuthConfig } from '@sasjs/utils'
|
import { AuthConfig } from '@sasjs/utils/types'
|
||||||
import * as NodeFormData from 'form-data'
|
import * as NodeFormData from 'form-data'
|
||||||
import { generateToken, mockAuthResponse } from './mockResponses'
|
import { generateToken, mockAuthResponse } from './mockResponses'
|
||||||
import { RequestClient } from '../../request/RequestClient'
|
import { RequestClient } from '../../request/RequestClient'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { AuthConfig } from '@sasjs/utils'
|
import { AuthConfig } from '@sasjs/utils/types'
|
||||||
import * as refreshTokensModule from '../refreshTokensForViya'
|
import * as refreshTokensModule from '../refreshTokensForViya'
|
||||||
import { generateToken, mockAuthResponse } from './mockResponses'
|
import { generateToken, mockAuthResponse } from './mockResponses'
|
||||||
import { getTokens } from '../getTokens'
|
import { getTokens } from '../getTokens'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ServerType } from '@sasjs/utils'
|
import { ServerType } from '@sasjs/utils/types'
|
||||||
import { generateToken, mockAuthResponse } from './mockResponses'
|
import { generateToken, mockAuthResponse } from './mockResponses'
|
||||||
import { RequestClient } from '../../request/RequestClient'
|
import { RequestClient } from '../../request/RequestClient'
|
||||||
import { refreshTokensForSasjs } from '../refreshTokensForSasjs'
|
import { refreshTokensForSasjs } from '../refreshTokensForSasjs'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { AuthConfig, ServerType } from '@sasjs/utils'
|
import { AuthConfig, ServerType } from '@sasjs/utils/types'
|
||||||
import * as NodeFormData from 'form-data'
|
import * as NodeFormData from 'form-data'
|
||||||
import { generateToken, mockAuthResponse } from './mockResponses'
|
import { generateToken, mockAuthResponse } from './mockResponses'
|
||||||
import { RequestClient } from '../../request/RequestClient'
|
import { RequestClient } from '../../request/RequestClient'
|
||||||
|
|||||||
@@ -93,15 +93,24 @@ export class FileUploader extends BaseJobExecutor {
|
|||||||
this.requestClient,
|
this.requestClient,
|
||||||
config.serverUrl
|
config.serverUrl
|
||||||
)
|
)
|
||||||
|
|
||||||
break
|
break
|
||||||
case ServerType.Sas9:
|
case ServerType.Sas9:
|
||||||
jsonResponse =
|
jsonResponse =
|
||||||
typeof res.result === 'string'
|
typeof res.result === 'string'
|
||||||
? parseWeboutResponse(res.result, uploadUrl)
|
? parseWeboutResponse(res.result, uploadUrl)
|
||||||
: res.result
|
: res.result
|
||||||
|
|
||||||
|
break
|
||||||
|
case ServerType.Sasjs:
|
||||||
|
jsonResponse =
|
||||||
|
typeof res.result === 'string'
|
||||||
|
? getValidJson(res.result)
|
||||||
|
: res.result
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else if (this.serverType !== ServerType.Sasjs) {
|
} else {
|
||||||
jsonResponse =
|
jsonResponse =
|
||||||
typeof res.result === 'string'
|
typeof res.result === 'string'
|
||||||
? getValidJson(res.result)
|
? getValidJson(res.result)
|
||||||
|
|||||||
@@ -93,8 +93,10 @@ export class SasjsJobExecutor extends BaseJobExecutor {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const { result } = res.result
|
const { result } = res
|
||||||
if (result && result.trim()) res.result = getValidJson(result)
|
|
||||||
|
if (result && typeof result === 'string' && result.trim())
|
||||||
|
res.result = getValidJson(result)
|
||||||
|
|
||||||
this.requestClient!.appendRequest(res, sasJob, config.debug)
|
this.requestClient!.appendRequest(res, sasJob, config.debug)
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import * as pem from 'pem'
|
|||||||
import * as http from 'http'
|
import * as http from 'http'
|
||||||
import * as https from 'https'
|
import * as https from 'https'
|
||||||
import { app, mockedAuthResponse } from './SAS_server_app'
|
import { app, mockedAuthResponse } from './SAS_server_app'
|
||||||
import { ServerType } from '@sasjs/utils'
|
import { ServerType } from '@sasjs/utils/types'
|
||||||
import SASjs from '../SASjs'
|
import SASjs from '../SASjs'
|
||||||
import * as axiosModules from '../utils/createAxiosInstance'
|
import * as axiosModules from '../utils/createAxiosInstance'
|
||||||
import {
|
import {
|
||||||
@@ -213,7 +213,7 @@ describe('RequestClient - Self Signed Server', () => {
|
|||||||
serverType: ServerType.SasViya
|
serverType: ServerType.SasViya
|
||||||
})
|
})
|
||||||
|
|
||||||
const expectedError = 'self signed certificate'
|
const expectedError = 'self-signed certificate'
|
||||||
|
|
||||||
const rejectionErrorMessage = await adapterWithoutCertificate
|
const rejectionErrorMessage = await adapterWithoutCertificate
|
||||||
.getAccessToken('clientId', 'clientSecret', 'authCode')
|
.getAccessToken('clientId', 'clientSecret', 'authCode')
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { SessionManager } from '../SessionManager'
|
|||||||
import { RequestClient } from '../request/RequestClient'
|
import { RequestClient } from '../request/RequestClient'
|
||||||
import * as dotenv from 'dotenv'
|
import * as dotenv from 'dotenv'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { Logger, LogLevel } from '@sasjs/utils'
|
import { Logger, LogLevel } from '@sasjs/utils/logger'
|
||||||
import { Session, Context } from '../types'
|
import { Session, Context } from '../types'
|
||||||
|
|
||||||
jest.mock('axios')
|
jest.mock('axios')
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ describe('RootFolderNotFoundError', () => {
|
|||||||
|
|
||||||
const error = new RootFolderNotFoundError(
|
const error = new RootFolderNotFoundError(
|
||||||
'/myProject',
|
'/myProject',
|
||||||
'https://analytium.co.uk',
|
'https://sas.4gl.io',
|
||||||
token
|
token
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ describe('RootFolderNotFoundError', () => {
|
|||||||
it('when access token is not provided, error message should not contain scopes', () => {
|
it('when access token is not provided, error message should not contain scopes', () => {
|
||||||
const error = new RootFolderNotFoundError(
|
const error = new RootFolderNotFoundError(
|
||||||
'/myProject',
|
'/myProject',
|
||||||
'https://analytium.co.uk'
|
'https://sas.4gl.io'
|
||||||
)
|
)
|
||||||
|
|
||||||
expect(error).toBeInstanceOf(RootFolderNotFoundError)
|
expect(error).toBeInstanceOf(RootFolderNotFoundError)
|
||||||
@@ -30,7 +30,7 @@ describe('RootFolderNotFoundError', () => {
|
|||||||
|
|
||||||
it('should include the folder path and SASDrive URL in the message', () => {
|
it('should include the folder path and SASDrive URL in the message', () => {
|
||||||
const folderPath = '/myProject'
|
const folderPath = '/myProject'
|
||||||
const serverUrl = 'https://analytium.co.uk'
|
const serverUrl = 'https://sas.4gl.io'
|
||||||
const error = new RootFolderNotFoundError(folderPath, serverUrl)
|
const error = new RootFolderNotFoundError(folderPath, serverUrl)
|
||||||
|
|
||||||
expect(error).toBeInstanceOf(RootFolderNotFoundError)
|
expect(error).toBeInstanceOf(RootFolderNotFoundError)
|
||||||
|
|||||||
Reference in New Issue
Block a user