Skip to content

Commit 69ef446

Browse files
author
michael kappes
committed
added test for key to short/long
1 parent 4b5d5b8 commit 69ef446

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/get-algorithm.function.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,21 @@ describe("get-algorithm", () => {
2323
// THEN
2424
expect(result.cipher).toBe(Algorithm.AES256CBC);
2525
});
26+
27+
it("should throw new Invalid key length, key too short", () => {
28+
// GIVEN
29+
const base64Key = "TIzNDU2Nzg5MTAxMTEyCg==";
30+
31+
// THEN
32+
expect(() => getAlgorithm(base64Key)).toThrow(new Error("Invalid key length: 15"));
33+
});
34+
35+
it("should throw new Invalid key length, key too long", () => {
36+
// GIVEN
37+
const base64Key = "CCTIzNDU2Nzg5MTAxMTEyCg==";
38+
39+
// THEN
40+
expect(() => getAlgorithm(base64Key)).toThrow(new Error("Invalid key length: 17"));
41+
});
42+
2643
});

0 commit comments

Comments
 (0)