mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-23 16:42:19 +00:00
* feat(autocomplete): add zh-CN descriptions for zip, unzip, make, nano Cover 32 missing Fig descriptions, generate zh-TW, add batch coverage tests, and record source and semantic checks. * fix(autocomplete): correct zip, unzip, and make semantics Limit zip -9 to the compression level, warn that unzip -0 is a suspect upstream option, and describe make -N as the Apple/NeXT compatibility extension. * fix(autocomplete): simplify unzip -0 warning and correct NeXT note Keep the -O gbk version caveat in the research record and describe Next/NeXT as a capitalization difference. * feat(autocomplete): complete remaining common command descriptions Add 177 zh-CN descriptions for python, python3, node, vim, sort, awk, and sed; generate zh-TW, cover the batch with real Fig specs, and record one deferred shared node key. * fix(autocomplete): correct sed n and sort parallel semantics Add the automatic-print condition to sed n, remove the universal CPU default from sort --parallel, and remove duplicated adopted-entry sections from the source record. * fix: repair macOS terminal setup and align autocomplete details - Read OSC 7 setup payloads through base64 stdin so BSD/macOS works - Keep the FIDO askpass socket path within the Unix sun_path limit - Align autocomplete descriptions in a shared fixed column - Fix an invalid optional-parameter declaration and lint warnings - Harden macOS-sensitive OSC 7, SFTP, temp-dir and privacy tests * feat(autocomplete): add zh-CN descriptions for file and text utilities Cover ln, stat, wc, cut, uniq, tee and xargs with 70 localized descriptions. Add coverage and localization tests, preload the new common specs, and record the upstream wc/xargs wording corrections. * fix(autocomplete): keep popup scrollbars draggable Panel mousedown handlers no longer preventDefault across the whole box, so the right-side detail scrollbar and the suggestion list scrollbar can be dragged while padding clicks still preserve terminal focus. * fix(autocomplete): keep detail panel open while selecting text Delay row hover clearing so the pointer can move into the right-side detail panel, and allow native text selection there without stealing terminal focus on ordinary padding clicks.
104 lines
4.0 KiB
JavaScript
104 lines
4.0 KiB
JavaScript
"use strict";
|
|
|
|
const test = require("node:test");
|
|
const assert = require("node:assert/strict");
|
|
const {
|
|
classifyAskpassPrompt,
|
|
buildFidoAskpassEnv,
|
|
ensureFidoAskpass,
|
|
releaseFidoAskpassLease,
|
|
shutdownFidoAskpass,
|
|
getTempBase,
|
|
} = require("./fidoAskpass.cjs");
|
|
const fidoPromptHandler = require("./fidoPromptHandler.cjs");
|
|
const fs = require("node:fs");
|
|
const { EventEmitter } = require("node:events");
|
|
|
|
test("buildFidoAskpassEnv creates helper artifacts", () => {
|
|
const env = buildFidoAskpassEnv();
|
|
assert.ok(env.SSH_ASKPASS);
|
|
assert.equal(env.SSH_ASKPASS_REQUIRE, "force");
|
|
assert.ok(env.NETCATTY_FIDO_ASKPASS_SOCK);
|
|
assert.ok(fs.existsSync(env.SSH_ASKPASS));
|
|
const artifacts = ensureFidoAskpass();
|
|
assert.equal(artifacts.wrapperPath, env.SSH_ASKPASS);
|
|
shutdownFidoAskpass();
|
|
});
|
|
|
|
test("getTempBase uses Netcatty managed temp dir (no os.tmpdir fallback)", () => {
|
|
const tempDirBridge = require("./tempDirBridge.cjs");
|
|
const managed = tempDirBridge.getTempDir();
|
|
assert.equal(getTempBase(), managed);
|
|
assert.match(managed, /Netcatty/i);
|
|
});
|
|
|
|
test("askpass socket path stays within the Unix sun_path limit", () => {
|
|
const artifacts = ensureFidoAskpass();
|
|
try {
|
|
if (process.platform !== "win32") {
|
|
assert.ok(
|
|
Buffer.byteLength(artifacts.socketPath) <= 103,
|
|
`socket path must fit sun_path: ${artifacts.socketPath}`,
|
|
);
|
|
}
|
|
} finally {
|
|
shutdownFidoAskpass();
|
|
}
|
|
});
|
|
|
|
test("classifyAskpassPrompt re-export works", () => {
|
|
assert.equal(classifyAskpassPrompt("Enter PIN for authenticator"), "pin");
|
|
assert.equal(classifyAskpassPrompt("Confirm user presence"), "touch");
|
|
});
|
|
|
|
test("releaseFidoAskpassLease cancels outstanding FIDO prompts for that lease", async () => {
|
|
const sent = [];
|
|
const sender = {
|
|
id: 77,
|
|
isDestroyed: () => false,
|
|
send: (channel, payload) => sent.push({ channel, payload }),
|
|
};
|
|
const leaseId = "lease-release-cancel-test";
|
|
const pending = fidoPromptHandler.requestFidoPrompt(sender, {
|
|
kind: "pin",
|
|
message: "Enter PIN",
|
|
leaseId,
|
|
});
|
|
releaseFidoAskpassLease(leaseId);
|
|
assert.deepEqual(await pending, { cancelled: true });
|
|
assert.equal(fidoPromptHandler.getRequests().size, 0);
|
|
assert.ok(sent.some((entry) => entry.channel === "netcatty:fido-prompt-cancelled"));
|
|
});
|
|
|
|
test("Windows notification helpers exit immediately while hints follow PIN and lease ownership", async () => {
|
|
class Socket extends EventEmitter {
|
|
setEncoding() {}
|
|
end(data) { this.reply = JSON.parse(data); this.emit("close"); }
|
|
}
|
|
const sender = { id: 2823, isDestroyed: () => false, send() {} };
|
|
const env = buildFidoAskpassEnv({ resolveWebContents: () => sender });
|
|
const leaseId = env.NETCATTY_FIDO_ASKPASS_LEASE;
|
|
const { handleAskpassClient } = require("./fidoAskpass.cjs");
|
|
try {
|
|
const notification = new Socket();
|
|
handleAskpassClient(notification, "win32");
|
|
notification.emit("data", `${JSON.stringify({ mode: "none", leaseId, prompt: "Touch security key" })}\n`);
|
|
assert.equal(notification.reply.ok, true, "native helper must not block device-failure replies");
|
|
assert.equal(fidoPromptHandler.getRequests().size, 1, "helper exit must not dismiss the independent hint");
|
|
const pin = new Socket();
|
|
handleAskpassClient(pin, "win32");
|
|
pin.emit("data", `${JSON.stringify({ leaseId, prompt: "Enter PIN for authenticator:" })}\n`);
|
|
const requests = [...fidoPromptHandler.getRequests()];
|
|
assert.equal(requests.length, 1, "a stale touch hint must not block PIN input");
|
|
assert.equal(requests[0][1].kind, "pin");
|
|
fidoPromptHandler.handleResponse({ sender }, { requestId: requests[0][0], response: "fixture-pin" });
|
|
await new Promise(setImmediate);
|
|
assert.equal(pin.reply.response, "fixture-pin");
|
|
const hints = [...fidoPromptHandler.getRequests().values()];
|
|
assert.equal(hints.length, 1);
|
|
assert.equal(hints[0].kind, "touch");
|
|
releaseFidoAskpassLease(leaseId);
|
|
assert.equal(fidoPromptHandler.getRequests().size, 0);
|
|
} finally { releaseFidoAskpassLease(leaseId); shutdownFidoAskpass(); }
|
|
});
|