Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 60233d0

Browse files
committed
test/proxy.test.ts: Implement
1 parent 240c8e2 commit 60233d0

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

‎test/proxy.test.ts‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import * as integration from "./integration"
2+
import * as httpserver from "./httpserver"
3+
import * as express from "express"
4+
import * as assert from "assert"
5+
6+
describe("proxy", () => {
7+
let codeServer: httpserver.HttpServer | undefined
8+
let nhooyrDevServer = new httpserver.HttpServer()
9+
let proxyPath: string
10+
11+
before(async () => {
12+
const e = express.default()
13+
await nhooyrDevServer.listen(e)
14+
e.get("/wsup", (req, res) => {
15+
res.json("asher is the best")
16+
})
17+
proxyPath = `/proxy/${nhooyrDevServer.port()}/wsup`
18+
e.get(proxyPath, (req, res) => {
19+
res.json("joe is the best")
20+
})
21+
})
22+
23+
after(async () => {
24+
await nhooyrDevServer.close()
25+
})
26+
27+
afterEach(async () => {
28+
if (codeServer) {
29+
await codeServer.close()
30+
codeServer = undefined
31+
}
32+
})
33+
34+
it("should rewrite the base path", async () => {
35+
;[,, codeServer,] = await integration.setup(["--auth=none"], "")
36+
const resp = await codeServer.fetch(proxyPath)
37+
assert.equal(resp.status, 200)
38+
assert.equal(await resp.json(), "asher is the best")
39+
})
40+
41+
it("should not rewrite the base path", async () => {
42+
;[,,codeServer,] = await integration.setup(["--auth=none", "--proxy-path-passthrough=true"], "")
43+
const resp = await codeServer.fetch(proxyPath)
44+
assert.equal(resp.status, 200)
45+
assert.equal(await resp.json(), "joe is the best")
46+
})
47+
})

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /