mirror of
https://github.com/danog/code-server.git
synced 2024-11-27 04:45:52 +01:00
62b3a6fd9f
* Fix issue where HTTP error status codes are not read. * Fix issues surrounding sessions when accessed from a proxy. - Updated vscode args to match latest upstream. - Fixed issues surrounding trailing slashes affecting base paths. - Updated cookie names to better match upstream's usage, debuggability. * Bump vendor. * Update tests. * Fix issue where tests lack cookie key. Co-authored-by: Asher <ash@coder.com>
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { HttpCode, HttpError } from "../../../src/common/http"
|
|
|
|
describe("http", () => {
|
|
describe("HttpCode", () => {
|
|
it("should return the correct HTTP codes", () => {
|
|
expect(HttpCode.Ok).toBe(200)
|
|
expect(HttpCode.Redirect).toBe(302)
|
|
expect(HttpCode.NotFound).toBe(404)
|
|
expect(HttpCode.BadRequest).toBe(400)
|
|
expect(HttpCode.Unauthorized).toBe(401)
|
|
expect(HttpCode.LargePayload).toBe(413)
|
|
expect(HttpCode.ServerError).toBe(500)
|
|
})
|
|
})
|
|
|
|
describe("HttpError", () => {
|
|
it("should work as expected", () => {
|
|
const message = "Bad request from client"
|
|
const httpError = new HttpError(message, HttpCode.BadRequest)
|
|
|
|
expect(httpError.message).toBe(message)
|
|
expect(httpError.statusCode).toBe(400)
|
|
expect(httpError.details).toBeUndefined()
|
|
})
|
|
it("should have details if provided", () => {
|
|
const details = {
|
|
message: "User needs to be signed-in in order to perform action",
|
|
}
|
|
const message = "Unauthorized"
|
|
const httpError = new HttpError(message, HttpCode.BadRequest, details)
|
|
|
|
expect(httpError.details).toStrictEqual(details)
|
|
})
|
|
})
|
|
})
|