[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:
115
components/port-forwarding/hostKeyVerification.test.ts
Normal file
115
components/port-forwarding/hostKeyVerification.test.ts
Normal file
@@ -0,0 +1,115 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
createKnownHostFromPortForwardHostKeyInfo,
|
||||
enqueuePortForwardHostKeyVerification,
|
||||
isPortForwardHostKeySessionId,
|
||||
removePortForwardHostKeyVerification,
|
||||
toPendingPortForwardHostKeyVerification,
|
||||
} from "./hostKeyVerification.ts";
|
||||
|
||||
test("isPortForwardHostKeySessionId only accepts port-forward tunnel sessions", () => {
|
||||
assert.equal(isPortForwardHostKeySessionId("pf-rule-1-123456"), true);
|
||||
assert.equal(isPortForwardHostKeySessionId("session-1"), false);
|
||||
assert.equal(isPortForwardHostKeySessionId(undefined), false);
|
||||
});
|
||||
|
||||
test("createKnownHostFromPortForwardHostKeyInfo saves the verified host key", () => {
|
||||
assert.deepEqual(
|
||||
createKnownHostFromPortForwardHostKeyInfo(
|
||||
{
|
||||
hostname: "jump.internal",
|
||||
port: 2200,
|
||||
keyType: "ssh-ed25519",
|
||||
fingerprint: "abc123",
|
||||
publicKey: "ssh-ed25519 AAAA",
|
||||
},
|
||||
1000,
|
||||
"fixed",
|
||||
),
|
||||
{
|
||||
id: "kh-1000-fixed",
|
||||
hostname: "jump.internal",
|
||||
port: 2200,
|
||||
keyType: "ssh-ed25519",
|
||||
publicKey: "ssh-ed25519 AAAA",
|
||||
fingerprint: "abc123",
|
||||
discoveredAt: 1000,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test("toPendingPortForwardHostKeyVerification ignores non-port-forward requests", () => {
|
||||
assert.equal(
|
||||
toPendingPortForwardHostKeyVerification({
|
||||
requestId: "req-terminal",
|
||||
sessionId: "terminal-session",
|
||||
hostname: "terminal.example.com",
|
||||
port: 22,
|
||||
keyType: "ssh-ed25519",
|
||||
fingerprint: "terminal-fingerprint",
|
||||
}),
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
test("toPendingPortForwardHostKeyVerification accepts port-forward requests", () => {
|
||||
assert.deepEqual(
|
||||
toPendingPortForwardHostKeyVerification({
|
||||
requestId: "req-port-forward",
|
||||
sessionId: "pf-rule-1-123456",
|
||||
hostname: "jump.internal",
|
||||
port: 2200,
|
||||
keyType: "ssh-ed25519",
|
||||
fingerprint: "abc123",
|
||||
publicKey: "ssh-ed25519 AAAA",
|
||||
status: "unknown",
|
||||
}),
|
||||
{
|
||||
requestId: "req-port-forward",
|
||||
hostKeyInfo: {
|
||||
hostname: "jump.internal",
|
||||
port: 2200,
|
||||
keyType: "ssh-ed25519",
|
||||
fingerprint: "abc123",
|
||||
publicKey: "ssh-ed25519 AAAA",
|
||||
status: "unknown",
|
||||
knownHostId: undefined,
|
||||
knownFingerprint: undefined,
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test("port-forward host-key confirmations are queued instead of overwritten", () => {
|
||||
const first = {
|
||||
requestId: "req-1",
|
||||
hostKeyInfo: {
|
||||
hostname: "jump-1.internal",
|
||||
port: 22,
|
||||
keyType: "ssh-ed25519",
|
||||
fingerprint: "first",
|
||||
},
|
||||
};
|
||||
const second = {
|
||||
requestId: "req-2",
|
||||
hostKeyInfo: {
|
||||
hostname: "jump-2.internal",
|
||||
port: 22,
|
||||
keyType: "ssh-ed25519",
|
||||
fingerprint: "second",
|
||||
},
|
||||
};
|
||||
|
||||
const queued = enqueuePortForwardHostKeyVerification(
|
||||
enqueuePortForwardHostKeyVerification([], first),
|
||||
second,
|
||||
);
|
||||
|
||||
assert.deepEqual(queued.map((pending) => pending.requestId), ["req-1", "req-2"]);
|
||||
assert.deepEqual(
|
||||
removePortForwardHostKeyVerification(queued, "req-1").map((pending) => pending.requestId),
|
||||
["req-2"],
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user