1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-02-08 00:01:28 +01:00

[EC-598] chore: rearrange tests

This commit is contained in:
Andreas Coroiu 2023-03-23 09:38:52 +01:00
parent 260bcc9f9e
commit f49822989c
No known key found for this signature in database
GPG Key ID: E70B5FFC81DFEC1A

View File

@ -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]
);
});
});
});
});