From 322b78e8e9a91c42fcf126af6b3067208942d61d Mon Sep 17 00:00:00 2001 From: beckpaul Date: Sun, 3 Dec 2023 21:01:50 -0500 Subject: [PATCH] update tests, add secondary test --- tests/integration/accountRouter.test.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/integration/accountRouter.test.js b/tests/integration/accountRouter.test.js index 80cbf2c4..177328d2 100644 --- a/tests/integration/accountRouter.test.js +++ b/tests/integration/accountRouter.test.js @@ -26,10 +26,28 @@ describe('Account Routes', function () { expect(response.statusCode).toBe(200) }) - test('redirect to reset request page if missing parameters with flash parameter', async () => { - const response = await testSession.get('/account/password/confirmReset') + test('redirect to reset request page if missing username parameter with flash parameter', async () => { + const response = await testSession.get('/account/password/confirmReset?token=XXXXX') + + const flashValue = response.headers.location.match(/flash=([^&]+)/)[1] + const buff = Buffer.from(flashValue, 'base64') + const text = JSON.parse(buff.toString('ascii')).messages[0].msg + + expect(response.statusCode).toBe(302) + expect(response.headers.location).toContain('/account/requestPasswordReset?flash=') + expect(text).toBe('Missing username') + }) + + test('redirect to reset request page if missing token parameter with flash parameter', async () => { + const response = await testSession.get('/account/password/confirmReset?username=turbo2') + + const flashValue = response.headers.location.match(/flash=([^&]+)/)[1] + const buff = Buffer.from(flashValue, 'base64') + const text = JSON.parse(buff.toString('ascii')).messages[0].msg + expect(response.statusCode).toBe(302) expect(response.headers.location).toContain('/account/requestPasswordReset?flash=') + expect(text).toBe('Missing token') }) test('redirect old pw-reset routes', async () => {