From 8429acac74a9aeba66ce4c55f9f162a7ea219325 Mon Sep 17 00:00:00 2001 From: ckoegel Date: Wed, 18 Oct 2023 11:36:59 -0400 Subject: [PATCH] add 403 tests --- jest.config.js | 2 ++ tests/integration/calls-api.test.js | 11 +++++++++++ tests/integration/statistics-api.test.js | 11 +++++++++++ 3 files changed, 24 insertions(+) diff --git a/jest.config.js b/jest.config.js index 0d2ba81..da6727c 100644 --- a/jest.config.js +++ b/jest.config.js @@ -16,6 +16,8 @@ module.exports = { 'MANTECA_IDLE_NUMBER': process.env.MANTECA_IDLE_NUMBER, 'MANTECA_ACTIVE_NUMBER': process.env.MANTECA_ACTIVE_NUMBER, 'MANTECA_BASE_URL': process.env.MANTECA_BASE_URL, + 'FORBIDDEN_USERNAME': process.env.BW_USERNAME_FORBIDDEN, + 'FORBIDDEN_PASSWORD': process.env.BW_PASSWORD_FORBIDDEN, 'UNAUTHORIZED_USERNAME': 'bad_username', 'UNAUTHORIZED_PASSWORD': 'bad_password', 'MAX_RETRIES': 40, diff --git a/tests/integration/calls-api.test.js b/tests/integration/calls-api.test.js index bd03bcb..a1206a9 100644 --- a/tests/integration/calls-api.test.js +++ b/tests/integration/calls-api.test.js @@ -171,6 +171,17 @@ describe('CallsApi', () => { } }); + test('403', async () => { + const configBad = new Configuration({username: FORBIDDEN_USERNAME, password: FORBIDDEN_PASSWORD}); + const callsApiBad = new CallsApi(configBad); + + try { + await callsApiBad.getCallState(BW_ACCOUNT_ID, callId); + } catch (e) { + expect(e.response.status).toEqual(403); + } + }); + test('404', async () => { try { await callsApi.getCallState(BW_ACCOUNT_ID, 'does-not-exist'); diff --git a/tests/integration/statistics-api.test.js b/tests/integration/statistics-api.test.js index a0a36e2..c3da67f 100644 --- a/tests/integration/statistics-api.test.js +++ b/tests/integration/statistics-api.test.js @@ -26,5 +26,16 @@ describe('StatisticsApi', () => { expect(e.response.status).toEqual(401); } }); + + test('403', async () => { + const configBad = new Configuration({username: FORBIDDEN_USERNAME, password: FORBIDDEN_PASSWORD}); + const statisticsApiBad = new StatisticsApi(configBad); + + try { + await statisticsApiBad.getStatistics(BW_ACCOUNT_ID); + } catch (e) { + expect(e.response.status).toEqual(403); + } + }); }); });