|
|
@@ -293,19 +293,26 @@ describe("tool.write", () => {
|
|
|
})
|
|
|
|
|
|
describe("error handling", () => {
|
|
|
- test("throws error for paths outside project", async () => {
|
|
|
+ test("throws error when OS denies write access", async () => {
|
|
|
await using tmp = await tmpdir()
|
|
|
- const outsidePath = "/etc/passwd"
|
|
|
+ const readonlyPath = path.join(tmp.path, "readonly.txt")
|
|
|
+
|
|
|
+ // Create a read-only file
|
|
|
+ await fs.writeFile(readonlyPath, "test", "utf-8")
|
|
|
+ await fs.chmod(readonlyPath, 0o444)
|
|
|
|
|
|
await Instance.provide({
|
|
|
directory: tmp.path,
|
|
|
fn: async () => {
|
|
|
+ const { FileTime } = await import("../../src/file/time")
|
|
|
+ FileTime.read(ctx.sessionID, readonlyPath)
|
|
|
+
|
|
|
const write = await WriteTool.init()
|
|
|
await expect(
|
|
|
write.execute(
|
|
|
{
|
|
|
- filePath: outsidePath,
|
|
|
- content: "test",
|
|
|
+ filePath: readonlyPath,
|
|
|
+ content: "new content",
|
|
|
},
|
|
|
ctx,
|
|
|
),
|