fix: preserve case-sensitive SSH usernames in host picker

This commit is contained in:
vam
2026-10-21 17:37:11 +08:00
parent 792ff604f5
commit 8daf21370b
4 changed files with 17 additions and 4 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ Orca can drive agents on remote machines over SSH — useful for long-running bu
Dirty add/edit forms ignore outside clicks so an accidental click away does not discard your fields; use Escape, Cancel, or × to discard.
The OpenSSH config picker's **In Orca** badge also recognizes a saved target with the same configured hostname, port, and user, even when its label differs from the config alias. A different port or user remains a separate target; entries without `HostName` are matched by alias only.
The OpenSSH config picker's **In Orca** badge also recognizes a saved target with the same configured hostname, port, and user, even when its label differs from the config alias. Hostnames are compared case-insensitively, but SSH usernames preserve case. A different port or user remains a separate target; entries without `HostName` are matched by alias only.
## Host key verification
@@ -77,6 +77,16 @@ describe('SSH config host picker search', () => {
expect(result.newHostCount).toBe(0)
})
it('keeps case-distinct SSH users on the same machine separate', () => {
const result = searchSshConfigHosts(
[{ host: 'admin-account', hostname: 'BOX', user: 'Admin' }],
[{ configHost: 'saved-account', label: 'Saved', host: 'box', port: 22, username: 'admin' }]
)
expect(result.hosts[0]).toMatchObject({ alias: 'admin-account', alreadyInOrca: false })
expect(result.newHostCount).toBe(1)
})
it('leaves a different machine unflagged', () => {
const result = searchSshConfigHosts(
[{ host: 'aimp', hostname: '172.16.203.131', user: 'chanmuzi' }],
+5 -2
View File
@@ -30,8 +30,11 @@ describe('sshEndpointIdentity', () => {
)
})
it('folds host and user case but keeps a different user distinct', () => {
expect(sshEndpointIdentity({ host: 'BOX', port: 22, username: 'Me' })).toBe(
it('folds hostname case but preserves case-sensitive SSH usernames', () => {
expect(sshEndpointIdentity({ host: 'BOX', port: 22, username: 'me' })).toBe(
sshEndpointIdentity({ host: 'box', port: 22, username: 'me' })
)
expect(sshEndpointIdentity({ host: 'box', port: 22, username: 'Me' })).not.toBe(
sshEndpointIdentity({ host: 'box', port: 22, username: 'me' })
)
expect(sshEndpointIdentity({ host: 'box', port: 22, username: 'me' })).not.toBe(
+1 -1
View File
@@ -25,5 +25,5 @@ export function sshEndpointIdentity(target: {
target.port <= 65_535
? target.port
: 22
return `${host}\u0000${port}\u0000${target.username?.trim().toLowerCase() ?? ''}`
return `${host}\u0000${port}\u0000${target.username?.trim() ?? ''}`
}