diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cb4eee7..c2cabf8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,19 +22,75 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: npm + - name: Check npm audit run: npm audit --production --audit-level=low + - name: Install Dependencies run: npm ci + - name: Check code style run: npm run lint + - name: Run unit tests run: npm test + - name: Generate coverage report uses: artiomtr/jest-coverage-report-action@v2.0-rc.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Build Package run: npm run package:lib env: CI: true + + - name: Install SSH Key + uses: shimataro/ssh-key-action@v2 + with: + key: ${{ secrets.DCGITLAB_KEY }} + known_hosts: 'placeholder' + + - name: Write VPN Files + run: | + echo "$CA_CRT" > .github/vpn/ca.crt + echo "$USER_CRT" > .github/vpn/user.crt + echo "$USER_KEY" > .github/vpn/user.key + echo "$TLS_KEY" > .github/vpn/tls.key + shell: bash + env: + CA_CRT: ${{ secrets.CA_CRT}} + USER_CRT: ${{ secrets.USER_CRT }} + USER_KEY: ${{ secrets.USER_KEY }} + TLS_KEY: ${{ secrets.TLS_KEY }} + + - name: Install Open VPN + run: | + sudo apt install apt-transport-https + sudo wget https://swupdate.openvpn.net/repos/openvpn-repo-pkg-key.pub + sudo apt-key add openvpn-repo-pkg-key.pub + sudo wget -O /etc/apt/sources.list.d/openvpn3.list https://swupdate.openvpn.net/community/openvpn3/repos/openvpn3-focal.list + sudo apt update + sudo apt install openvpn3=16~beta+focal + + - name: Start Open VPN 3 + run: openvpn3 session-start --config .github/vpn/config.ovpn + + - name: Deploy sasjs-tests + run: | + npm install -g replace-in-files-cli + cd sasjs-tests + replace-in-files --regex='"@sasjs/adapter".*' --replacement='"@sasjs/adapter":"latest",' ./package.json + npm i + replace-in-files --regex='"userName".*' --replacement='"userName":"${{ secrets.SASJS_USERNAME }}",' ./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 + npm run update:adapter && npm run build + scp -o stricthostkeychecking=no -r ./build/* ${{ secrets.DCGITLAB_DEPLOY_PATH_VIYA }} + + - name: Run cypress on sasjs + run: | + replace-in-files --regex='"sasjsTestsUrl".*' --replacement='"sasjsTestsUrl":"${{ secrets.SASJS_TEST_URL_VIYA }}",' ./cypress.json + replace-in-files --regex='"username".*' --replacement='"username":"${{ secrets.SASJS_USERNAME }}",' ./cypress.json + replace-in-files --regex='"password".*' --replacement='"password":"${{ secrets.SASJS_PASSWORD }}",' ./cypress.json + sh ./sasjs-cypress-run.sh ${{ secrets.SLACK_WEBHOOK }} diff --git a/sasjs-tests/package-lock.json b/sasjs-tests/package-lock.json index 3ae0af7..b19244b 100644 --- a/sasjs-tests/package-lock.json +++ b/sasjs-tests/package-lock.json @@ -2604,7 +2604,7 @@ "node_modules/@sasjs/adapter": { "version": "5.0.0", "resolved": "file:../build/sasjs-adapter-5.0.0.tgz", - "integrity": "sha512-Sr2fkOl/WqqnmZEsiCURe1+dYicuj3gE8lvzhFA1oiKUVKg0Ho552MsQvIg4qreqSmPWpHE7IY41c0tJw0sxkA==", + "integrity": "sha512-ARa1FFOHFdiVI/oHngmd5AJv6OZxeCwcHkpYEdrpY5syCg3hvTBYvmUZmxN4cRzwSsxAdiO9NGrHMgHbn5fV0Q==", "hasInstallScript": true, "license": "ISC", "dependencies": { @@ -23331,7 +23331,7 @@ }, "@sasjs/adapter": { "version": "file:../build/sasjs-adapter-5.0.0.tgz", - "integrity": "sha512-Sr2fkOl/WqqnmZEsiCURe1+dYicuj3gE8lvzhFA1oiKUVKg0Ho552MsQvIg4qreqSmPWpHE7IY41c0tJw0sxkA==", + "integrity": "sha512-ARa1FFOHFdiVI/oHngmd5AJv6OZxeCwcHkpYEdrpY5syCg3hvTBYvmUZmxN4cRzwSsxAdiO9NGrHMgHbn5fV0Q==", "requires": { "@sasjs/utils": "2.44.0", "axios": "0.26.0", diff --git a/src/auth/AuthManager.ts b/src/auth/AuthManager.ts index 310b907..c9a0333 100644 --- a/src/auth/AuthManager.ts +++ b/src/auth/AuthManager.ts @@ -100,12 +100,15 @@ export class AuthManager { password, clientId ) - .then((res) => { + .then(async (res) => { this.userName = username this.requestClient.saveLocalStorageToken( res.access_token, res.refresh_token ) + + await this.loginCallback() + return true }) .catch(() => false)