mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 15:24:46 +00:00
test: tighten sandbox policy assertions
This commit is contained in:
@@ -14,7 +14,7 @@ describe("sanitizeEnvVars", () => {
|
||||
NODE_ENV: "test",
|
||||
FOO: "bar",
|
||||
});
|
||||
expect(result.blocked).toEqual(expect.arrayContaining(["OPENAI_API_KEY", "GITHUB_TOKEN"]));
|
||||
expect(result.blocked).toStrictEqual(["OPENAI_API_KEY", "GITHUB_TOKEN"]);
|
||||
});
|
||||
|
||||
it("blocks credentials even when suffix pattern matches", () => {
|
||||
@@ -25,7 +25,7 @@ describe("sanitizeEnvVars", () => {
|
||||
});
|
||||
|
||||
expect(result.allowed).toEqual({ USER: "alice" });
|
||||
expect(result.blocked).toEqual(expect.arrayContaining(["MY_TOKEN", "MY_SECRET"]));
|
||||
expect(result.blocked).toStrictEqual(["MY_TOKEN", "MY_SECRET"]);
|
||||
});
|
||||
|
||||
it("adds warnings for suspicious values", () => {
|
||||
|
||||
@@ -137,14 +137,18 @@ describe("sandbox/tool-policy", () => {
|
||||
};
|
||||
|
||||
const sandbox = resolveSandboxConfigForAgent(cfg, "tavern");
|
||||
expect(sandbox.tools.allow).toEqual(expect.arrayContaining(["browser", "message", "tts"]));
|
||||
expect(sandbox.tools.allow).toContain("browser");
|
||||
expect(sandbox.tools.allow).toContain("message");
|
||||
expect(sandbox.tools.allow).toContain("tts");
|
||||
expect(sandbox.tools.deny).not.toContain("browser");
|
||||
|
||||
const runtime = resolveSandboxRuntimeStatus({
|
||||
cfg,
|
||||
sessionKey: "agent:tavern:main",
|
||||
});
|
||||
expect(runtime.toolPolicy.allow).toEqual(expect.arrayContaining(["browser", "message", "tts"]));
|
||||
expect(runtime.toolPolicy.allow).toContain("browser");
|
||||
expect(runtime.toolPolicy.allow).toContain("message");
|
||||
expect(runtime.toolPolicy.allow).toContain("tts");
|
||||
expect(runtime.toolPolicy.deny).not.toContain("browser");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user