summaryrefslogtreecommitdiff
path: root/tests/integration/run_tests.rs
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2024-05-09 10:54:47 -0600
committerGitHub <noreply@github.com>2024-05-09 10:54:47 -0600
commit684377c92c88877d97c522bcc4cd6a4175277dfb (patch)
tree192e84a3f3daceb5bd47d787eedba32416dcba3c /tests/integration/run_tests.rs
parentdc29986ae591425f4a653a7155d41d75fbf7931a (diff)
refactor(ext/tls): Implement required functionality for later SNI support (#23686)
Precursor to #23236 This implements the SNI features, but uses private symbols to avoid exposing the functionality at this time. Note that to properly test this feature, we need to add a way for `connectTls` to specify a hostname. This is something that should be pushed into that API at a later time as well. ```ts Deno.test( { permissions: { net: true, read: true } }, async function listenResolver() { let sniRequests = []; const listener = Deno.listenTls({ hostname: "localhost", port: 0, [resolverSymbol]: (sni: string) => { sniRequests.push(sni); return { cert, key, }; }, }); { const conn = await Deno.connectTls({ hostname: "localhost", [serverNameSymbol]: "server-1", port: listener.addr.port, }); const [_handshake, serverConn] = await Promise.all([ conn.handshake(), listener.accept(), ]); conn.close(); serverConn.close(); } { const conn = await Deno.connectTls({ hostname: "localhost", [serverNameSymbol]: "server-2", port: listener.addr.port, }); const [_handshake, serverConn] = await Promise.all([ conn.handshake(), listener.accept(), ]); conn.close(); serverConn.close(); } assertEquals(sniRequests, ["server-1", "server-2"]); listener.close(); }, ); ``` --------- Signed-off-by: Matt Mastracci <matthew@mastracci.com>
Diffstat (limited to 'tests/integration/run_tests.rs')
-rw-r--r--tests/integration/run_tests.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs
index 88ddfb318..8a24603b3 100644
--- a/tests/integration/run_tests.rs
+++ b/tests/integration/run_tests.rs
@@ -13,6 +13,7 @@ use deno_core::serde_json::json;
use deno_core::url;
use deno_fetch::reqwest;
use deno_tls::rustls;
+use deno_tls::rustls::ClientConnection;
use deno_tls::rustls_pemfile;
use deno_tls::TlsStream;
use pretty_assertions::assert_eq;
@@ -5388,8 +5389,11 @@ async fn listen_tls_alpn() {
let tcp_stream = tokio::net::TcpStream::connect("localhost:4504")
.await
.unwrap();
- let mut tls_stream =
- TlsStream::new_client_side(tcp_stream, cfg, hostname, None);
+ let mut tls_stream = TlsStream::new_client_side(
+ tcp_stream,
+ ClientConnection::new(cfg, hostname).unwrap(),
+ None,
+ );
let handshake = tls_stream.handshake().await.unwrap();
@@ -5437,8 +5441,11 @@ async fn listen_tls_alpn_fail() {
let tcp_stream = tokio::net::TcpStream::connect("localhost:4505")
.await
.unwrap();
- let mut tls_stream =
- TlsStream::new_client_side(tcp_stream, cfg, hostname, None);
+ let mut tls_stream = TlsStream::new_client_side(
+ tcp_stream,
+ ClientConnection::new(cfg, hostname).unwrap(),
+ None,
+ );
tls_stream.handshake().await.unwrap_err();