|
| 1 | +import * as httpserver from "../../utils/httpserver" |
| 2 | +import * as integration from "../../utils/integration" |
| 3 | + |
1 | 4 | import { RateLimiter } from "../../../src/node/routes/login"
|
2 | 5 |
|
3 | 6 | describe("login", () => {
|
@@ -34,4 +37,43 @@ describe("login", () => {
|
34 | 37 | expect(limiter.removeToken()).toBe(false)
|
35 | 38 | })
|
36 | 39 | })
|
| 40 | + describe.only("/", () => { |
| 41 | + let _codeServer: httpserver.HttpServer | undefined |
| 42 | + function codeServer(): httpserver.HttpServer { |
| 43 | + if (!_codeServer) { |
| 44 | + throw new Error("tried to use code-server before setting it up") |
| 45 | + } |
| 46 | + return _codeServer |
| 47 | + } |
| 48 | + |
| 49 | + // Store whatever might be in here so we can restore it afterward. |
| 50 | + // TODO: We should probably pass this as an argument somehow instead of |
| 51 | + // manipulating the environment. |
| 52 | + const previousEnvPassword = process.env.PASSWORD |
| 53 | + |
| 54 | + beforeEach(async () => { |
| 55 | + process.env.PASSWORD = "test" |
| 56 | + _codeServer = await integration.setup(["--auth=password"], "") |
| 57 | + }) |
| 58 | + |
| 59 | + afterEach(() => { |
| 60 | + process.env.PASSWORD = previousEnvPassword |
| 61 | + }) |
| 62 | + |
| 63 | + // TODO@jsjoeio fix this name of test |
| 64 | + it("should return an error", async () => { |
| 65 | + const resp = await codeServer().fetch("/", { method: "POST" }) |
| 66 | + // TODO@jsjoeio um not sure why we are getting a 404 |
| 67 | + expect(resp.status).toBe(404) |
| 68 | + |
| 69 | + try { |
| 70 | + const content = JSON.parse(await resp.text()) |
| 71 | + |
| 72 | + expect(content.error).toMatch("ENOENT") |
| 73 | + } catch (error) { |
| 74 | + console.log("heree") |
| 75 | + console.error(error) |
| 76 | + } |
| 77 | + }) |
| 78 | + }) |
37 | 79 | })
|
0 commit comments