diff options
Diffstat (limited to 'cli/tests/unit/tls_test.ts')
-rw-r--r-- | cli/tests/unit/tls_test.ts | 123 |
1 files changed, 64 insertions, 59 deletions
diff --git a/cli/tests/unit/tls_test.ts b/cli/tests/unit/tls_test.ts index fb8888be4..4062ef504 100644 --- a/cli/tests/unit/tls_test.ts +++ b/cli/tests/unit/tls_test.ts @@ -8,7 +8,6 @@ import { assertThrows, Deferred, deferred, - unitTest, } from "./test_util.ts"; import { BufReader, BufWriter } from "../../../test_util/std/io/bufio.ts"; import { readAll } from "../../../test_util/std/io/util.ts"; @@ -25,13 +24,13 @@ function unreachable(): never { throw new Error("Unreachable code reached"); } -unitTest(async function connectTLSNoPerm() { +Deno.test({ permissions: { net: false } }, async function connectTLSNoPerm() { await assertRejects(async () => { await Deno.connectTls({ hostname: "deno.land", port: 443 }); }, Deno.errors.PermissionDenied); }); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function connectTLSInvalidHost() { const listener = await Deno.listenTls({ @@ -49,17 +48,20 @@ unitTest( }, ); -unitTest(async function connectTLSCertFileNoReadPerm() { - await assertRejects(async () => { - await Deno.connectTls({ - hostname: "deno.land", - port: 443, - certFile: "cli/tests/testdata/tls/RootCA.crt", - }); - }, Deno.errors.PermissionDenied); -}); +Deno.test( + { permissions: { net: true, read: false } }, + async function connectTLSCertFileNoReadPerm() { + await assertRejects(async () => { + await Deno.connectTls({ + hostname: "deno.land", + port: 443, + certFile: "cli/tests/testdata/tls/RootCA.crt", + }); + }, Deno.errors.PermissionDenied); + }, +); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, function listenTLSNonExistentCertKeyFiles() { const options = { @@ -85,18 +87,21 @@ unitTest( }, ); -unitTest({ permissions: { net: true } }, function listenTLSNoReadPerm() { - assertThrows(() => { - Deno.listenTls({ - hostname: "localhost", - port: 3500, - certFile: "cli/tests/testdata/tls/localhost.crt", - keyFile: "cli/tests/testdata/tls/localhost.key", - }); - }, Deno.errors.PermissionDenied); -}); +Deno.test( + { permissions: { net: true, read: false } }, + function listenTLSNoReadPerm() { + assertThrows(() => { + Deno.listenTls({ + hostname: "localhost", + port: 3500, + certFile: "cli/tests/testdata/tls/localhost.crt", + keyFile: "cli/tests/testdata/tls/localhost.key", + }); + }, Deno.errors.PermissionDenied); + }, +); -unitTest( +Deno.test( { permissions: { read: true, write: true, net: true }, }, @@ -123,7 +128,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, write: true, net: true } }, function listenTLSEmptyCertFile() { const options = { @@ -148,7 +153,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function dialAndListenTLS() { const resolvable = deferred(); @@ -300,7 +305,7 @@ async function receiveThenSend( conn.close(); } -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsServerStreamHalfCloseSendOneByte() { const [serverConn, clientConn] = await tlsPair(); @@ -311,7 +316,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsClientStreamHalfCloseSendOneByte() { const [serverConn, clientConn] = await tlsPair(); @@ -322,7 +327,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsServerStreamHalfCloseSendOneChunk() { const [serverConn, clientConn] = await tlsPair(); @@ -333,7 +338,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsClientStreamHalfCloseSendOneChunk() { const [serverConn, clientConn] = await tlsPair(); @@ -344,7 +349,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsServerStreamHalfCloseSendManyBytes() { const [serverConn, clientConn] = await tlsPair(); @@ -355,7 +360,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsClientStreamHalfCloseSendManyBytes() { const [serverConn, clientConn] = await tlsPair(); @@ -366,7 +371,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsServerStreamHalfCloseSendManyChunks() { const [serverConn, clientConn] = await tlsPair(); @@ -377,7 +382,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsClientStreamHalfCloseSendManyChunks() { const [serverConn, clientConn] = await tlsPair(); @@ -427,7 +432,7 @@ async function receiveAlotSendNothing(conn: Deno.Conn) { conn.close(); } -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsServerStreamCancelRead() { const [serverConn, clientConn] = await tlsPair(); @@ -438,7 +443,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsClientStreamCancelRead() { const [serverConn, clientConn] = await tlsPair(); @@ -484,7 +489,7 @@ async function sendReceiveEmptyBuf(conn: Deno.Conn) { conn.close(); } -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsStreamSendReceiveEmptyBuf() { const [serverConn, clientConn] = await tlsPair(); @@ -510,7 +515,7 @@ async function closeWriteAndClose(conn: Deno.Conn) { conn.close(); } -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsServerStreamImmediateClose() { const [serverConn, clientConn] = await tlsPair(); @@ -521,7 +526,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsClientStreamImmediateClose() { const [serverConn, clientConn] = await tlsPair(); @@ -532,7 +537,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsClientAndServerStreamImmediateClose() { const [serverConn, clientConn] = await tlsPair(); @@ -775,7 +780,7 @@ async function tlsWithTcpFailureTestImpl( } } -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsHandshakeWithTcpCorruptionImmediately() { await tlsWithTcpFailureTestImpl("handshake", 0, "corruption", false); @@ -783,7 +788,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsHandshakeWithTcpShutdownImmediately() { await tlsWithTcpFailureTestImpl("handshake", 0, "shutdown", false); @@ -791,7 +796,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsHandshakeWithTcpCorruptionAfter70Bytes() { await tlsWithTcpFailureTestImpl("handshake", 76, "corruption", false); @@ -799,7 +804,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsHandshakeWithTcpShutdownAfter70bytes() { await tlsWithTcpFailureTestImpl("handshake", 77, "shutdown", false); @@ -807,7 +812,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsHandshakeWithTcpCorruptionAfter200Bytes() { await tlsWithTcpFailureTestImpl("handshake", 200, "corruption", false); @@ -815,7 +820,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsHandshakeWithTcpShutdownAfter200bytes() { await tlsWithTcpFailureTestImpl("handshake", 201, "shutdown", false); @@ -823,7 +828,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsTrafficWithTcpCorruption() { await tlsWithTcpFailureTestImpl("traffic", Infinity, "corruption", false); @@ -831,7 +836,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsTrafficWithTcpShutdown() { await tlsWithTcpFailureTestImpl("traffic", Infinity, "shutdown", false); @@ -912,7 +917,7 @@ async function curl(url: string): Promise<string> { } } -unitTest( +Deno.test( { permissions: { read: true, net: true, run: true } }, async function curlFakeHttpsServer() { const port = getPort(); @@ -936,7 +941,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function startTls() { const hostname = "smtp.gmail.com"; @@ -987,7 +992,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function connectTLSBadClientCertPrivateKey(): Promise<void> { await assertRejects(async () => { @@ -1003,7 +1008,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function connectTLSBadPrivateKey(): Promise<void> { await assertRejects(async () => { @@ -1019,7 +1024,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function connectTLSNotPrivateKey(): Promise<void> { await assertRejects(async () => { @@ -1035,7 +1040,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function connectWithClientCert() { // The test_server running on port 4552 responds with 'PASS' if client @@ -1060,7 +1065,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function connectTLSCaCerts() { const conn = await Deno.connectTls({ @@ -1074,7 +1079,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function connectTLSCertFile() { const conn = await Deno.connectTls({ @@ -1088,7 +1093,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function startTLSCaCerts() { const plainConn = await Deno.connect({ @@ -1105,7 +1110,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsHandshakeSuccess() { const hostname = "localhost"; @@ -1174,7 +1179,7 @@ unitTest( }, ); -unitTest( +Deno.test( { permissions: { read: true, net: true } }, async function tlsHandshakeFailure() { const hostname = "localhost"; |