mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
3235f11870
* Fix default SSH key fallback after Keychain reference key selection. Treat identityFilePaths as an explicit user key choice so terminal SSH sessions no longer fall back to ~/.ssh/id_* when a host uses a Keychain file-referenced key. Fixes #1614 Co-authored-by: Cursor <cursoragent@cursor.com> * Skip default-key primaries when explicit key config fails to load. Address Codex review: if identityFilePaths were set but loadFirstIdentityFileForAuth returns null, do not install ~/.ssh/id_* as the primary auth method. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
"use strict";
|
|
|
|
const test = require("node:test");
|
|
const assert = require("node:assert/strict");
|
|
|
|
const { hasUserConfiguredKey } = require("./sshAuthHelper.cjs");
|
|
|
|
test("hasUserConfiguredKey is true for inline private key material", () => {
|
|
assert.equal(hasUserConfiguredKey({ privateKey: "-----BEGIN OPENSSH PRIVATE KEY-----" }), true);
|
|
});
|
|
|
|
test("hasUserConfiguredKey is false for empty or whitespace inline keys", () => {
|
|
assert.equal(hasUserConfiguredKey({ privateKey: "" }), false);
|
|
assert.equal(hasUserConfiguredKey({ privateKey: " " }), false);
|
|
assert.equal(hasUserConfiguredKey({}), false);
|
|
});
|
|
|
|
test("hasUserConfiguredKey is true for Keychain reference identity file paths", () => {
|
|
assert.equal(
|
|
hasUserConfiguredKey({ identityFilePaths: ["/Users/alice/.ssh/id_ed25519"] }),
|
|
true,
|
|
);
|
|
});
|
|
|
|
test("hasUserConfiguredKey is false for empty identity file path lists", () => {
|
|
assert.equal(hasUserConfiguredKey({ identityFilePaths: [] }), false);
|
|
assert.equal(hasUserConfiguredKey({ identityFilePaths: null }), false);
|
|
});
|
|
|
|
test("hasUserConfiguredKey prefers explicit inline key over empty paths", () => {
|
|
assert.equal(
|
|
hasUserConfiguredKey({
|
|
privateKey: "-----BEGIN OPENSSH PRIVATE KEY-----",
|
|
identityFilePaths: [],
|
|
}),
|
|
true,
|
|
);
|
|
});
|