Skip to content

Commit 2e06798

Browse files
cliffhallclaude
andcommitted
test(filesystem): drive the ADS validatePath cases through the tools
Calling validatePath directly ties the test to its signature, which the read-only-directories change (#5348) extends with an access mode. The two cases (an absolute stream path reports the stream refusal rather than 'outside allowed directories'; a relative stream path is refused) now go through read_text_file over the in-memory client, so they hold in either merge order. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 45aba4a commit 2e06798

1 file changed

Lines changed: 33 additions & 15 deletions

File tree

‎src/filesystem/__tests__/alternate-data-streams.test.ts‎

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ vi.mock("../version.js", () => ({ SERVER_VERSION: "0.0.0-test" }));
1717

1818
const { isPathWithinAllowedDirectories, namesAlternateDataStream } =
1919
await import("../path-validation.js");
20-
const { validatePath } = await import("../lib.js");
2120
const { call, connect, quietStderr, textOf } = await import("./helpers.js");
2221

2322
const realPlatform = process.platform;
@@ -134,20 +133,6 @@ describe("isPathWithinAllowedDirectories on win32 refuses alternate streams", ()
134133
});
135134
});
136135

137-
describe("validatePath on win32 refuses alternate streams", () => {
138-
it("reports the stream refusal, not 'outside allowed directories'", async () => {
139-
await expect(
140-
validatePath("C:\\work\\file.txt:hidden", ["C:\\work"]),
141-
).rejects.toThrow(REFUSAL);
142-
});
143-
144-
it("refuses a relative path that names a stream", async () => {
145-
await expect(validatePath("file.txt:hidden", ["C:\\work"])).rejects.toThrow(
146-
REFUSAL,
147-
);
148-
});
149-
});
150-
151136
describe("the tools on win32 refuse alternate streams", () => {
152137
it("returns the refusal as a tool error for a read and a write", async () => {
153138
quietStderr();
@@ -170,4 +155,37 @@ describe("the tools on win32 refuse alternate streams", () => {
170155
vi.restoreAllMocks();
171156
}
172157
});
158+
159+
// validatePath runs the stream check before the containment check, so the
160+
// error names the stream rather than "outside allowed directories".
161+
it("reports the stream refusal, not 'outside allowed directories'", async () => {
162+
quietStderr();
163+
const conn = await connect(["C:\\work"]);
164+
try {
165+
const result = await call(conn.client, "read_text_file", {
166+
path: "C:\\work\\file.txt:hidden",
167+
});
168+
expect(result.isError).toBe(true);
169+
expect(textOf(result)).toMatch(REFUSAL);
170+
expect(textOf(result)).not.toMatch(/outside allowed directories/);
171+
} finally {
172+
await conn.close();
173+
vi.restoreAllMocks();
174+
}
175+
});
176+
177+
it("refuses a relative path that names a stream", async () => {
178+
quietStderr();
179+
const conn = await connect(["C:\\work"]);
180+
try {
181+
const result = await call(conn.client, "read_text_file", {
182+
path: "file.txt:hidden",
183+
});
184+
expect(result.isError).toBe(true);
185+
expect(textOf(result)).toMatch(REFUSAL);
186+
} finally {
187+
await conn.close();
188+
vi.restoreAllMocks();
189+
}
190+
});
173191
});

0 commit comments

Comments
 (0)