mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 03:03:24 -04:00
test: remove overlapping line webhook/account cases
This commit is contained in:
@@ -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");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user