Files
orca/src/main/ipc/ssh-host-server-decision-failure.test.ts
T
ff27338299 refactor(ssh): connect fails for hosts orcad can't serve; remove the relay client path (#27214)
* wip: connect fails for hosts the managed server can't serve; remove relay session, deploy and relay UI

* wip: delete relay-only client modules left unreachable, prune their tests and gates

* wip: format

* wip: exhaustive unserved message

* wip: drop relay attestation test for the deleted ownership proof

* fix: prune stale baselines; type the test transport stub

* fix(ssh): census proves leftover relay leases; name the remedy for older terminals; translate every connect-failure surface

* test(ssh): leftover leases defer to the host census

* test(e2e): remove relay-path SSH e2e specs and their CI lanes

* test(e2e): drop the auto-convert case that built its relay era through a live relay

* test(e2e): mark relay-era browser and catalog journeys fixme until they seed a profile

* test(e2e): seed relay-era browser and catalog journeys from a saved profile

The three journeys built their old-version state through a connect without an orcad template, which now refuses the host. They now start from a seeded relay-era profile, so the first connect converts the host as an upgrading user's would.

* chore(ci): drop shard timings for the deleted relay tests

* test(e2e): carry a relay-era login cookie across the browser conversion; own every launch

* test(ci): drop the deleted SSH layout oracle from its route

* test(e2e): open the retained browser after conversion, retrying a pre-connect card

* test(e2e): bind the relay-era browser partition before seeding its cookie

A relay-era build always recorded the partition binding before a page stored
data in it. Seeding the cookie into an unbound partition made the binding store
refuse it (browser_route_partition_binding_store_invalid), so the retained tab
showed the generic routing card and Retry could never clear it.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: m4air <m4air@Mac.localdomain>
Co-authored-by: Claude <noreply@anthropic.com>
2026-10-10 22:10:33 -07:00

57 lines
2.2 KiB
TypeScript

import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { SshTarget } from '../../shared/ssh-types'
const mocks = vi.hoisted(() => ({
getTarget: vi.fn(),
resolve: vi.fn()
}))
vi.mock('../../shared/app-environment', () => ({
getAppEnvironment: () => ({ getPath: () => '/tmp/user-data', getVersion: () => '1.5.0' })
}))
vi.mock('../ssh/ssh-target-registry', () => ({
getSshTargetRegistryStore: () => ({ getTarget: mocks.getTarget })
}))
vi.mock('../ssh/ssh-host-server-on-connect', () => ({
resolveHostServerOnConnect: mocks.resolve
}))
vi.mock('./ssh-host-server-on-connect-wiring', () => ({ hostServerOnConnectDeps: () => ({}) }))
vi.mock('./ssh-ipc-context', () => ({ connectionManager: null, getCurrentMainWindow: () => null }))
vi.mock('./ssh-renderer-broadcast', () => ({
broadcastSshState: vi.fn(),
clearRelayStateOverride: vi.fn(),
getPublicSshState: vi.fn()
}))
const { decideHostServer, publishHostServerDecisionFailure } =
await import('./ssh-host-server-connect')
const { broadcastSshState } = await import('./ssh-renderer-broadcast')
const { getSshHostServerStatus, setSshHostServerStatus } =
await import('../ssh/ssh-host-server-status')
const target: SshTarget = { id: 'ssh-1', label: 'Box', host: 'box', port: 22, username: 'me' }
const fenced: SshTarget = {
...target,
orcadFence: { environmentId: 'env-1' }
}
beforeEach(() => vi.clearAllMocks())
describe('a managed-server decision that fails', () => {
it('surfaces the real error on a host only its managed server can reach', async () => {
mocks.getTarget.mockReturnValue(fenced)
const auth = new Error('All configured authentication methods failed')
mocks.resolve.mockRejectedValue(auth)
await expect(decideHostServer(target)).rejects.toBe(auth)
})
it('replaces a stuck setting-up status with the error once setup fails', () => {
setSshHostServerStatus('ssh-1', { kind: 'setting-up', phase: 'connecting' })
publishHostServerDecisionFailure('ssh-1', new Error('listen EADDRINUSE'))
expect(getSshHostServerStatus('ssh-1')).toBeUndefined()
expect(vi.mocked(broadcastSshState).mock.calls.at(-1)?.[2]).toMatchObject({
status: 'error',
error: 'listen EADDRINUSE'
})
})
})