[Init] Initial commit - NetMesh terminal manager
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
This commit is contained in:
121
electron/bridges/sshBridgeDebug.test.cjs
Normal file
121
electron/bridges/sshBridgeDebug.test.cjs
Normal file
@@ -0,0 +1,121 @@
|
||||
const test = require("node:test");
|
||||
const assert = require("node:assert/strict");
|
||||
|
||||
const fs = require("node:fs");
|
||||
const os = require("node:os");
|
||||
const path = require("node:path");
|
||||
|
||||
const {
|
||||
_appendSshDiagnosticLog,
|
||||
_createSshDiagnosticLogger,
|
||||
_getSshDebugLogFilePath,
|
||||
_setSshDebugLoggingEnabled,
|
||||
_shouldLogSshDebugMessage,
|
||||
} = require("./sshBridge.cjs");
|
||||
|
||||
test("SSH debug logging keeps handshake and key exchange messages", () => {
|
||||
assert.equal(
|
||||
_shouldLogSshDebugMessage("Handshake: KEX algorithm: diffie-hellman-group-exchange-sha1"),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
_shouldLogSshDebugMessage("Handshake: (remote) KEX method: diffie-hellman-group14-sha1"),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
_shouldLogSshDebugMessage("Outbound: Sending KEXDH_GEX_REQUEST"),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
_shouldLogSshDebugMessage("Received DH GEX Group"),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
_shouldLogSshDebugMessage("Outbound: Sending NEWKEYS"),
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test("SSH debug logging keeps auth messages but drops noisy channel data", () => {
|
||||
assert.equal(
|
||||
_shouldLogSshDebugMessage("Outbound: Sending USERAUTH_REQUEST (publickey -- check)"),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
_shouldLogSshDebugMessage("Inbound: Received CHANNEL_DATA"),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
_shouldLogSshDebugMessage("Outbound: Sending CHANNEL_WINDOW_ADJUST"),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test("SSH diagnostic log defaults to Netcatty's managed temp directory", () => {
|
||||
const logPath = _getSshDebugLogFilePath();
|
||||
assert.equal(path.basename(path.dirname(logPath)), "Netcatty");
|
||||
assert.match(path.basename(logPath), /netcatty-ssh\.log$/);
|
||||
});
|
||||
|
||||
test("SSH diagnostic logging can be enabled at runtime and writes safe connection events", () => {
|
||||
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "netcatty-ssh-debug-"));
|
||||
const logPath = path.join(tempRoot, "ssh-debug.log");
|
||||
|
||||
try {
|
||||
_setSshDebugLoggingEnabled(false, { logFilePath: logPath });
|
||||
_appendSshDiagnosticLog("connection closed", {
|
||||
hostname: "10.1.38.1",
|
||||
username: "alice",
|
||||
password: "secret",
|
||||
privateKey: "-----BEGIN PRIVATE KEY-----",
|
||||
reason: "closed",
|
||||
});
|
||||
assert.equal(fs.existsSync(logPath), false);
|
||||
|
||||
_setSshDebugLoggingEnabled(true, { logFilePath: logPath });
|
||||
assert.equal(_getSshDebugLogFilePath(), logPath);
|
||||
|
||||
_appendSshDiagnosticLog("connection closed", {
|
||||
hostname: "10.1.38.1",
|
||||
username: "alice",
|
||||
password: "secret",
|
||||
privateKey: "-----BEGIN PRIVATE KEY-----",
|
||||
reason: "closed",
|
||||
});
|
||||
|
||||
const contents = fs.readFileSync(logPath, "utf8");
|
||||
assert.match(contents, /connection closed/);
|
||||
assert.match(contents, /10\.1\.38\.1/);
|
||||
assert.match(contents, /"reason":"closed"/);
|
||||
assert.doesNotMatch(contents, /secret/);
|
||||
assert.doesNotMatch(contents, /PRIVATE KEY/);
|
||||
} finally {
|
||||
_setSshDebugLoggingEnabled(false);
|
||||
fs.rmSync(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("SSH diagnostic logger keeps each session's enabled state isolated", () => {
|
||||
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "netcatty-ssh-debug-"));
|
||||
const logPath = path.join(tempRoot, "ssh-debug.log");
|
||||
|
||||
try {
|
||||
_setSshDebugLoggingEnabled(false, { logFilePath: logPath });
|
||||
const enabledLogger = _createSshDiagnosticLogger(true);
|
||||
const disabledLogger = _createSshDiagnosticLogger(false);
|
||||
|
||||
disabledLogger("disabled session closed", { hostname: "10.1.38.2" });
|
||||
enabledLogger("enabled session closed", { hostname: "10.1.38.1" });
|
||||
disabledLogger("disabled session error", { hostname: "10.1.38.3" });
|
||||
|
||||
const contents = fs.readFileSync(logPath, "utf8");
|
||||
assert.match(contents, /enabled session closed/);
|
||||
assert.match(contents, /10\.1\.38\.1/);
|
||||
assert.doesNotMatch(contents, /disabled session/);
|
||||
assert.doesNotMatch(contents, /10\.1\.38\.2/);
|
||||
assert.doesNotMatch(contents, /10\.1\.38\.3/);
|
||||
} finally {
|
||||
_setSshDebugLoggingEnabled(false);
|
||||
fs.rmSync(tempRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user