fix: keep cli dump budget byte-only
This commit is contained in:
@@ -164,7 +164,6 @@ describe("ssh stdout bounded streaming", () => {
|
||||
});
|
||||
|
||||
test("formats truncation hint without echoing remote command", () => {
|
||||
const policy = readCliOutputPolicy();
|
||||
const invocation = parseSshInvocation("D601:win", ["ps"]);
|
||||
expect(invocation.parsed.remoteCommand).not.toBeNull();
|
||||
const hint = sshStdoutTruncationHint({
|
||||
@@ -186,7 +185,6 @@ describe("ssh stdout bounded streaming", () => {
|
||||
name: "unified-cli-dump-preview",
|
||||
configPath: "config/unidesk-cli.yaml",
|
||||
});
|
||||
expect(payload.thresholdLines).toBe(policy.maxPreviewLines);
|
||||
expect(formatted).not.toContain("Get-Content");
|
||||
});
|
||||
|
||||
@@ -219,32 +217,6 @@ describe("ssh stdout bounded streaming", () => {
|
||||
rmSync(payload.dumpPath, { force: true });
|
||||
});
|
||||
|
||||
test("forwarder bounds very short lines by YAML-style line budget", () => {
|
||||
const invocation = parseSshInvocation("D601:win", ["ps"]);
|
||||
const forwarded: Buffer[] = [];
|
||||
const stdout = {
|
||||
write(chunk: string | Buffer): boolean {
|
||||
forwarded.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
||||
return true;
|
||||
},
|
||||
} as NodeJS.WritableStream;
|
||||
const forwarder = createSshStdoutForwarder({
|
||||
invocation,
|
||||
transport: "frontend-websocket",
|
||||
maxBytes: 1000,
|
||||
maxLines: 2,
|
||||
stdout,
|
||||
});
|
||||
|
||||
const hint = forwarder.write(Buffer.from("a\nb\nc\n"));
|
||||
expect(Buffer.concat(forwarded).toString("utf8")).toBe("a\nb\n");
|
||||
expect(hint).toContain("\"trigger\":\"lines\"");
|
||||
const payload = JSON.parse(hint!.slice("UNIDESK_SSH_STDOUT_TRUNCATED ".length)) as { dumpPath: string; forwardedLines: number };
|
||||
expect(payload.forwardedLines).toBe(2);
|
||||
expect(readFileSync(payload.dumpPath, "utf8")).toBe("a\nb\nc\n");
|
||||
rmSync(payload.dumpPath, { force: true });
|
||||
});
|
||||
|
||||
test("stderr forwarder uses the same dump guard and marker", () => {
|
||||
const invocation = parseSshInvocation("D601:win", ["ps"]);
|
||||
const forwarded: Buffer[] = [];
|
||||
|
||||
Reference in New Issue
Block a user