diff options
author | 2023-03-07 12:22:34 -0800 | |
---|---|---|
committer | 2023-03-07 12:22:34 -0800 | |
commit | f7e4eb83694aa007a492ef66c28ffbe6a2dae791 (patch) | |
tree | 7af25aa5c42a2e1b2b47ba1df35f8caa9054cbeb /test/bun.js/proxy.test.js | |
parent | 36275a44ce7a33587bd26aad120042ab95470ff3 (diff) | |
download | bun-f7e4eb83694aa007a492ef66c28ffbe6a2dae791.tar.gz bun-f7e4eb83694aa007a492ef66c28ffbe6a2dae791.tar.zst bun-f7e4eb83694aa007a492ef66c28ffbe6a2dae791.zip |
Reorganize tests (#2332)
Diffstat (limited to 'test/bun.js/proxy.test.js')
-rw-r--r-- | test/bun.js/proxy.test.js | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/test/bun.js/proxy.test.js b/test/bun.js/proxy.test.js deleted file mode 100644 index c903efab3..000000000 --- a/test/bun.js/proxy.test.js +++ /dev/null @@ -1,69 +0,0 @@ -import { afterAll, beforeAll, describe, expect, it } from "bun:test"; -import { gc } from "./gc"; - -let proxy, server; - -// TODO: Proxy with TLS requests - -beforeAll(() => { - proxy = Bun.serve({ - async fetch(request) { - // if is not an proxy connection just drop it - if (!request.headers.has("proxy-connection")) { - return new Response("Bad Request", { status: 400 }); - } - - // simple http proxy - if (request.url.startsWith("http://")) { - return await fetch(request.url, { - method: request.method, - body: await request.text(), - }); - } - - // no TLS support here - return new Response("Bad Request", { status: 400 }); - }, - port: 54312, - }); - server = Bun.serve({ - async fetch(request) { - if (request.method === "POST") { - const text = await request.text(); - return new Response(text, { status: 200 }); - } - return new Response("Hello, World", { status: 200 }); - }, - port: 54322, - }); -}); - -afterAll(() => { - server.stop(); - proxy.stop(); -}); - -describe("proxy", () => { - const requests = [ - [new Request("http://localhost:54322"), "fetch() GET with non-TLS Proxy", "http://localhost:54312"], - [ - new Request("http://localhost:54322", { - method: "POST", - body: "Hello, World", - }), - "fetch() POST with non-TLS Proxy", - "http://localhost:54312", - ], - ]; - for (let [request, name, proxy] of requests) { - gc(); - it(name, async () => { - gc(); - const response = await fetch(request, { verbose: true, proxy }); - gc(); - const text = await response.text(); - gc(); - expect(text).toBe("Hello, World"); - }); - } -}); |