mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
[EC-598] chore: rearrange tests
This commit is contained in:
@@ -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. */
|
/** Spec: show the items contained within the user and rp parameter structures to the user. */
|
||||||
it("should request confirmation from user", async () => {
|
it("should request confirmation from user", async () => {
|
||||||
userInterface.confirmNewCredential.mockResolvedValue(true);
|
userInterface.confirmNewCredential.mockResolvedValue(true);
|
||||||
@@ -166,20 +166,6 @@ describe("FidoAuthenticatorService", () => {
|
|||||||
} as NewCredentialParams);
|
} 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 () => {
|
it("should save credential to vault if request confirmed by user", async () => {
|
||||||
const encryptedCipher = Symbol();
|
const encryptedCipher = Symbol();
|
||||||
userInterface.confirmNewCredential.mockResolvedValue(true);
|
userInterface.confirmNewCredential.mockResolvedValue(true);
|
||||||
@@ -206,6 +192,18 @@ describe("FidoAuthenticatorService", () => {
|
|||||||
);
|
);
|
||||||
expect(cipherService.createWithServer).toHaveBeenCalledWith(encryptedCipher);
|
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]
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user