mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
Add context to logs for decryption failures (#11684)
* Add logging to decryption routines * Fix case of uknown encryption type * Add decryption context to log where failures occur * Update log message * Fix linting * Add more context logs * Add more fine grained logging * Update log message * Fix tests
This commit is contained in:
@@ -149,7 +149,7 @@ describe("EncString", () => {
|
||||
const key = new SymmetricCryptoKey(makeStaticByteArray(32));
|
||||
await encString.decryptWithKey(key, encryptService);
|
||||
|
||||
expect(encryptService.decryptToUtf8).toHaveBeenCalledWith(encString, key);
|
||||
expect(encryptService.decryptToUtf8).toHaveBeenCalledWith(encString, key, "domain-withkey");
|
||||
});
|
||||
|
||||
it("fails to decrypt when key is null", async () => {
|
||||
@@ -351,7 +351,7 @@ describe("EncString", () => {
|
||||
await encString.decrypt(null, key);
|
||||
|
||||
expect(keyService.getUserKeyWithLegacySupport).not.toHaveBeenCalled();
|
||||
expect(encryptService.decryptToUtf8).toHaveBeenCalledWith(encString, key);
|
||||
expect(encryptService.decryptToUtf8).toHaveBeenCalledWith(encString, key, "provided-key");
|
||||
});
|
||||
|
||||
it("gets an organization key if required", async () => {
|
||||
@@ -362,7 +362,11 @@ describe("EncString", () => {
|
||||
await encString.decrypt("orgId", null);
|
||||
|
||||
expect(keyService.getOrgKey).toHaveBeenCalledWith("orgId");
|
||||
expect(encryptService.decryptToUtf8).toHaveBeenCalledWith(encString, orgKey);
|
||||
expect(encryptService.decryptToUtf8).toHaveBeenCalledWith(
|
||||
encString,
|
||||
orgKey,
|
||||
"domain-orgkey-orgId",
|
||||
);
|
||||
});
|
||||
|
||||
it("gets the user's decryption key if required", async () => {
|
||||
@@ -373,7 +377,11 @@ describe("EncString", () => {
|
||||
await encString.decrypt(null, null);
|
||||
|
||||
expect(keyService.getUserKeyWithLegacySupport).toHaveBeenCalledWith();
|
||||
expect(encryptService.decryptToUtf8).toHaveBeenCalledWith(encString, userKey);
|
||||
expect(encryptService.decryptToUtf8).toHaveBeenCalledWith(
|
||||
encString,
|
||||
userKey,
|
||||
"domain-withlegacysupport-masterkey",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user