summaryrefslogtreecommitdiff
path: root/tests/unit_node
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2024-09-11 19:19:02 +0900
committerGitHub <noreply@github.com>2024-09-11 19:19:02 +0900
commit200145a09a51e96298f1ecd5ce78f75c27c7880a (patch)
tree9fce91280f324673233d435523d6fb675e137fba /tests/unit_node
parentad30703e8e6bcf0fb87b5bc4ad1b49d040e54c77 (diff)
fix(ext/node): avoid showing `UNKNOWN` error from TCP handle (#25550)
Diffstat (limited to 'tests/unit_node')
-rw-r--r--tests/unit_node/tls_test.ts28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/unit_node/tls_test.ts b/tests/unit_node/tls_test.ts
index 4ee622a67..6826ab84c 100644
--- a/tests/unit_node/tls_test.ts
+++ b/tests/unit_node/tls_test.ts
@@ -1,11 +1,16 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-import { assertEquals, assertInstanceOf } from "@std/assert";
+import {
+ assertEquals,
+ assertInstanceOf,
+ assertStringIncludes,
+} from "@std/assert";
import { delay } from "@std/async/delay";
import { fromFileUrl, join } from "@std/path";
import * as tls from "node:tls";
import * as net from "node:net";
import * as stream from "node:stream";
+import { execCode } from "../unit/test_util.ts";
const tlsTestdataDir = fromFileUrl(
new URL("../testdata/tls", import.meta.url),
@@ -189,3 +194,24 @@ Deno.test("tlssocket._handle._parentWrap is set", () => {
._parentWrap;
assertInstanceOf(parentWrap, stream.PassThrough);
});
+
+Deno.test("tls.connect() throws InvalidData when there's error in certificate", async () => {
+ // Uses execCode to avoid `--unsafely-ignore-certificate-errors` option applied
+ const [status, output] = await execCode(`
+ import tls from "node:tls";
+ const conn = tls.connect({
+ host: "localhost",
+ port: 4557,
+ });
+
+ conn.on("error", (err) => {
+ console.log(err);
+ });
+ `);
+
+ assertEquals(status, 0);
+ assertStringIncludes(
+ output,
+ "InvalidData: invalid peer certificate: UnknownIssuer",
+ );
+});