mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 01:30:43 +00:00
56 lines
1.6 KiB
TypeScript
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 "*"',
|
|
}),
|
|
]);
|
|
});
|
|
});
|