fix: breaking test for email confirmation API call

This commit is contained in:
Julian Lam
2023-01-27 11:46:10 -05:00
parent a2cbd5d3c4
commit bb5d8ea851
2 changed files with 19 additions and 2 deletions

View File

@@ -2,6 +2,14 @@ get:
tags:
- authentication
summary: Verify an email address
parameters:
- in: path
name: code
schema:
type: string
required: true
description: a valid confirmation code
example: f8c4a54a-47ae-40f5-a0a5-356d6a35c24e
responses:
"200":
description: Email address verified, or confirmation code was incorrect

View File

@@ -49,6 +49,13 @@ describe('API', async () => {
}, nconf.get('secret')))(),
},
],
'/api/confirm/{code}': [
{
in: 'path',
name: 'code',
example: '', // to be defined later...
},
],
},
post: {},
put: {},
@@ -110,12 +117,14 @@ describe('API', async () => {
}
// Create sample users
const adminUid = await user.create({ username: 'admin', password: '123456', email: 'test@example.org' });
const unprivUid = await user.create({ username: 'unpriv', password: '123456', email: 'unpriv@example.org' });
const adminUid = await user.create({ username: 'admin', password: '123456' });
const unprivUid = await user.create({ username: 'unpriv', password: '123456' });
const emailConfirmationUid = await user.create({ username: 'emailConf', email: 'emailConf@example.org' });
await user.setUserField(adminUid, 'email', 'test@example.org');
await user.setUserField(unprivUid, 'email', 'unpriv@example.org');
await user.email.confirmByUid(adminUid);
await user.email.confirmByUid(unprivUid);
mocks.get['/api/confirm/{code}'][0].example = await db.get(`confirm:byUid:${emailConfirmationUid}`);
for (let x = 0; x < 4; x++) {
// eslint-disable-next-line no-await-in-loop