Files
outline/server/routes/api/index.test.ts
T
Tom Moor c9d8306de6 fix: Add WWW-Authenticate header to API 401 responses (#14321)
* fix: Add WWW-Authenticate header to API 401 responses

* fix: Keep a challenge set on the response
2026-10-24 18:29:39 -04:00

33 lines
904 B
TypeScript

import { getTestServer } from "@server/test/support";
const server = getTestServer();
describe("POST unknown endpoint", () => {
it("should be not found", async () => {
const res = await server.post("/api/blah");
expect(res.status).toEqual(404);
});
});
describe("GET unknown endpoint", () => {
it("should be not found", async () => {
const res = await server.get("/api/blah");
expect(res.status).toEqual(404);
});
});
describe("PATCH unknown endpoint", () => {
it("should be method not allowed", async () => {
const res = await server.patch("/api/blah");
expect(res.status).toEqual(405);
});
});
describe("unauthenticated request", () => {
it("should include a Bearer challenge", async () => {
const res = await server.post("/api/auth.info");
expect(res.status).toEqual(401);
expect(res.headers.get("www-authenticate")).toEqual("Bearer");
});
});