2023-09-12 01:26:59 +08:00
|
|
|
import { mockLogger } from "../../../utils/helpers"
|
2023-03-03 17:12:34 +08:00
|
|
|
import * as httpserver from "../../../utils/httpserver"
|
|
|
|
import * as integration from "../../../utils/integration"
|
|
|
|
|
|
|
|
describe("vscode", () => {
|
|
|
|
let codeServer: httpserver.HttpServer | undefined
|
|
|
|
beforeEach(() => {
|
|
|
|
mockLogger()
|
|
|
|
})
|
|
|
|
|
|
|
|
afterEach(async () => {
|
|
|
|
if (codeServer) {
|
|
|
|
await codeServer.dispose()
|
|
|
|
codeServer = undefined
|
|
|
|
}
|
|
|
|
jest.clearAllMocks()
|
|
|
|
})
|
|
|
|
|
|
|
|
it("should fail origin check", async () => {
|
|
|
|
await expect(async () => {
|
|
|
|
codeServer = await integration.setup(["--auth=none"], "")
|
|
|
|
await codeServer.wsWait("/vscode", {
|
|
|
|
headers: {
|
|
|
|
host: "localhost:8080",
|
|
|
|
origin: "https://evil.org",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}).rejects.toThrow()
|
|
|
|
})
|
|
|
|
})
|