[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

This commit is contained in:
2026-09-13 18:24:01 +08:00
commit 3c72efcb7f
3255 changed files with 907009 additions and 0 deletions

View File

@@ -0,0 +1,161 @@
import assert from "node:assert/strict";
import test from "node:test";
import { importVaultHostFiles } from "./vaultImportBatch.ts";
const secureCrtFile = (
relativePath: string,
hostname: string | null,
portHex = "00000016",
protocol = "SSH2",
) => {
const file = new File([[
hostname ? `S:"Hostname"=${hostname}` : "S:\"Username\"=nobody",
'S:"Username"=operator',
`S:"Protocol Name"=${protocol}`,
`D:"[SSH2] Port"=${portHex}`,
].join("\n")], relativePath.split("/").at(-1) ?? "session.ini");
Object.defineProperty(file, "webkitRelativePath", { value: relativePath });
return file;
};
test("SecureCRT directory import reads every session and preserves folder groups", async () => {
const result = await importVaultHostFiles({
format: "securecrt",
files: [
secureCrtFile("Sessions/Production/Web.ini", "web.example.com", "000008ae"),
secureCrtFile("Sessions/Staging/DB.ini", "db.example.com"),
secureCrtFile("Sessions/Archive/Web Copy.ini", "web.example.com", "000008ae"),
secureCrtFile("Sessions/Default.ini", "should-not-import.example.com"),
secureCrtFile("Sessions/Production/__FolderData__.ini", "should-not-import.example.com"),
secureCrtFile("Sessions/Broken.ini", null),
],
});
assert.deepEqual(result.stats, {
parsed: 3,
imported: 3,
skipped: 1,
duplicates: 0,
});
assert.deepEqual(
result.hosts.map(({ label, hostname, port, group }) => ({ label, hostname, port, group })),
[
{
label: "Web",
hostname: "web.example.com",
port: 2222,
group: "Production",
},
{
label: "DB",
hostname: "db.example.com",
port: 22,
group: "Staging",
},
{
label: "Web Copy",
hostname: "web.example.com",
port: 2222,
group: "Archive",
},
],
);
assert.deepEqual(result.groups, ["Production", "Staging", "Archive"]);
assert.match(result.issues[0]?.message ?? "", /Broken\.ini/);
});
test("SecureCRT keeps separate session files that point to the same endpoint", async () => {
const session = [
'S:"Hostname"=shared.example.com',
'S:"Username"=root',
'S:"Protocol Name"=SSH2',
].join("\n");
const result = await importVaultHostFiles({
format: "securecrt",
files: [
new File([session], "web.ini"),
new File([session], "web.ini"),
],
relativePaths: [
"Sessions/Prod/web.ini",
"Sessions/Staging/web.ini",
],
});
assert.equal(result.hosts.length, 2);
assert.deepEqual(result.hosts.map((host) => host.group), ["Prod", "Staging"]);
});
test("SecureCRT destination group keeps same-endpoint session files", async () => {
const { applyVaultImportDestination } = await import("../../domain/vaultImport");
const session = [
'S:"Hostname"=shared.example.com',
'S:"Username"=root',
'S:"Protocol Name"=SSH2',
].join("\n");
const imported = await importVaultHostFiles({
format: "securecrt",
files: [
new File([session], "web.ini"),
new File([session], "web.ini"),
],
relativePaths: [
"Sessions/Prod/web.ini",
"Sessions/Staging/web.ini",
],
});
const targeted = applyVaultImportDestination(
imported,
{ mode: "group", group: "Imported/SecureCRT" },
{ collapseDuplicateEndpoints: false },
);
assert.equal(targeted.hosts.length, 2);
assert.deepEqual(targeted.hosts.map((host) => host.group), [
"Imported/SecureCRT",
"Imported/SecureCRT",
]);
});
test("SecureCRT batch import does not count an unsupported session twice", async () => {
const result = await importVaultHostFiles({
format: "securecrt",
files: [secureCrtFile("Sessions/Local.ini", "localhost", "00000016", "Local")],
});
assert.equal(result.hosts.length, 0);
assert.equal(result.stats.parsed, 1);
assert.equal(result.stats.skipped, 1);
assert.equal(result.issues.length, 1);
});
test("SecureCRT folder paths transferred alongside files survive the worker boundary", async () => {
const file = new File([
[
'S:"Hostname"=transferred.example.com',
'S:"Username"=operator',
'S:"Protocol Name"=SSH2',
].join("\n"),
], "Transferred.ini");
const result = await importVaultHostFiles({
format: "securecrt",
files: [file],
relativePaths: ["Sessions/Production/Transferred.ini"],
});
assert.equal(result.hosts[0]?.group, "Production");
assert.deepEqual(result.groups, ["Production"]);
});
test("SecureCRT keeps a real nested Sessions folder when that folder was selected", async () => {
const result = await importVaultHostFiles({
format: "securecrt",
files: [secureCrtFile("Sessions/Sessions/Nested.ini", "nested.example.com")],
});
assert.equal(result.hosts[0]?.group, "Sessions");
assert.deepEqual(result.groups, ["Sessions"]);
});