From 92ed4d38dbef98b9353d6dd6d96abb400be56f9f Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Wed, 23 Oct 2024 13:17:43 +0530 Subject: fix(node:tls): set TLSSocket.alpnProtocol for client connections (#26476) Towards https://github.com/denoland/deno/issues/26127 --- tests/unit_node/tls_test.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/unit_node') 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)); +}); -- cgit v1.2.3