diff --git a/libs/common/src/key-management/crypto/services/encrypt.service.spec.ts b/libs/common/src/key-management/crypto/services/encrypt.service.spec.ts index ef58af4c426..c0533e60176 100644 --- a/libs/common/src/key-management/crypto/services/encrypt.service.spec.ts +++ b/libs/common/src/key-management/crypto/services/encrypt.service.spec.ts @@ -266,7 +266,7 @@ describe("EncryptService", () => { const plainValue = makeStaticByteArray(16, 1); it("throws if no key is provided", () => { - return expect(encryptService.encryptFileData(plainValue, null)).rejects.toThrow( + return expect(encryptService.encryptToBytes(plainValue, null)).rejects.toThrow( "No encryption key", ); }); @@ -281,11 +281,11 @@ describe("EncryptService", () => { encryptionKey: mock32Key.key, }); - await expect(encryptService.encryptFileData(plainValue, key)).rejects.toThrow( + await expect(encryptService.encryptToBytes(plainValue, key)).rejects.toThrow( "Type 0 encryption is not supported.", ); - await expect(encryptService.encryptFileData(plainValue, mock32Key)).rejects.toThrow( + await expect(encryptService.encryptToBytes(plainValue, mock32Key)).rejects.toThrow( "Type 0 encryption is not supported.", ); }); @@ -297,7 +297,7 @@ describe("EncryptService", () => { cryptoFunctionService.randomBytes.mockResolvedValue(iv as CsprngArray); cryptoFunctionService.aesEncrypt.mockResolvedValue(cipherText); - const actual = await encryptService.encryptFileData(plainValue, key); + const actual = await encryptService.encryptToBytes(plainValue, key); const expectedBytes = new Uint8Array(1 + iv.byteLength + cipherText.byteLength); expectedBytes.set([EncryptionType.AesCbc256_B64]); expectedBytes.set(iv, 1); @@ -315,7 +315,7 @@ describe("EncryptService", () => { cryptoFunctionService.aesEncrypt.mockResolvedValue(cipherText); cryptoFunctionService.hmac.mockResolvedValue(mac); - const actual = await encryptService.encryptFileData(plainValue, key); + const actual = await encryptService.encryptToBytes(plainValue, key); const expectedBytes = new Uint8Array( 1 + iv.byteLength + mac.byteLength + cipherText.byteLength, ); @@ -629,7 +629,9 @@ describe("EncryptService", () => { it("is a proxy to decryptBytes", async () => { const key = new SymmetricCryptoKey(makeStaticByteArray(64)); const encString = new EncString(EncryptionType.AesCbc256_B64, "data"); - encryptService.decryptBytes = jest.fn(); + const jestFn = jest.fn(); + jestFn.mockResolvedValue(new Uint8Array(64)); + encryptService.decryptBytes = jestFn; await encryptService.unwrapSymmetricKey(encString, key); expect(encryptService.decryptBytes).toHaveBeenCalledWith(encString, key); });