mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-20 15:19:16 +00:00
* fix: dial SFTP separately on network-device SSH sessions Huawei and Ruijie switches drop the shell when SFTP opens on the terminal TCP session. Use the existing dedicated login for network-device mode and network-vendor banners without marking those hosts single-channel bastions. Fixes #3631 Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix: block follow-cwd probes on dedicated SFTP logins Network-device mode and vendor SSH banners already dial SFTP separately, but follow-terminal-cwd still opened an exec channel on the terminal transport. Gate that probe with the same dedicated-login decision. Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> * fix: skip terminal pwd exec for network-vendor banners when opening SFTP Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
54 lines
2.2 KiB
TypeScript
54 lines
2.2 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import test from "node:test";
|
|
|
|
const sidePanelSource = readFileSync(new URL("../SftpSidePanel.tsx", import.meta.url), "utf8");
|
|
const tabBridgeSource = readFileSync(
|
|
new URL("../terminalLayer/TerminalLayerTabBridge.tsx", import.meta.url),
|
|
"utf8",
|
|
);
|
|
|
|
test("SFTP side panel rebinds after same-tab SSH start-over", () => {
|
|
assert.match(sidePanelSource, /shouldRebindSftpSidePanelSourceSession\(/);
|
|
assert.match(sidePanelSource, /shouldDeferSftpSidePanelAutoConnectForSession\(/);
|
|
assert.match(sidePanelSource, /lastSourceSessionStatusRef/);
|
|
assert.match(
|
|
sidePanelSource,
|
|
/previousStatus:\s*lastSourceSessionStatusRef\.current/,
|
|
);
|
|
// Reuse the terminal transport only when SSH is connected, or when a strict
|
|
// pending source id is already pinned. A dedicated login (bastion banner,
|
|
// network-vendor banner, or network-device mode) never reuses that
|
|
// transport. A linked id may arrive while reconnecting.
|
|
assert.match(
|
|
sidePanelSource,
|
|
/const dedicatedSftpLogin = sftpRequiresDedicatedLogin\(\{/,
|
|
);
|
|
assert.match(
|
|
sidePanelSource,
|
|
/const reuseTerminalTransport = !dedicatedSftpLogin && \(\s*Boolean\(pendingStrictSourceSessionId\) \|\| activeSessionStatus === "connected"\s*\);/,
|
|
);
|
|
assert.match(
|
|
sidePanelSource,
|
|
/sourceSessionId: reuseTerminalTransport\s*\?\s*\(pendingStrictSourceSessionId \?\? \(activeSessionId \?\? undefined\)\)\s*: undefined/,
|
|
);
|
|
assert.match(
|
|
sidePanelSource,
|
|
/requireSourceSessionReuse: reuseTerminalTransport && Boolean\(pendingStrictSourceSessionId\)/,
|
|
);
|
|
assert.match(sidePanelSource, /resolveSftpSidePanelTrackedSourceStatusUpdate\(/);
|
|
assert.match(
|
|
sidePanelSource,
|
|
/trackedSessionId = lastSourceSessionIdRef\.current/,
|
|
);
|
|
assert.match(sidePanelSource, /if \(activeSessionId\) return;/);
|
|
});
|
|
|
|
test("terminal layer keeps the linked SFTP session id while SSH reconnects", () => {
|
|
assert.match(tabBridgeSource, /isTerminalSessionEligibleForSftpReuse\(session\)/);
|
|
assert.doesNotMatch(
|
|
tabBridgeSource,
|
|
/activeTerminalSessionIdForSftp[\s\S]*canReuseTerminalConnection\(session\)/,
|
|
);
|
|
});
|