Files
Netcatty/components/terminalLayer/commandCwdProbe.test.ts
T
又是一条懒汉 5805d15746 feat(ssh): add single-channel SSH option for bastion hosts (#3458)
Add a host and group toggle for bastions that allow one session channel per TCP connection. After the handshake, BHostSSH, TERM-SSHD, and CLOUDBILITY take that path automatically. File transfer uses a separate SFTP login, and the interactive terminal is not given another exec, SFTP, copy/split, or port-forward channel.

The manual toggle remains for bastions that still advertise OpenSSH.
2026-09-29 18:01:04 +08:00

66 lines
1.8 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { shouldProbeCommandCwd } from "./commandCwdProbe";
test("probes command cwd for session restore even when the SFTP panel is not visible", () => {
assert.equal(
shouldProbeCommandCwd({
restoreTerminalCwd: true,
visibleSftpHost: null,
sessionHost: { sftpFollowTerminalCwd: false },
globalSftpFollowTerminalCwd: false,
}),
true,
);
});
test("does not probe command cwd when neither session restore nor SFTP follow cwd needs it", () => {
assert.equal(
shouldProbeCommandCwd({
restoreTerminalCwd: false,
visibleSftpHost: null,
sessionHost: { sftpFollowTerminalCwd: true },
globalSftpFollowTerminalCwd: true,
}),
false,
);
});
test("probes command cwd for visible SFTP follow cwd using host override", () => {
assert.equal(
shouldProbeCommandCwd({
restoreTerminalCwd: false,
visibleSftpHost: { sftpFollowTerminalCwd: true },
sessionHost: { sftpFollowTerminalCwd: false },
globalSftpFollowTerminalCwd: false,
}),
true,
);
});
test("visible SFTP host override can disable command cwd probing", () => {
assert.equal(
shouldProbeCommandCwd({
restoreTerminalCwd: false,
visibleSftpHost: { sftpFollowTerminalCwd: false },
sessionHost: { sftpFollowTerminalCwd: true },
globalSftpFollowTerminalCwd: true,
}),
false,
);
});
test("does not probe command cwd on single-channel SSH hosts", () => {
assert.equal(
shouldProbeCommandCwd({
restoreTerminalCwd: true,
visibleSftpHost: { sftpFollowTerminalCwd: true },
sessionHost: { sftpFollowTerminalCwd: true },
globalSftpFollowTerminalCwd: true,
restrictExtraSshChannels: true,
}),
false,
);
});