diff --git a/.github/workflows/sast-scan.yml b/.github/workflows/sast-scan.yml deleted file mode 100644 index f9316303..00000000 --- a/.github/workflows/sast-scan.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: SAST Scan -on: - pull_request: - types: [opened, synchronize, reopened] -jobs: - security: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Horusec Scan - run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/src horuszup/horusec-cli:latest horusec start -p /src -P $(pwd) \ No newline at end of file diff --git a/.jsdoc.json b/.jsdoc.json index bd24065e..6da32180 100644 --- a/.jsdoc.json +++ b/.jsdoc.json @@ -26,6 +26,7 @@ "lib/stack/release/items/index.js", "lib/stack/label/index.js", "lib/stack/locale/index.js", + "lib/stack/auditlog/index.js", "lib/stack/environment/index.js", "lib/stack/deliveryToken/index.js", "lib/stack/roles/index.js", diff --git a/lib/core/concurrency-queue.js b/lib/core/concurrency-queue.js index 2deeac7f..21e3fef3 100644 --- a/lib/core/concurrency-queue.js +++ b/lib/core/concurrency-queue.js @@ -93,18 +93,18 @@ export function ConcurrencyQueue ({ axios, config }) { } if (this.paused && request.retryCount > 0) { - return new Promise(resolve => { - this.unshift({ request, resolve }) + return new Promise((resolve, reject) => { + this.unshift({ request, resolve, reject }) }) } else if (request.retryCount > 0) { return request } - return new Promise(resolve => { + return new Promise((resolve, reject) => { request.onComplete = () => { - this.running.pop({ request, resolve }) + this.running.pop({ request, resolve, reject }) } - this.push({ request, resolve }) + this.push({ request, resolve, reject }) }) } @@ -131,6 +131,7 @@ export function ConcurrencyQueue ({ axios, config }) { }, time)) } } + const refreshToken = () => { return config.refreshToken().then((token) => { if (token.authorization) { @@ -146,8 +147,19 @@ export function ConcurrencyQueue ({ axios, config }) { axios.httpClientParams.headers.authtoken = token.authtoken this.config.authtoken = token.authtoken } - }).catch((error) => { - throw error + }).catch(() => { + this.queue.forEach(queueItem => { + queueItem.reject({ + errorCode: '401', + errorMessage: 'Unable to refresh token', + code: 'Unauthorized', + message: 'Request failed with status code 401', + name: 'Token Error', + config: queueItem.request + }) + }) + this.queue = [] + this.running = [] }).finally(() => { this.queue.forEach((queueItem) => { if (this.config.authorization) { diff --git a/lib/stack/locale/index.js b/lib/stack/locale/index.js index 6a43f3f1..6edafa45 100644 --- a/lib/stack/locale/index.js +++ b/lib/stack/locale/index.js @@ -24,9 +24,8 @@ export function Locale (http, data = {}) { * * client.stack({ api_key: 'api_key'}).locale('locale_code').fetch() * .then((locale) => { - * locale.title = 'My New Content Type' - * locale.description = 'Content Type description' - * return locale.update() + * locale.fallback_locale = 'en-at' + * return locale.update() * }) * .then((locale) => console.log(locale)) * diff --git a/test/unit/concurrency-Queue-test.js b/test/unit/concurrency-Queue-test.js index d5021e6e..8d52fa7e 100644 --- a/test/unit/concurrency-Queue-test.js +++ b/test/unit/concurrency-Queue-test.js @@ -69,6 +69,10 @@ describe('Concurrency queue test', () => { if (req.url === '/user-session') { res.writeHead(200, { 'Content-Type': 'application/json' }) res.end(JSON.stringify({ token })) + + // Test for refresh token error - uncomment this + // res.writeHead(401, { 'Content-Type': 'application/json' }) + // res.end(JSON.stringify({ errorCode: 401 })) } else if (req.url === '/unauthorized') { if (req.headers.authorization === token) { res.writeHead(200, { 'Content-Type': 'application/json' })