diff options
author | Luca Casonato <hello@lcas.dev> | 2021-12-10 11:47:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-10 11:47:21 +0100 |
commit | 6f8f1cc2443a88eed7608b895b72378ab9272681 (patch) | |
tree | 10d565de5ecf459914158cffb90d30522724303b /cli/tests | |
parent | f530189c500b9f12c4c94e88eca23eab9ae0d970 (diff) |
tests: deflake crypto InvalidIntializationVector (#13040)
Use fixed data that is known to error as the test intends.
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/unit/webcrypto_test.ts | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/cli/tests/unit/webcrypto_test.ts b/cli/tests/unit/webcrypto_test.ts index 0660d9a7e..9e22b0a49 100644 --- a/cli/tests/unit/webcrypto_test.ts +++ b/cli/tests/unit/webcrypto_test.ts @@ -746,19 +746,24 @@ Deno.test(async function testUnwrapKey() { }); Deno.test(async function testDecryptWithInvalidIntializationVector() { - const data = new Uint8Array([42, 42, 42, 42]); - const key = await crypto.subtle.generateKey( + // deno-fmt-ignore + const data = new Uint8Array([42,42,42,42,42,42,42,42,42,42,42,42,42,42,42]); + const key = await crypto.subtle.importKey( + "raw", + new Uint8Array(16), { name: "AES-CBC", length: 256 }, true, ["encrypt", "decrypt"], ); - const initVector = crypto.getRandomValues(new Uint8Array(16)); + // deno-fmt-ignore + const initVector = new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]); const encrypted = await crypto.subtle.encrypt( { name: "AES-CBC", iv: initVector }, key, data, ); - const initVector2 = crypto.getRandomValues(new Uint8Array(16)); + // deno-fmt-ignore + const initVector2 = new Uint8Array([15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0]); await assertRejects(async () => { await crypto.subtle.decrypt( { name: "AES-CBC", iv: initVector2 }, |