From f49822989cc5cf7b5a4e11cf83cbe6adb4c607c0 Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Thu, 23 Mar 2023 09:38:52 +0100 Subject: [PATCH] [EC-598] chore: rearrange tests --- .../fido2-authenticator.service.spec.ts | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/libs/common/src/webauthn/services/fido2-authenticator.service.spec.ts b/libs/common/src/webauthn/services/fido2-authenticator.service.spec.ts index b0f3441631..2503b198e8 100644 --- a/libs/common/src/webauthn/services/fido2-authenticator.service.spec.ts +++ b/libs/common/src/webauthn/services/fido2-authenticator.service.spec.ts @@ -152,7 +152,7 @@ describe("FidoAuthenticatorService", () => { }); }); - describe("when input passes all initial checks", () => { + describe("creation of discoverable credential", () => { /** Spec: show the items contained within the user and rp parameter structures to the user. */ it("should request confirmation from user", async () => { userInterface.confirmNewCredential.mockResolvedValue(true); @@ -166,20 +166,6 @@ describe("FidoAuthenticatorService", () => { } as NewCredentialParams); }); - /** Spec: If the user declines permission, return the CTAP2_ERR_OPERATION_DENIED error. */ - it("should throw error if user denies creation request", async () => { - userInterface.confirmNewCredential.mockResolvedValue(false); - const params = await createCredentialParams(); - - const result = async () => await authenticator.makeCredential(params); - - await expect(result).rejects.toThrowError( - Fido2AutenticatorErrorCode[Fido2AutenticatorErrorCode.CTAP2_ERR_OPERATION_DENIED] - ); - }); - }); - - describe("creation of discoverable credential", () => { it("should save credential to vault if request confirmed by user", async () => { const encryptedCipher = Symbol(); userInterface.confirmNewCredential.mockResolvedValue(true); @@ -206,6 +192,18 @@ describe("FidoAuthenticatorService", () => { ); expect(cipherService.createWithServer).toHaveBeenCalledWith(encryptedCipher); }); + + /** Spec: If the user declines permission, return the CTAP2_ERR_OPERATION_DENIED error. */ + it("should throw error if user denies creation request", async () => { + userInterface.confirmNewCredential.mockResolvedValue(false); + const params = await createCredentialParams(); + + const result = async () => await authenticator.makeCredential(params); + + await expect(result).rejects.toThrowError( + Fido2AutenticatorErrorCode[Fido2AutenticatorErrorCode.CTAP2_ERR_OPERATION_DENIED] + ); + }); }); }); });