summaryrefslogtreecommitdiff
path: root/cli/js/tls_test.ts
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-10-04 20:28:51 -0400
committerGitHub <noreply@github.com>2019-10-04 20:28:51 -0400
commitb81e5db17aa8b3088d6034ddf86b79c69410f012 (patch)
tree579e4c23d60d1b0d038156bc28a04f74ea87b2f0 /cli/js/tls_test.ts
parent9049213867d30f7df090a83b6baf3e0717a4d2d2 (diff)
Merge deno_cli_snapshots into deno_cli (#3064)
Diffstat (limited to 'cli/js/tls_test.ts')
-rw-r--r--cli/js/tls_test.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/cli/js/tls_test.ts b/cli/js/tls_test.ts
new file mode 100644
index 000000000..25900f876
--- /dev/null
+++ b/cli/js/tls_test.ts
@@ -0,0 +1,25 @@
+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
+import { test, testPerm, assert, assertEquals } from "./test_util.ts";
+
+// TODO(ry) The tests in this file use github.com:443, but it would be better to
+// not rely on an internet connection and rather use a localhost TLS server.
+
+test(async function dialTLSNoPerm(): Promise<void> {
+ let err;
+ try {
+ await Deno.dialTLS({ hostname: "github.com", port: 443 });
+ } catch (e) {
+ err = e;
+ }
+ assertEquals(err.kind, Deno.ErrorKind.PermissionDenied);
+ assertEquals(err.name, "PermissionDenied");
+});
+
+testPerm({ net: true }, async function dialTLSBasic(): Promise<void> {
+ const conn = await Deno.dialTLS({ hostname: "github.com", port: 443 });
+ assert(conn.rid > 0);
+ const body = new TextEncoder().encode("GET / HTTP/1.0\r\n\r\n");
+ const writeResult = await conn.write(body);
+ assertEquals(body.length, writeResult);
+ conn.close();
+});