test: remove overlapping line webhook/account cases

This commit is contained in:
Peter Steinberger
2026-02-16 07:22:30 +00:00
parent 12d6b3b0c9
commit 077130bdb8
2 changed files with 4 additions and 32 deletions

View File

@@ -176,24 +176,17 @@ describe("LINE accounts", () => {
});
describe("normalizeAccountId", () => {
it("normalizes undefined to default", () => {
it("normalizes undefined and literal default", () => {
expect(normalizeAccountId(undefined)).toBe(DEFAULT_ACCOUNT_ID);
});
it("normalizes 'default' to DEFAULT_ACCOUNT_ID", () => {
expect(normalizeAccountId("default")).toBe(DEFAULT_ACCOUNT_ID);
});
it("preserves other account ids", () => {
it("preserves non-default account ids", () => {
expect(normalizeAccountId("business")).toBe("business");
});
it("lowercases account ids", () => {
expect(normalizeAccountId("Business")).toBe("business");
});
it("trims whitespace", () => {
expect(normalizeAccountId(" business ")).toBe("business");
it("trims and lowercases account ids", () => {
expect(normalizeAccountId(" Business ")).toBe("business");
});
});
});

View File

@@ -139,25 +139,4 @@ describe("createLineWebhookMiddleware", () => {
expect(res.json).toHaveBeenCalledWith({ error: "Missing X-Line-Signature header" });
expect(onEvents).not.toHaveBeenCalled();
});
it("rejects webhooks with signatures computed using wrong secret", async () => {
const onEvents = vi.fn(async () => {});
const correctSecret = "correct-secret";
const wrongSecret = "wrong-secret";
const rawBody = JSON.stringify({ events: [{ type: "message" }] });
const middleware = createLineWebhookMiddleware({ channelSecret: correctSecret, onEvents });
const req = {
headers: { "x-line-signature": sign(rawBody, wrongSecret) },
body: rawBody,
// oxlint-disable-next-line typescript/no-explicit-any
} as any;
const res = createRes();
// oxlint-disable-next-line typescript/no-explicit-any
await middleware(req, res, {} as any);
expect(res.status).toHaveBeenCalledWith(401);
expect(onEvents).not.toHaveBeenCalled();
});
});