mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-25 09:51:28 +00:00
* refactor: streamline codebase, unify duplicated modules, and consolidate tests * fix(test): batch discovered test files into Windows-safe command lines
92 lines
2.8 KiB
JavaScript
92 lines
2.8 KiB
JavaScript
"use strict";
|
|
|
|
const test = require("node:test");
|
|
const assert = require("node:assert/strict");
|
|
const {
|
|
remoteSoftwareRequiresSingleChannel,
|
|
remoteDisallowsChunkedChannelWrite,
|
|
optionsForPeerSingleChannel,
|
|
} = require("./singleChannelSshBanner.shared.cjs");
|
|
|
|
test("single-channel banners match only the supported software tokens", () => {
|
|
for (const version of [
|
|
"BHostSSH_7.0",
|
|
"SSH-2.0-BHostSSH_7.0",
|
|
"TERM-SSHD",
|
|
"SSH-2.0-TERM-SSHD",
|
|
"term-sshd",
|
|
"CLOUDBILITY-4.14",
|
|
"SSH-2.0-CLOUDBILITY-4.14",
|
|
"CloudLinker",
|
|
"SSH-2.0-CloudLinker",
|
|
"cloudlinker-1.0",
|
|
"russh",
|
|
"SSH-2.0-russh",
|
|
"SSH-2.0-russh_0.45.0",
|
|
"RuSSH",
|
|
]) {
|
|
assert.equal(remoteSoftwareRequiresSingleChannel(version), true, version);
|
|
}
|
|
});
|
|
|
|
test("single-channel banner match ignores OpenSSH, JumpServer, and lookalike tokens", () => {
|
|
for (const version of [
|
|
"",
|
|
" ",
|
|
undefined,
|
|
"OpenSSH_9.6",
|
|
"SSH-2.0-OpenSSH_9.6",
|
|
"OpenSSH_for_Windows_9.5",
|
|
"dropbear_2024.85",
|
|
"JumpServer",
|
|
"SSH-2.0-JumpServer",
|
|
"KoKo",
|
|
"SSH-2.0-KOKO",
|
|
"tsshd",
|
|
"superterm-sshd",
|
|
"cloudterm-sshd",
|
|
"openterm-sshd",
|
|
"CmdbHostSSH",
|
|
"BHost",
|
|
"notcloudbility",
|
|
"Go",
|
|
"SSH-2.0-Go",
|
|
"notcloudlinker",
|
|
"CloudLinkerProxy",
|
|
"russhd",
|
|
"myrussh",
|
|
"prerussh",
|
|
"russhserver",
|
|
"SSH-2.0-russhd",
|
|
"notRussh",
|
|
]) {
|
|
assert.equal(remoteSoftwareRequiresSingleChannel(version), false, String(version));
|
|
}
|
|
});
|
|
|
|
test("chunked-write limit stays on BHostSSH and TERM-SSHD", () => {
|
|
assert.equal(remoteDisallowsChunkedChannelWrite("BHostSSH_7.0"), true);
|
|
assert.equal(remoteDisallowsChunkedChannelWrite("SSH-2.0-TERM-SSHD"), true);
|
|
assert.equal(remoteDisallowsChunkedChannelWrite("CLOUDBILITY-4.14"), false);
|
|
assert.equal(remoteDisallowsChunkedChannelWrite("SSH-2.0-CloudLinker"), false);
|
|
assert.equal(remoteDisallowsChunkedChannelWrite("SSH-2.0-russh"), false);
|
|
assert.equal(remoteDisallowsChunkedChannelWrite("SSH-2.0-russh_0.45.0"), false);
|
|
assert.equal(remoteDisallowsChunkedChannelWrite("OpenSSH_9.6"), false);
|
|
assert.equal(remoteDisallowsChunkedChannelWrite("superterm-sshd"), false);
|
|
});
|
|
|
|
test("optionsForPeerSingleChannel stamps the runtime flag from the peer banner", () => {
|
|
const requested = { hostname: "bastion", singleChannelSsh: false };
|
|
const stamped = optionsForPeerSingleChannel(requested, { _remoteVer: "CLOUDBILITY-4.14" });
|
|
assert.equal(stamped.singleChannelSsh, true);
|
|
assert.equal(requested.singleChannelSsh, false);
|
|
assert.equal(
|
|
optionsForPeerSingleChannel(requested, { _remoteVer: "OpenSSH_9.6" }),
|
|
requested,
|
|
);
|
|
assert.equal(
|
|
optionsForPeerSingleChannel({ singleChannelSsh: true }, { _remoteVer: "OpenSSH_9.6" }).singleChannelSsh,
|
|
true,
|
|
);
|
|
});
|