mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-01 14:10:24 +00:00
fix: align exec default reporting with runtime
This commit is contained in:
@@ -1,8 +1,17 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { SessionEntry } from "../config/sessions.js";
|
||||
import * as execApprovals from "../infra/exec-approvals.js";
|
||||
import { resolveExecDefaults } from "./exec-defaults.js";
|
||||
|
||||
describe("resolveExecDefaults", () => {
|
||||
beforeEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
vi.spyOn(execApprovals, "loadExecApprovals").mockReturnValue({
|
||||
version: 1,
|
||||
agents: {},
|
||||
});
|
||||
});
|
||||
|
||||
it("does not advertise node routing when exec host is pinned to gateway", () => {
|
||||
expect(
|
||||
resolveExecDefaults({
|
||||
@@ -55,4 +64,44 @@ describe("resolveExecDefaults", () => {
|
||||
}).canRequestNode,
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("uses host approval defaults for gateway when exec policy is unset", () => {
|
||||
expect(
|
||||
resolveExecDefaults({
|
||||
cfg: {
|
||||
tools: {
|
||||
exec: {
|
||||
host: "auto",
|
||||
},
|
||||
},
|
||||
},
|
||||
sandboxAvailable: false,
|
||||
}),
|
||||
).toMatchObject({
|
||||
host: "auto",
|
||||
effectiveHost: "gateway",
|
||||
security: "full",
|
||||
ask: "off",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps sandbox deny by default when auto resolves to sandbox", () => {
|
||||
expect(
|
||||
resolveExecDefaults({
|
||||
cfg: {
|
||||
tools: {
|
||||
exec: {
|
||||
host: "auto",
|
||||
},
|
||||
},
|
||||
},
|
||||
sandboxAvailable: true,
|
||||
}),
|
||||
).toMatchObject({
|
||||
host: "auto",
|
||||
effectiveHost: "sandbox",
|
||||
security: "deny",
|
||||
ask: "off",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user