| import { describe, expect, it, vi } from "vitest"; | |
| import { startWebhookServer } from "./monitor.test-harness.js"; | |
| describe("createNextcloudTalkWebhookServer auth order", () => { | |
| it("rejects missing signature headers before reading request body", async () => { | |
| const readBody = vi.fn(async () => { | |
| throw new Error("should not be called for missing signature headers"); | |
| }); | |
| const harness = await startWebhookServer({ | |
| path: "/nextcloud-auth-order", | |
| maxBodyBytes: 128, | |
| readBody, | |
| onMessage: vi.fn(), | |
| }); | |
| const response = await fetch(harness.webhookUrl, { | |
| method: "POST", | |
| headers: { | |
| "content-type": "application/json", | |
| }, | |
| body: "{}", | |
| }); | |
| expect(response.status).toBe(400); | |
| expect(await response.json()).toEqual({ error: "Missing signature headers" }); | |
| expect(readBody).not.toHaveBeenCalled(); | |
| }); | |
| }); | |