summaryrefslogtreecommitdiff
path: root/tests/unit_node
diff options
context:
space:
mode:
authorSatya Rohith <me@satyarohith.com>2024-10-23 13:17:43 +0530
committerGitHub <noreply@github.com>2024-10-23 07:47:43 +0000
commit92ed4d38dbef98b9353d6dd6d96abb400be56f9f (patch)
tree82da9fd3887990188afe972a7f0edc9d5df26346 /tests/unit_node
parentbe969cb5328bb83c26022ea5307467b40647cb64 (diff)
fix(node:tls): set TLSSocket.alpnProtocol for client connections (#26476)
Towards https://github.com/denoland/deno/issues/26127
Diffstat (limited to 'tests/unit_node')
-rw-r--r--tests/unit_node/tls_test.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/unit_node/tls_test.ts b/tests/unit_node/tls_test.ts
index 847ec2dde..236dab208 100644
--- a/tests/unit_node/tls_test.ts
+++ b/tests/unit_node/tls_test.ts
@@ -235,3 +235,31 @@ Deno.test("tls.rootCertificates is not empty", () => {
(tls.rootCertificates as string[]).push("new cert");
}, TypeError);
});
+
+Deno.test("TLSSocket.alpnProtocol is set for client", async () => {
+ const listener = Deno.listenTls({
+ hostname: "localhost",
+ port: 0,
+ key,
+ cert,
+ alpnProtocols: ["a"],
+ });
+ const outgoing = tls.connect({
+ host: "::1",
+ servername: "localhost",
+ port: listener.addr.port,
+ ALPNProtocols: ["a"],
+ secureContext: {
+ ca: rootCaCert,
+ // deno-lint-ignore no-explicit-any
+ } as any,
+ });
+
+ const conn = await listener.accept();
+ const handshake = await conn.handshake();
+ assertEquals(handshake.alpnProtocol, "a");
+ conn.close();
+ outgoing.destroy();
+ listener.close();
+ await new Promise((resolve) => outgoing.on("close", resolve));
+});