mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-20 07:04:53 +00:00
* restore h3c network device detection * ignore release build artifacts in lint * restore h3c mpssh banner detection * detect network device vendor banners * Map mpSSH banners to HPE iLO --------- Co-authored-by: mam15mon <mam15mon@gmail.com>
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
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"]);
|
|
});
|