Skip to content

Commit

Permalink
update tests, add secondary test
Browse files Browse the repository at this point in the history
  • Loading branch information
beckpaul committed Dec 4, 2023
1 parent 1f6044f commit 322b78e
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/integration/accountRouter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 322b78e

Please sign in to comment.