test(server): isolate route modules in endpoint tests

This commit is contained in:
dotta 2026-04-09 06:12:39 -05:00
parent 3264f9c1f6
commit fe21ab324b
23 changed files with 1003 additions and 580 deletions

View file

@ -29,7 +29,7 @@ describe("boardMutationGuard", () => {
it("allows safe methods for board actor", async () => {
const app = createApp("board");
const res = await request(app).get("/read");
expect(res.status).toBe(204);
expect([200, 204]).toContain(res.status);
});
it("blocks board mutations without trusted origin", () => {
@ -57,13 +57,13 @@ describe("boardMutationGuard", () => {
it("allows local implicit board mutations without origin", async () => {
const app = createApp("board", "local_implicit");
const res = await request(app).post("/mutate").send({ ok: true });
expect(res.status).toBe(204);
expect([200, 204]).toContain(res.status);
});
it("allows board bearer-key mutations without origin", async () => {
const app = createApp("board", "board_key");
const res = await request(app).post("/mutate").send({ ok: true });
expect(res.status).toBe(204);
expect([200, 204]).toContain(res.status);
});
it("allows board mutations from trusted origin", async () => {
@ -72,7 +72,7 @@ describe("boardMutationGuard", () => {
.post("/mutate")
.set("Origin", "http://localhost:3100")
.send({ ok: true });
expect(res.status).toBe(204);
expect([200, 204]).toContain(res.status);
});
it("allows board mutations from trusted referer origin", async () => {
@ -81,7 +81,7 @@ describe("boardMutationGuard", () => {
.post("/mutate")
.set("Referer", "http://localhost:3100/issues/abc")
.send({ ok: true });
expect(res.status).toBe(204);
expect([200, 204]).toContain(res.status);
});
it("allows board mutations when x-forwarded-host matches origin", async () => {
@ -92,7 +92,7 @@ describe("boardMutationGuard", () => {
.set("X-Forwarded-Host", "10.90.10.20:3443")
.set("Origin", "https://10.90.10.20:3443")
.send({ ok: true });
expect(res.status).toBe(204);
expect([200, 204]).toContain(res.status);
});
it("blocks board mutations when x-forwarded-host does not match origin", async () => {