summaryrefslogtreecommitdiff
path: root/cli/tests/unit/fetch_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/unit/fetch_test.ts')
-rw-r--r--cli/tests/unit/fetch_test.ts36
1 files changed, 36 insertions, 0 deletions
diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts
index a2bd1741b..bc61d67b5 100644
--- a/cli/tests/unit/fetch_test.ts
+++ b/cli/tests/unit/fetch_test.ts
@@ -1324,3 +1324,39 @@ unitTest(
}), TypeError);
},
);
+
+unitTest(
+ { permissions: { net: true, read: true } },
+ async function fetchSupportsHttp1Only() {
+ const caCert = await Deno.readTextFile("cli/tests/testdata/tls/RootCA.pem");
+ const client = Deno.createHttpClient({ caCerts: [caCert] });
+ const res = await fetch("https://localhost:5546/http_version", { client });
+ assert(res.ok);
+ assertEquals(await res.text(), "HTTP/1.1");
+ client.close();
+ },
+);
+
+unitTest(
+ { permissions: { net: true, read: true } },
+ async function fetchSupportsHttp2() {
+ const caCert = await Deno.readTextFile("cli/tests/testdata/tls/RootCA.pem");
+ const client = Deno.createHttpClient({ caCerts: [caCert] });
+ const res = await fetch("https://localhost:5547/http_version", { client });
+ assert(res.ok);
+ assertEquals(await res.text(), "HTTP/2.0");
+ client.close();
+ },
+);
+
+unitTest(
+ { permissions: { net: true, read: true } },
+ async function fetchPrefersHttp2() {
+ const caCert = await Deno.readTextFile("cli/tests/testdata/tls/RootCA.pem");
+ const client = Deno.createHttpClient({ caCerts: [caCert] });
+ const res = await fetch("https://localhost:5545/http_version", { client });
+ assert(res.ok);
+ assertEquals(await res.text(), "HTTP/2.0");
+ client.close();
+ },
+);