mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 20:08:26 +00:00
test(config): enforce allow+alsoAllow mutual exclusion
This commit is contained in:
53
src/config/config.tools-alsoAllow.test.ts
Normal file
53
src/config/config.tools-alsoAllow.test.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { validateConfigObject } from "./validation.js";
|
||||
|
||||
// NOTE: These tests ensure allow + alsoAllow cannot be set in the same scope.
|
||||
|
||||
describe("config: tools.alsoAllow", () => {
|
||||
it("rejects tools.allow + tools.alsoAllow together", () => {
|
||||
const res = validateConfigObject({
|
||||
tools: {
|
||||
allow: ["group:fs"],
|
||||
alsoAllow: ["lobster"],
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.ok).toBe(false);
|
||||
if (!res.ok) {
|
||||
expect(res.issues.some((i) => i.path === "tools")).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects agents.list[].tools.allow + alsoAllow together", () => {
|
||||
const res = validateConfigObject({
|
||||
agents: {
|
||||
list: [
|
||||
{
|
||||
id: "main",
|
||||
tools: {
|
||||
allow: ["group:fs"],
|
||||
alsoAllow: ["lobster"],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.ok).toBe(false);
|
||||
if (!res.ok) {
|
||||
expect(res.issues.some((i) => i.path.includes("agents.list"))).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("allows profile + alsoAllow", () => {
|
||||
const res = validateConfigObject({
|
||||
tools: {
|
||||
profile: "coding",
|
||||
alsoAllow: ["lobster"],
|
||||
},
|
||||
});
|
||||
|
||||
expect(res.ok).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user