Files
openclaw/extensions/line/src/config-schema.test.ts
2026-05-06 07:49:27 +01:00

56 lines
1.6 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { LineConfigSchema } from "./config-schema.js";
describe("LineConfigSchema", () => {
it('rejects dmPolicy="open" without wildcard allowFrom', () => {
const result = LineConfigSchema.safeParse({
channelAccessToken: "token",
channelSecret: "secret",
dmPolicy: "open",
});
if (result.success) {
throw new Error("Expected config validation to fail");
}
expect(result.error.issues).toEqual([
expect.objectContaining({
path: ["allowFrom"],
message: 'channels.line.dmPolicy="open" requires channels.line.allowFrom to include "*"',
}),
]);
});
it('accepts dmPolicy="open" with wildcard allowFrom', () => {
const result = LineConfigSchema.safeParse({
channelAccessToken: "token",
channelSecret: "secret",
dmPolicy: "open",
allowFrom: ["*"],
});
expect(result.success).toBe(true);
});
it('rejects account dmPolicy="open" without wildcard allowFrom', () => {
const result = LineConfigSchema.safeParse({
accounts: {
work: {
channelAccessToken: "token",
channelSecret: "secret",
dmPolicy: "open",
},
},
});
if (result.success) {
throw new Error("Expected account config validation to fail");
}
expect(result.error.issues).toEqual([
expect.objectContaining({
path: ["accounts", "work", "allowFrom"],
message: 'channels.line.dmPolicy="open" requires channels.line.allowFrom to include "*"',
}),
]);
});
});