mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 22:18:27 +00:00
perf(test): fold exec approvals socket defaults into main suite
This commit is contained in:
@@ -1,32 +0,0 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
|
||||||
import { mergeExecApprovalsSocketDefaults, normalizeExecApprovals } from "./exec-approvals.js";
|
|
||||||
|
|
||||||
describe("mergeExecApprovalsSocketDefaults", () => {
|
|
||||||
it("prefers normalized socket, then current, then default path", () => {
|
|
||||||
const normalized = normalizeExecApprovals({
|
|
||||||
version: 1,
|
|
||||||
agents: {},
|
|
||||||
socket: { path: "/tmp/a.sock", token: "a" },
|
|
||||||
});
|
|
||||||
const current = normalizeExecApprovals({
|
|
||||||
version: 1,
|
|
||||||
agents: {},
|
|
||||||
socket: { path: "/tmp/b.sock", token: "b" },
|
|
||||||
});
|
|
||||||
const merged = mergeExecApprovalsSocketDefaults({ normalized, current });
|
|
||||||
expect(merged.socket?.path).toBe("/tmp/a.sock");
|
|
||||||
expect(merged.socket?.token).toBe("a");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("falls back to current token when missing in normalized", () => {
|
|
||||||
const normalized = normalizeExecApprovals({ version: 1, agents: {} });
|
|
||||||
const current = normalizeExecApprovals({
|
|
||||||
version: 1,
|
|
||||||
agents: {},
|
|
||||||
socket: { path: "/tmp/b.sock", token: "b" },
|
|
||||||
});
|
|
||||||
const merged = mergeExecApprovalsSocketDefaults({ normalized, current });
|
|
||||||
expect(merged.socket?.path).toBeTruthy();
|
|
||||||
expect(merged.socket?.token).toBe("b");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
isSafeBinUsage,
|
isSafeBinUsage,
|
||||||
matchAllowlist,
|
matchAllowlist,
|
||||||
maxAsk,
|
maxAsk,
|
||||||
|
mergeExecApprovalsSocketDefaults,
|
||||||
minSecurity,
|
minSecurity,
|
||||||
normalizeExecApprovals,
|
normalizeExecApprovals,
|
||||||
normalizeSafeBins,
|
normalizeSafeBins,
|
||||||
@@ -79,6 +80,36 @@ describe("exec approvals allowlist matching", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("mergeExecApprovalsSocketDefaults", () => {
|
||||||
|
it("prefers normalized socket, then current, then default path", () => {
|
||||||
|
const normalized = normalizeExecApprovals({
|
||||||
|
version: 1,
|
||||||
|
agents: {},
|
||||||
|
socket: { path: "/tmp/a.sock", token: "a" },
|
||||||
|
});
|
||||||
|
const current = normalizeExecApprovals({
|
||||||
|
version: 1,
|
||||||
|
agents: {},
|
||||||
|
socket: { path: "/tmp/b.sock", token: "b" },
|
||||||
|
});
|
||||||
|
const merged = mergeExecApprovalsSocketDefaults({ normalized, current });
|
||||||
|
expect(merged.socket?.path).toBe("/tmp/a.sock");
|
||||||
|
expect(merged.socket?.token).toBe("a");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("falls back to current token when missing in normalized", () => {
|
||||||
|
const normalized = normalizeExecApprovals({ version: 1, agents: {} });
|
||||||
|
const current = normalizeExecApprovals({
|
||||||
|
version: 1,
|
||||||
|
agents: {},
|
||||||
|
socket: { path: "/tmp/b.sock", token: "b" },
|
||||||
|
});
|
||||||
|
const merged = mergeExecApprovalsSocketDefaults({ normalized, current });
|
||||||
|
expect(merged.socket?.path).toBeTruthy();
|
||||||
|
expect(merged.socket?.token).toBe("b");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("exec approvals safe shell command builder", () => {
|
describe("exec approvals safe shell command builder", () => {
|
||||||
it("quotes only safeBins segments (leaves other segments untouched)", () => {
|
it("quotes only safeBins segments (leaves other segments untouched)", () => {
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
|
|||||||
Reference in New Issue
Block a user