test: tighten sandbox mounted path assertions

This commit is contained in:
Peter Steinberger
2026-05-09 15:38:27 +01:00
parent 64c5d52ca2
commit 4015402534

View File

@@ -103,9 +103,10 @@ describe("tools.fs.workspaceOnly", () => {
await expect(
writeTool?.execute("t2", { path: "/agent/owned.txt", content: "x" }),
).rejects.toThrow(/Path escapes sandbox root/i);
await expect(fs.stat(path.join(agentRoot, "owned.txt"))).rejects.toMatchObject({
code: "ENOENT",
});
const missingOwnedFile = await fs
.stat(path.join(agentRoot, "owned.txt"))
.catch((error: unknown) => error);
expect((missingOwnedFile as NodeJS.ErrnoException).code).toBe("ENOENT");
await expect(
editTool?.execute("t3", { path: "/agent/secret.txt", oldText: "shh", newText: "nope" }),
@@ -129,9 +130,10 @@ describe("tools.fs.workspaceOnly", () => {
await expect(applyPatchTool.execute("t1", { input: APPLY_PATCH_PAYLOAD })).rejects.toThrow(
/Path escapes sandbox root/i,
);
await expect(fs.stat(path.join(agentRoot, "pwned.txt"))).rejects.toMatchObject({
code: "ENOENT",
});
const missingPatchedFile = await fs
.stat(path.join(agentRoot, "pwned.txt"))
.catch((error: unknown) => error);
expect((missingPatchedFile as NodeJS.ErrnoException).code).toBe("ENOENT");
});
});