Skip to content

Commit

Permalink
test(crypto): add regression test for re-export of native crypto.getR…
Browse files Browse the repository at this point in the history
…andomValues() (#3688)

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
  • Loading branch information
jeremyBanks and iuioiua authored Oct 11, 2023
1 parent 5e7d99d commit b8cd759
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion crypto/crypto_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { assert, assertEquals } from "../assert/mod.ts";
import { assert, assertEquals, assertInstanceOf } from "../assert/mod.ts";
import { crypto as stdCrypto } from "./mod.ts";
import { repeat } from "../bytes/repeat.ts";
import { dirname, fromFileUrl } from "../path/mod.ts";
Expand Down Expand Up @@ -1418,3 +1418,14 @@ Deno.test({
assert(stdCrypto.subtle.timingSafeEqual(a.buffer, b.buffer));
},
});

/**
* This is one of many methods of `crypto` for which we don't have our own
* implementation, and just pass calls through to the native implementation.
* This test doesn't cover any cryptographic logic but just serves to ensure
* that (at least this one of) the native methods are indeed re-exported, and
* that they're appropriately bound to use the required receiver.
*/
Deno.test("[crypto/getRandomValues] passes through to native implementation", () => {
assertInstanceOf(stdCrypto.getRandomValues(new Uint8Array(1)), Uint8Array);
});

0 comments on commit b8cd759

Please sign in to comment.