Files
orca/src/main/ipc/ssh-passphrase.test.ts
T
93d8b1f042 fix(ssh): complete keyboard-interactive MFA prompt handling (#15588)
Honor SSH keyboard-interactive prompt echo and empty responses, reuse login
passwords without replaying rejected values, and stop cancelled or stale
credential requests from continuing authentication or restoring the cache.

Original implementation: Junho Kim (#8750).
Port and follow-up work: Allen (#15588).

Verified with 2,773 SSH/credential tests, full typecheck, changed-code quality,
a production Electron build, real-socket MFA fixtures, and rendered UI checks.

Fixes #8622

Co-authored-by: Junho Kim <arkimjh@illinois.edu>
Co-authored-by: microdaery <microdaery@gapp.nthu.edu.tw>
2026-09-27 01:12:29 -07:00

41 lines
1.1 KiB
TypeScript

import type { BrowserWindow } from 'electron'
import { describe, expect, it, vi } from 'vitest'
import { requestCredential } from './ssh-passphrase'
vi.mock('electron', () => ({
ipcMain: {
handle: vi.fn(),
removeHandler: vi.fn()
}
}))
function credentialWindow() {
return {
isDestroyed: () => false,
webContents: { send: vi.fn() }
} as unknown as BrowserWindow
}
describe('SSH credential requests', () => {
it('resolves and removes the renderer prompt when its connection aborts', async () => {
const window = credentialWindow()
const controller = new AbortController()
const pending = requestCredential(
() => window,
'target-1',
'keyboard-interactive',
'Duo response',
undefined,
controller.signal
)
const request = vi.mocked(window.webContents.send).mock.calls[0][1] as { requestId: string }
controller.abort()
await expect(pending).resolves.toBeNull()
expect(window.webContents.send).toHaveBeenLastCalledWith('ssh:credential-resolved', {
requestId: request.requestId
})
})
})