mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 09:40:43 +00:00
test(extensions): move config regression coverage
This commit is contained in:
43
extensions/imessage/src/config-schema.test.ts
Normal file
43
extensions/imessage/src/config-schema.test.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { IMessageConfigSchema } from "../config-api.js";
|
||||
|
||||
describe("imessage config schema", () => {
|
||||
it("accepts safe remoteHost", () => {
|
||||
const res = IMessageConfigSchema.safeParse({
|
||||
remoteHost: "bot@gateway-host",
|
||||
});
|
||||
|
||||
expect(res.success).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects unsafe remoteHost", () => {
|
||||
const res = IMessageConfigSchema.safeParse({
|
||||
remoteHost: "bot@gateway-host -oProxyCommand=whoami",
|
||||
});
|
||||
|
||||
expect(res.success).toBe(false);
|
||||
if (!res.success) {
|
||||
expect(res.error.issues[0]?.path.join(".")).toBe("remoteHost");
|
||||
}
|
||||
});
|
||||
|
||||
it("accepts attachment root patterns", () => {
|
||||
const res = IMessageConfigSchema.safeParse({
|
||||
attachmentRoots: ["/Users/*/Library/Messages/Attachments"],
|
||||
remoteAttachmentRoots: ["/Volumes/relay/attachments"],
|
||||
});
|
||||
|
||||
expect(res.success).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects relative attachment roots", () => {
|
||||
const res = IMessageConfigSchema.safeParse({
|
||||
attachmentRoots: ["./attachments"],
|
||||
});
|
||||
|
||||
expect(res.success).toBe(false);
|
||||
if (!res.success) {
|
||||
expect(res.error.issues[0]?.path.join(".")).toBe("attachmentRoots.0");
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user