fix: add windows trans fs read ops
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
parseSshInvocation,
|
||||
sshStdoutStreamMaxBytes,
|
||||
sshStdoutTruncationHint,
|
||||
windowsFsReadOnlyScript,
|
||||
windowsPowerShellScriptPrelude,
|
||||
} from "./ssh";
|
||||
|
||||
@@ -20,6 +21,44 @@ describe("ssh windows PowerShell safety prelude", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("ssh windows fs read-only operations", () => {
|
||||
test("routes common read-only commands through the Windows fs backend", () => {
|
||||
const invocation = parseSshInvocation("D601:win/c/test", ["cat", "hello.md"]);
|
||||
const rgInvocation = parseSshInvocation("D601:win/c/test", ["rg", "-i", "needle", "."]);
|
||||
|
||||
expect(invocation.route.plane).toBe("win");
|
||||
expect(invocation.route.workspace).toBe("C:\\test");
|
||||
expect(invocation.parsed.invocationKind).toBe("helper");
|
||||
expect(invocation.parsed.requiresStdin).toBe(false);
|
||||
expect(invocation.parsed.remoteCommand).toContain("powershell.exe");
|
||||
expect(invocation.parsed.remoteCommand).toContain("-EncodedCommand");
|
||||
expect(rgInvocation.parsed.invocationKind).toBe("helper");
|
||||
expect(rgInvocation.parsed.requiresStdin).toBe(false);
|
||||
});
|
||||
|
||||
test("builds bounded UTF-8 scripts for cat, ls, and rg", () => {
|
||||
const catScript = windowsFsReadOnlyScript("F:\\Work\\demo", "cat", ["--max-bytes", "4096", "中文.md"]);
|
||||
const lsScript = windowsFsReadOnlyScript("F:\\Work\\demo", "ls", ["-la", "--limit=5"]);
|
||||
const rgScript = windowsFsReadOnlyScript("F:\\Work\\demo", "rg", ["-i", "--max-count=5", "needle", "."]);
|
||||
|
||||
expect(catScript).toContain("$operation = 'cat';");
|
||||
expect(catScript).toContain("F:\\Work\\demo");
|
||||
expect(catScript).toContain("binary file refused by windows fs read operation");
|
||||
expect(catScript).toContain("file is not valid UTF-8");
|
||||
expect(catScript).toContain("file too large for windows fs read operation");
|
||||
expect(lsScript).toContain("$operation = 'ls';");
|
||||
expect(lsScript).toContain("UNIDESK_WINDOWS_FS_TRUNCATED");
|
||||
expect(lsScript).toContain("TYPE BYTES UPDATED NAME");
|
||||
expect(rgScript).toContain("$operation = 'rg';");
|
||||
expect(rgScript).toContain("unsupported rg option on Windows route");
|
||||
expect(rgScript).toContain("UNIDESK_WINDOWS_FS_SKIPPED");
|
||||
});
|
||||
|
||||
test("rejects unsupported Windows read operations instead of treating them as POSIX", () => {
|
||||
expect(() => parseSshInvocation("D601:win/c/test", ["sed", "-n", "1p", "hello.md"])).toThrow("unsupported ssh win operation: sed");
|
||||
});
|
||||
});
|
||||
|
||||
describe("ssh stdout bounded streaming", () => {
|
||||
test("uses bounded defaults and clamps env override", () => {
|
||||
expect(sshStdoutStreamMaxBytes({} as NodeJS.ProcessEnv)).toBe(256 * 1024);
|
||||
|
||||
Reference in New Issue
Block a user