test: tighten sandbox mounted path assertions · openclaw/openclaw@4015402
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -103,9 +103,10 @@ describe("tools.fs.workspaceOnly", () => {
|
103 | 103 | await expect( |
104 | 104 | writeTool?.execute("t2", { path: "/agent/owned.txt", content: "x" }), |
105 | 105 | ).rejects.toThrow(/Path escapes sandbox root/i); |
106 | | -await expect(fs.stat(path.join(agentRoot, "owned.txt"))).rejects.toMatchObject({ |
107 | | -code: "ENOENT", |
108 | | -}); |
| 106 | +const missingOwnedFile = await fs |
| 107 | +.stat(path.join(agentRoot, "owned.txt")) |
| 108 | +.catch((error: unknown) => error); |
| 109 | +expect((missingOwnedFile as NodeJS.ErrnoException).code).toBe("ENOENT"); |
109 | 110 | |
110 | 111 | await expect( |
111 | 112 | editTool?.execute("t3", { path: "/agent/secret.txt", oldText: "shh", newText: "nope" }), |
@@ -129,9 +130,10 @@ describe("tools.fs.workspaceOnly", () => {
|
129 | 130 | await expect(applyPatchTool.execute("t1", { input: APPLY_PATCH_PAYLOAD })).rejects.toThrow( |
130 | 131 | /Path escapes sandbox root/i, |
131 | 132 | ); |
132 | | -await expect(fs.stat(path.join(agentRoot, "pwned.txt"))).rejects.toMatchObject({ |
133 | | -code: "ENOENT", |
134 | | -}); |
| 133 | +const missingPatchedFile = await fs |
| 134 | +.stat(path.join(agentRoot, "pwned.txt")) |
| 135 | +.catch((error: unknown) => error); |
| 136 | +expect((missingPatchedFile as NodeJS.ErrnoException).code).toBe("ENOENT"); |
135 | 137 | }); |
136 | 138 | }); |
137 | 139 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。