mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 16:28:26 +00:00
test(agents): share pi-tools sandbox fixture context
This commit is contained in:
@@ -4,6 +4,7 @@ import path from "node:path";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { createOpenClawCodingTools } from "./pi-tools.js";
|
||||
import { createHostSandboxFsBridge } from "./test-helpers/host-sandbox-fs-bridge.js";
|
||||
import { createPiToolsSandboxContext } from "./test-helpers/pi-tools-sandbox-context.js";
|
||||
|
||||
vi.mock("../infra/shell-env.js", async (importOriginal) => {
|
||||
const mod = await importOriginal<typeof import("../infra/shell-env.js")>();
|
||||
@@ -157,29 +158,13 @@ describe("sandboxed workspace paths", () => {
|
||||
it("uses sandbox workspace for relative read/write/edit", async () => {
|
||||
await withTempDir("openclaw-sandbox-", async (sandboxDir) => {
|
||||
await withTempDir("openclaw-workspace-", async (workspaceDir) => {
|
||||
const sandbox = {
|
||||
enabled: true,
|
||||
sessionKey: "sandbox:test",
|
||||
const sandbox = createPiToolsSandboxContext({
|
||||
workspaceDir: sandboxDir,
|
||||
agentWorkspaceDir: workspaceDir,
|
||||
workspaceAccess: "rw" as const,
|
||||
containerName: "openclaw-sbx-test",
|
||||
containerWorkdir: "/workspace",
|
||||
fsBridge: createHostSandboxFsBridge(sandboxDir),
|
||||
docker: {
|
||||
image: "openclaw-sandbox:bookworm-slim",
|
||||
containerPrefix: "openclaw-sbx-",
|
||||
workdir: "/workspace",
|
||||
readOnlyRoot: true,
|
||||
tmpfs: [],
|
||||
network: "none",
|
||||
user: "1000:1000",
|
||||
capDrop: ["ALL"],
|
||||
env: { LANG: "C.UTF-8" },
|
||||
},
|
||||
tools: { allow: [], deny: [] },
|
||||
browserAllowHostControl: false,
|
||||
};
|
||||
});
|
||||
|
||||
const testFile = "sandbox.txt";
|
||||
await fs.writeFile(path.join(sandboxDir, testFile), "sandbox read", "utf8");
|
||||
|
||||
Reference in New Issue
Block a user