Skip to content

Commit

Permalink
test(core): add verification record rewrite test
Browse files Browse the repository at this point in the history
add verification record rewrite test
  • Loading branch information
simeng-li committed Jul 3, 2024
1 parent 9173418 commit 9411401
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class CodeVerification implements VerificationRecord<VerificationType.Ver
*
* @remark Instead of session jti,
* the verification id is used as `interaction_jti` to uniquely identify the passcode record in DB
* for the current interaction session.
* for the current interaction.
*/
private async sendVerificationCode() {
const { createPasscode, sendPasscode } = this.libraries.passcodes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,42 @@ devFeatureTest.describe('Verification code verification APIs', () => {
);
});

it('should throw a 404 error if the verification record is overwrote by a concurrent verification request', async () => {
const client = await initExperienceClient();

const { verificationId, code } = await successfullySendVerificationCode(client, {
interactionEvent: InteractionEvent.SignIn,
identifier: {
type,
value,
},
});

// Resend and recreate the verification record
await successfullySendVerificationCode(client, {
interactionEvent: InteractionEvent.SignIn,
identifier: {
type,
value,
},
});

await expectRejects(
client.verifyVerificationCode({
code,
identifier: {
type,
value,
},
verificationId,
}),
{
code: 'session.verification_session_not_found',
status: 404,
}
);
});

it('should throw a 400 error if the identifier is different', async () => {
const client = await initExperienceClient();

Expand Down

0 comments on commit 9411401

Please sign in to comment.