summaryrefslogtreecommitdiff
path: root/cli/tests/unit_node
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/unit_node')
-rw-r--r--cli/tests/unit_node/crypto_cipher_test.ts44
1 files changed, 44 insertions, 0 deletions
diff --git a/cli/tests/unit_node/crypto_cipher_test.ts b/cli/tests/unit_node/crypto_cipher_test.ts
index b14d149f5..3f740f40c 100644
--- a/cli/tests/unit_node/crypto_cipher_test.ts
+++ b/cli/tests/unit_node/crypto_cipher_test.ts
@@ -1,6 +1,8 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import crypto from "node:crypto";
import { Buffer } from "node:buffer";
+import { Readable } from "node:stream";
+import { buffer, text } from "node:stream/consumers";
import {
assertEquals,
assertThrows,
@@ -90,6 +92,27 @@ Deno.test({
});
Deno.test({
+ name: "createCipheriv - transform stream",
+ async fn() {
+ const result = await buffer(
+ Readable.from("foo".repeat(15)).pipe(crypto.createCipheriv(
+ "aes-128-cbc",
+ new Uint8Array(16),
+ new Uint8Array(16),
+ )),
+ );
+ // deno-fmt-ignore
+ assertEquals([...result], [
+ 129, 19, 202, 142, 137, 51, 23, 53, 198, 33,
+ 214, 125, 17, 5, 128, 57, 162, 217, 220, 53,
+ 172, 51, 85, 113, 71, 250, 44, 156, 80, 4,
+ 158, 92, 185, 173, 67, 47, 255, 71, 78, 187,
+ 80, 206, 42, 5, 34, 104, 1, 54
+ ]);
+ },
+});
+
+Deno.test({
name: "createDecipheriv - basic",
fn() {
const decipher = crypto.createDecipheriv(
@@ -110,3 +133,24 @@ Deno.test({
);
},
});
+
+Deno.test({
+ name: "createDecipheriv - transform stream",
+ async fn() {
+ const stream = Readable.from([
+ // deno-fmt-ignore
+ new Uint8Array([
+ 129, 19, 202, 142, 137, 51, 23, 53, 198, 33,
+ 214, 125, 17, 5, 128, 57, 162, 217, 220, 53,
+ 172, 51, 85, 113, 71, 250, 44, 156, 80, 4,
+ 158, 92, 185, 173, 67, 47, 255, 71, 78, 187,
+ 80, 206, 42, 5, 34, 104, 1, 54
+ ]),
+ ]).pipe(crypto.createDecipheriv(
+ "aes-128-cbc",
+ new Uint8Array(16),
+ new Uint8Array(16),
+ ));
+ assertEquals(await text(stream), "foo".repeat(15));
+ },
+});