summaryrefslogtreecommitdiff
path: root/cli/tests/unit_node
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2023-03-17 02:55:12 +0530
committerGitHub <noreply@github.com>2023-03-16 22:25:12 +0100
commit1300d6178e8863a220fa301e9fde8be3580d9b66 (patch)
treea29b839ea2583339042fafd90387990ea2d4ac94 /cli/tests/unit_node
parent2c7174a5a245ff5d7e4e9f7a1fafb578be9a3ef2 (diff)
fix(ext/node): resource leak in createHmac (#18229)
This commit fixes https://github.com/denoland/deno/issues/18140. Verified that test fails on `main`.
Diffstat (limited to 'cli/tests/unit_node')
-rw-r--r--cli/tests/unit_node/crypto_hash.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/cli/tests/unit_node/crypto_hash.ts b/cli/tests/unit_node/crypto_hash.ts
new file mode 100644
index 000000000..fae66e024
--- /dev/null
+++ b/cli/tests/unit_node/crypto_hash.ts
@@ -0,0 +1,24 @@
+// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+import { createHash, createHmac } from "node:crypto";
+import { assertEquals } from "../../../test_util/std/testing/asserts.ts";
+
+// https://github.com/denoland/deno/issues/18140
+Deno.test({
+ name: "createHmac digest",
+ fn() {
+ assertEquals(
+ createHmac("sha256", "secret").update("hello").digest("hex"),
+ "88aab3ede8d3adf94d26ab90d3bafd4a2083070c3bcce9c014ee04a443847c0b",
+ );
+ },
+});
+
+Deno.test({
+ name: "createHash digest",
+ fn() {
+ assertEquals(
+ createHash("sha256").update("hello").digest("hex"),
+ "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824",
+ );
+ },
+});