diff options
Diffstat (limited to 'cli/tests/unit/tls_test.ts')
-rw-r--r-- | cli/tests/unit/tls_test.ts | 72 |
1 files changed, 41 insertions, 31 deletions
diff --git a/cli/tests/unit/tls_test.ts b/cli/tests/unit/tls_test.ts index 8472d93e0..12fe9bd50 100644 --- a/cli/tests/unit/tls_test.ts +++ b/cli/tests/unit/tls_test.ts @@ -37,8 +37,8 @@ unitTest( const listener = await Deno.listenTls({ hostname: "localhost", port: 3567, - certFile: "cli/tests/tls/localhost.crt", - keyFile: "cli/tests/tls/localhost.key", + certFile: "cli/tests/testdata/tls/localhost.crt", + keyFile: "cli/tests/testdata/tls/localhost.key", }); await assertThrowsAsync(async () => { @@ -54,7 +54,7 @@ unitTest(async function connectTLSCertFileNoReadPerm() { await Deno.connectTls({ hostname: "deno.land", port: 443, - certFile: "cli/tests/tls/RootCA.crt", + certFile: "cli/tests/testdata/tls/RootCA.crt", }); }, Deno.errors.PermissionDenied); }); @@ -65,8 +65,8 @@ unitTest( const options = { hostname: "localhost", port: 3500, - certFile: "cli/tests/tls/localhost.crt", - keyFile: "cli/tests/tls/localhost.key", + certFile: "cli/tests/testdata/tls/localhost.crt", + keyFile: "cli/tests/testdata/tls/localhost.key", }; assertThrows(() => { @@ -90,8 +90,8 @@ unitTest({ perms: { net: true } }, function listenTLSNoReadPerm() { Deno.listenTls({ hostname: "localhost", port: 3500, - certFile: "cli/tests/tls/localhost.crt", - keyFile: "cli/tests/tls/localhost.key", + certFile: "cli/tests/testdata/tls/localhost.crt", + keyFile: "cli/tests/testdata/tls/localhost.key", }); }, Deno.errors.PermissionDenied); }); @@ -104,8 +104,8 @@ unitTest( const options = { hostname: "localhost", port: 3500, - certFile: "cli/tests/tls/localhost.crt", - keyFile: "cli/tests/tls/localhost.key", + certFile: "cli/tests/testdata/tls/localhost.crt", + keyFile: "cli/tests/testdata/tls/localhost.key", }; const testDir = Deno.makeTempDirSync(); @@ -129,8 +129,8 @@ unitTest( const options = { hostname: "localhost", port: 3500, - certFile: "cli/tests/tls/localhost.crt", - keyFile: "cli/tests/tls/localhost.key", + certFile: "cli/tests/testdata/tls/localhost.crt", + keyFile: "cli/tests/testdata/tls/localhost.key", }; const testDir = Deno.makeTempDirSync(); @@ -158,8 +158,8 @@ unitTest( const listener = Deno.listenTls({ hostname, port, - certFile: "cli/tests/tls/localhost.crt", - keyFile: "cli/tests/tls/localhost.key", + certFile: "cli/tests/testdata/tls/localhost.crt", + keyFile: "cli/tests/testdata/tls/localhost.key", }); const response = encoder.encode( @@ -182,7 +182,7 @@ unitTest( const conn = await Deno.connectTls({ hostname, port, - certFile: "cli/tests/tls/RootCA.pem", + certFile: "cli/tests/testdata/tls/RootCA.pem", }); assert(conn.rid > 0); const w = new BufWriter(conn); @@ -222,15 +222,15 @@ async function tlsPair(): Promise<[Deno.Conn, Deno.Conn]> { const listener = Deno.listenTls({ hostname: "localhost", port, - certFile: "cli/tests/tls/localhost.crt", - keyFile: "cli/tests/tls/localhost.key", + certFile: "cli/tests/testdata/tls/localhost.crt", + keyFile: "cli/tests/testdata/tls/localhost.key", }); const acceptPromise = listener.accept(); const connectPromise = Deno.connectTls({ hostname: "localhost", port, - certFile: "cli/tests/tls/RootCA.pem", + certFile: "cli/tests/testdata/tls/RootCA.pem", }); const endpoints = await Promise.all([acceptPromise, connectPromise]); @@ -553,8 +553,8 @@ async function tlsWithTcpFailureTestImpl( const tlsListener = Deno.listenTls({ hostname: "localhost", port: tlsPort, - certFile: "cli/tests/tls/localhost.crt", - keyFile: "cli/tests/tls/localhost.key", + certFile: "cli/tests/testdata/tls/localhost.crt", + keyFile: "cli/tests/testdata/tls/localhost.key", }); const tcpPort = getPort(); @@ -570,7 +570,7 @@ async function tlsWithTcpFailureTestImpl( Deno.connectTls({ hostname: "localhost", port: tcpPort, - certFile: "cli/tests/tls/RootCA.crt", + certFile: "cli/tests/testdata/tls/RootCA.crt", }), ]); @@ -845,8 +845,8 @@ function createHttpsListener(port: number): Deno.Listener { const listener = Deno.listenTls({ hostname: "localhost", port, - certFile: "./cli/tests/tls/localhost.crt", - keyFile: "./cli/tests/tls/localhost.key", + certFile: "./cli/tests/testdata/tls/localhost.crt", + keyFile: "./cli/tests/testdata/tls/localhost.key", }); serve(listener); @@ -995,7 +995,9 @@ unitTest( hostname: "deno.land", port: 443, certChain: "bad data", - privateKey: await Deno.readTextFile("cli/tests/tls/localhost.key"), + privateKey: await Deno.readTextFile( + "cli/tests/testdata/tls/localhost.key", + ), }); }, Deno.errors.InvalidData); }, @@ -1008,7 +1010,9 @@ unitTest( await Deno.connectTls({ hostname: "deno.land", port: 443, - certChain: await Deno.readTextFile("cli/tests/tls/localhost.crt"), + certChain: await Deno.readTextFile( + "cli/tests/testdata/tls/localhost.crt", + ), privateKey: "bad data", }); }, Deno.errors.InvalidData); @@ -1022,7 +1026,9 @@ unitTest( await Deno.connectTls({ hostname: "deno.land", port: 443, - certChain: await Deno.readTextFile("cli/tests/tls/localhost.crt"), + certChain: await Deno.readTextFile( + "cli/tests/testdata/tls/localhost.crt", + ), privateKey: "", }); }, Deno.errors.InvalidData); @@ -1034,15 +1040,19 @@ unitTest( async function connectWithClientCert() { // The test_server running on port 4552 responds with 'PASS' if client // authentication was successful. Try it by running test_server and - // curl --key cli/tests/tls/localhost.key \ - // --cert cli/tests/tls/localhost.crt \ - // --cacert cli/tests/tls/RootCA.crt https://localhost:4552/ + // curl --key cli/tests/testdata/tls/localhost.key \ + // --cert cli/tests/testdata/tls/localhost.crt \ + // --cacert cli/tests/testdata/tls/RootCA.crt https://localhost:4552/ const conn = await Deno.connectTls({ hostname: "localhost", port: 4552, - certChain: await Deno.readTextFile("cli/tests/tls/localhost.crt"), - privateKey: await Deno.readTextFile("cli/tests/tls/localhost.key"), - certFile: "cli/tests/tls/RootCA.crt", + certChain: await Deno.readTextFile( + "cli/tests/testdata/tls/localhost.crt", + ), + privateKey: await Deno.readTextFile( + "cli/tests/testdata/tls/localhost.key", + ), + certFile: "cli/tests/testdata/tls/RootCA.crt", }); const result = decoder.decode(await readAll(conn)); assertEquals(result, "PASS"); |