[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:
148
components/terminal/runtime/terminalDistroDetection.test.ts
Normal file
148
components/terminal/runtime/terminalDistroDetection.test.ts
Normal file
@@ -0,0 +1,148 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
registerConnectionToken,
|
||||
runDistroDetection,
|
||||
} from "./terminalDistroDetection.ts";
|
||||
|
||||
test("runDistroDetection uses SSH banner but skips POSIX probes for manually marked network devices", async () => {
|
||||
let remoteInfoCalls = 0;
|
||||
let distroProbeCalls = 0;
|
||||
const detected: string[] = [];
|
||||
const token = registerConnectionToken("ssh-session");
|
||||
|
||||
await runDistroDetection({
|
||||
host: {
|
||||
id: "host-1",
|
||||
label: "HPE iLO",
|
||||
hostname: "192.168.2.2",
|
||||
username: "root",
|
||||
deviceType: "network",
|
||||
},
|
||||
terminalBackend: {
|
||||
getSessionRemoteInfo: async () => {
|
||||
remoteInfoCalls += 1;
|
||||
return { success: true, remoteSshVersion: "SSH-2.0-mpSSH_0.2.1" };
|
||||
},
|
||||
getSessionDistroInfo: async () => {
|
||||
distroProbeCalls += 1;
|
||||
return { success: false, error: "network device closed the extra channel" };
|
||||
},
|
||||
},
|
||||
onOsDetected: (_hostId: string, distro: string) => {
|
||||
detected.push(distro);
|
||||
},
|
||||
} as never, "ssh-session", token);
|
||||
|
||||
assert.equal(remoteInfoCalls, 1);
|
||||
assert.equal(distroProbeCalls, 0);
|
||||
assert.deepEqual(detected, ["hpe"]);
|
||||
});
|
||||
|
||||
test("runDistroDetection normalizes Darwin probe output to macos", async () => {
|
||||
let remoteInfoCalls = 0;
|
||||
let distroProbeCalls = 0;
|
||||
const detected: string[] = [];
|
||||
const token = registerConnectionToken("macos-session");
|
||||
|
||||
await runDistroDetection({
|
||||
host: {
|
||||
id: "macos-host",
|
||||
label: "Mac mini",
|
||||
hostname: "mac-mini.local",
|
||||
username: "dev",
|
||||
},
|
||||
terminalBackend: {
|
||||
getSessionRemoteInfo: async () => {
|
||||
remoteInfoCalls += 1;
|
||||
return { success: true, remoteSshVersion: "SSH-2.0-OpenSSH_9.9" };
|
||||
},
|
||||
getSessionDistroInfo: async () => {
|
||||
distroProbeCalls += 1;
|
||||
return {
|
||||
success: true,
|
||||
stdout: "Darwin mac-mini.local 24.5.0 Darwin Kernel Version 24.5.0\n",
|
||||
stderr: "",
|
||||
};
|
||||
},
|
||||
},
|
||||
onOsDetected: (_hostId: string, distro: string) => {
|
||||
detected.push(distro);
|
||||
},
|
||||
} as never, "macos-session", token);
|
||||
|
||||
assert.equal(remoteInfoCalls, 1);
|
||||
assert.equal(distroProbeCalls, 1);
|
||||
assert.deepEqual(detected, ["macos"]);
|
||||
});
|
||||
|
||||
test("runDistroDetection normalizes FreeBSD uname output", async () => {
|
||||
const detected: string[] = [];
|
||||
const token = registerConnectionToken("freebsd-session");
|
||||
|
||||
await runDistroDetection({
|
||||
host: {
|
||||
id: "freebsd-host",
|
||||
label: "FreeBSD server",
|
||||
hostname: "freebsd.example.com",
|
||||
username: "root",
|
||||
},
|
||||
terminalBackend: {
|
||||
getSessionRemoteInfo: async () => ({
|
||||
success: true,
|
||||
remoteSshVersion: "SSH-2.0-OpenSSH_9.7 FreeBSD-20240806",
|
||||
}),
|
||||
getSessionDistroInfo: async () => ({
|
||||
success: true,
|
||||
stdout: "FreeBSD freebsd.example.com 14.3-RELEASE-p1 GENERIC amd64\n",
|
||||
stderr: "",
|
||||
}),
|
||||
},
|
||||
onOsDetected: (_hostId: string, distro: string) => {
|
||||
detected.push(distro);
|
||||
},
|
||||
} as never, "freebsd-session", token);
|
||||
|
||||
assert.deepEqual(detected, ["freebsd"]);
|
||||
});
|
||||
|
||||
test("Windows OpenSSH is identified without sending POSIX probes", async () => {
|
||||
const detected: string[] = [];
|
||||
await runDistroDetection({
|
||||
host: { id: 'windows', os: 'linux' },
|
||||
terminalBackend: {
|
||||
getSessionRemoteInfo: async () => ({ success: true, remoteSshVersion: 'SSH-2.0-OpenSSH_for_Windows_9.5' }),
|
||||
getSessionDistroInfo: async () => { throw new Error('must not probe Windows with POSIX commands'); },
|
||||
},
|
||||
onOsDetected: (_id: string, distro: string) => detected.push(distro),
|
||||
} as never, 'windows', registerConnectionToken('windows'));
|
||||
assert.deepEqual(detected, ['windows']);
|
||||
});
|
||||
|
||||
test("failed or unrecognized probes do not invent an operating system", async () => {
|
||||
const detected: string[] = [];
|
||||
await runDistroDetection({
|
||||
host: { id: 'unknown', os: 'linux' },
|
||||
terminalBackend: {
|
||||
getSessionDistroInfo: async () => ({ success: true, stdout: '', stderr: 'Linux command not found' }),
|
||||
},
|
||||
onOsDetected: (_id: string, distro: string) => detected.push(distro),
|
||||
} as never, 'unknown', registerConnectionToken('unknown'));
|
||||
assert.deepEqual(detected, []);
|
||||
});
|
||||
|
||||
test("a superseded Windows detection cannot update the newer connection", async () => {
|
||||
const detected: string[] = [];
|
||||
await runDistroDetection({
|
||||
host: { id: 'windows', os: 'linux' },
|
||||
terminalBackend: {
|
||||
getSessionRemoteInfo: async () => {
|
||||
registerConnectionToken('reconnected');
|
||||
return { success: true, remoteSshVersion: 'OpenSSH_for_Windows_9.5' };
|
||||
},
|
||||
},
|
||||
onOsDetected: (_id: string, distro: string) => detected.push(distro),
|
||||
} as never, 'reconnected', registerConnectionToken('reconnected'));
|
||||
assert.deepEqual(detected, []);
|
||||
});
|
||||
Reference in New Issue
Block a user