From a097c4089b2a7f2db3c70e951d935e23b4f4293a Mon Sep 17 00:00:00 2001 From: Erik Price Date: Thu, 11 Feb 2021 03:45:10 -0800 Subject: fix(runtime/tls): handle invalid host for connectTls/startTls (#9453) --- cli/tests/unit/tls_test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'cli') diff --git a/cli/tests/unit/tls_test.ts b/cli/tests/unit/tls_test.ts index ba1f067de..fa869037e 100644 --- a/cli/tests/unit/tls_test.ts +++ b/cli/tests/unit/tls_test.ts @@ -20,6 +20,24 @@ unitTest(async function connectTLSNoPerm(): Promise { }, Deno.errors.PermissionDenied); }); +unitTest( + { perms: { read: true, net: true } }, + async function connectTLSInvalidHost(): Promise { + const listener = await Deno.listenTls({ + hostname: "localhost", + port: 3567, + certFile: "cli/tests/tls/localhost.crt", + keyFile: "cli/tests/tls/localhost.key", + }); + + await assertThrowsAsync(async () => { + await Deno.connectTls({ hostname: "127.0.0.1", port: 3567 }); + }, Error); + + listener.close(); + }, +); + unitTest(async function connectTLSCertFileNoReadPerm(): Promise { await assertThrowsAsync(async () => { await Deno.connectTls({ -- cgit v1.2.3