diff options
author | 2023-09-07 02:23:24 -0300 | |
---|---|---|
committer | 2023-09-06 22:23:24 -0700 | |
commit | 4360ec83b4146e15344b304573795f084f86a7c2 (patch) | |
tree | d2df0876f7885b856632d5bdcee06835c63787fe /test/js/node | |
parent | 3b9829f17134a21790f1524f3391409f385dfee9 (diff) | |
download | bun-4360ec83b4146e15344b304573795f084f86a7c2.tar.gz bun-4360ec83b4146e15344b304573795f084f86a7c2.tar.zst bun-4360ec83b4146e15344b304573795f084f86a7c2.zip |
feat(fetch) rejectUnauthorized and checkServerIdentity (#4514)
* enable root certs on fetch
* rebase
* fix lookup
* some fixes and improvements
* fmt
* more fixes
* more fixes
* check detached onHandshake
* fix promise case
* fix cert non-Native
* add fetch tls tests
* more one test
Diffstat (limited to 'test/js/node')
-rw-r--r-- | test/js/node/http/node-http.test.ts | 30 | ||||
-rw-r--r-- | test/js/node/tls/node-tls-connect.test.ts | 2 |
2 files changed, 20 insertions, 12 deletions
diff --git a/test/js/node/http/node-http.test.ts b/test/js/node/http/node-http.test.ts index 619718fee..d28676a19 100644 --- a/test/js/node/http/node-http.test.ts +++ b/test/js/node/http/node-http.test.ts @@ -807,6 +807,8 @@ describe("node:http", () => { done(); } catch (error) { done(error); + } finally { + server.close(); } }); }); @@ -823,20 +825,12 @@ describe("node:http", () => { }); } catch (err) { done(err); + } finally { + server.close(); } }); }); - test("should not decompress gzip, issue#4397", async () => { - const { promise, resolve } = Promise.withResolvers(); - request("https://bun.sh/", { headers: { "accept-encoding": "gzip" } }, res => { - res.on("data", function cb(chunk) { - resolve(chunk); - res.off("data", cb); - }); - }).end(); - const chunk = await promise; - expect(chunk.toString()).not.toContain("<html"); - }); + test("test unix socket server", done => { const socketPath = `${tmpdir()}/bun-server-${Math.random().toString(32)}.sock`; const server = createServer((req, res) => { @@ -850,6 +844,18 @@ describe("node:http", () => { res.end(); }); + test("should not decompress gzip, issue#4397", async () => { + const { promise, resolve } = Promise.withResolvers(); + request("https://bun.sh/", { headers: { "accept-encoding": "gzip" } }, res => { + res.on("data", function cb(chunk) { + resolve(chunk); + res.off("data", cb); + }); + }).end(); + const chunk = await promise; + expect(chunk.toString()).not.toContain("<html"); + }); + server.listen(socketPath, () => { // TODO: unix socket is not implemented in fetch. const output = spawnSync("curl", ["--unix-socket", socketPath, "http://localhost/bun?a=1"]); @@ -858,6 +864,8 @@ describe("node:http", () => { done(); } catch (err) { done(err); + } finally { + server.close(); } }); }); diff --git a/test/js/node/tls/node-tls-connect.test.ts b/test/js/node/tls/node-tls-connect.test.ts index 8bc2dcb7a..3bcf49db0 100644 --- a/test/js/node/tls/node-tls-connect.test.ts +++ b/test/js/node/tls/node-tls-connect.test.ts @@ -50,7 +50,7 @@ it("Bun.serve() should work with tls and Bun.file()", async () => { key: COMMON_CERT.key, }, }); - const res = await fetch(`https://${server.hostname}:${server.port}/`); + const res = await fetch(`https://${server.hostname}:${server.port}/`, { tls: { rejectUnauthorized: false } }); expect(await res.text()).toBe("<h1>HELLO</h1>"); server.stop(); }); |