c5d678a37a
Every spec drives the real sshd container set up by the ssh-test-base fixture; no mocks. Specs are grouped by concern (file per group), mirroring the docker/ directory style. Each one maps 1:1 to a row in docs/specs/ssh-executor/e2e-plan.md. UI surface: - connection-form.spec.ts — field rendering, save/test gating, identity-source toggle, default port. - test-result.spec.ts — successful + failed Test Connection paths, per-step badges, fingerprint surfacing, cached/will-upload copy. - trust-gate.spec.ts — save disabled until trust ticked, edits reset result + trust, fingerprint-change warning when pinned != observed. - sessions-card.spec.ts — empty state, row rendering, manual refresh, status badges, truncation, polling pickup. - persistence.spec.ts — fingerprint persists across reload, new form starts blank, executor list label, partial state doesn't leak. API contract: - test-endpoint.spec.ts — POST /api/v1/ssh/test step ordering, invalid body, host-required, handshake short-circuit, cached/uploaded states. - sessions-endpoint.spec.ts — GET /api/v1/ssh/executors/:id/sessions filters to ssh-runtime rows, populates metadata, monotonic uptime. - executor-crud.spec.ts — type=ssh persists fingerprint, profile workdir round-trip, edit-with-running-sessions keeps snapshots. Real-SSH integration: - launch-task.spec.ts — full smoke: agentctl upload + sha256 cache hit on second launch, task/session dir layout, stop cleans session dir. - recovery.spec.ts — backend restart reconnects, dead pid surfaces failure, persisted metadata keys present. - auth-methods.spec.ts — key + valid, missing key, passphrase-protected rejection, agent without SSH_AUTH_SOCK, wrong-key auth failure. - concurrency.spec.ts — two sessions share task dir distinct ports, two tasks distinct dirs, traffic drop + restore exercises eviction + reconnect. - hostkey-rotation.spec.ts — regenerate host key surfaces new fingerprint, stale pinned fingerprint blocks launch verbatim, re-trust restores function. - config-inheritance.spec.ts — ~/.ssh/config HostName / Port / IdentityFile / ProxyJump inheritance with form-overrides-config rules. - workdir-per-profile.spec.ts — per-profile ssh_workdir_root routes to separate remote workdir trees; default falls back to ~/.kandev. - proxy-jump.spec.ts — 2-container bastion topology asserts target is unreachable directly, reachable via ProxyJump, chained ProxyJump fails. - error-surfacing.spec.ts — TCP refused, auth failed, bastion unreachable surface verbatim; backend 400 stays a 400 not a synthesised failure. Also adds an AGENTS.md (CLAUDE.md symlink) line pointing at the e2e/README.md so future agents discover the containers project + KANDEV_E2E_CONTAINERS env var without grepping playwright.config.ts.
98 lines
3.5 KiB
TypeScript
98 lines
3.5 KiB
TypeScript
import { test, expect } from "../../fixtures/ssh-test-base";
|
||
import { SSHSettingsPage } from "../../pages/SSHSettingsPage";
|
||
|
||
/**
|
||
* The defining UX guarantee of the SSH executor: Save is locked until the
|
||
* user explicitly trusts the fingerprint they just observed, editing any
|
||
* field that could reach a different machine resets that trust, and
|
||
* fingerprint-change between trust and save is called out in the UI.
|
||
*
|
||
* Covers e2e-plan.md group C (C1–C7).
|
||
*/
|
||
test.describe("ssh trust gate", () => {
|
||
test("save disabled until trust ticked even after a successful test", async ({
|
||
testPage,
|
||
seedData,
|
||
}) => {
|
||
const page = new SSHSettingsPage(testPage);
|
||
await page.gotoNew();
|
||
await page.fillForm({
|
||
name: "C1",
|
||
host: seedData.sshTarget.host,
|
||
port: seedData.sshTarget.port,
|
||
user: seedData.sshTarget.user,
|
||
identitySource: "file",
|
||
identityFile: seedData.sshTarget.identityFile,
|
||
});
|
||
await page.clickTest();
|
||
await page.waitForTestResult();
|
||
await expect(page.saveButton).toBeDisabled();
|
||
await page.tickTrust();
|
||
await expect(page.saveButton).toBeEnabled();
|
||
});
|
||
|
||
for (const field of [
|
||
{ name: "host", apply: (p: SSHSettingsPage) => p.fillForm({ host: "other.example.com" }) },
|
||
{ name: "port", apply: (p: SSHSettingsPage) => p.fillForm({ port: 2222 }) },
|
||
{ name: "user", apply: (p: SSHSettingsPage) => p.fillForm({ user: "root" }) },
|
||
{
|
||
name: "identity_source",
|
||
apply: (p: SSHSettingsPage) => p.fillForm({ identitySource: "agent" }),
|
||
},
|
||
]) {
|
||
test(`editing ${field.name} after a test clears the result and unticks trust`, async ({
|
||
testPage,
|
||
seedData,
|
||
}) => {
|
||
const page = new SSHSettingsPage(testPage);
|
||
await page.gotoNew();
|
||
await page.fillForm({
|
||
name: `C-edit-${field.name}`,
|
||
host: seedData.sshTarget.host,
|
||
port: seedData.sshTarget.port,
|
||
user: seedData.sshTarget.user,
|
||
identitySource: "file",
|
||
identityFile: seedData.sshTarget.identityFile,
|
||
});
|
||
await page.clickTest();
|
||
await page.waitForTestResult();
|
||
await page.tickTrust();
|
||
await expect(page.saveButton).toBeEnabled();
|
||
|
||
await field.apply(page);
|
||
await expect(page.saveButton).toBeDisabled();
|
||
await expect(page.trustCheckbox).not.toBeChecked();
|
||
});
|
||
}
|
||
|
||
// C7 — fingerprint-change warning when re-testing with already-pinned
|
||
// fingerprint differing from the new one. We simulate by editing the
|
||
// executor's pinned fingerprint via the API and reloading the form.
|
||
test("fingerprint-change warning surfaces when observed fingerprint differs from pinned", async ({
|
||
testPage,
|
||
apiClient,
|
||
seedData,
|
||
}) => {
|
||
// Set a wrong fingerprint on the seeded executor.
|
||
await apiClient.updateExecutor(seedData.sshExecutorId, {
|
||
config: {
|
||
ssh_host: seedData.sshTarget.host,
|
||
ssh_port: String(seedData.sshTarget.port),
|
||
ssh_user: seedData.sshTarget.user,
|
||
ssh_identity_source: "file",
|
||
ssh_identity_file: seedData.sshTarget.identityFile,
|
||
ssh_host_fingerprint: "SHA256:wrong-fingerprint-on-purpose",
|
||
},
|
||
});
|
||
|
||
const page = new SSHSettingsPage(testPage);
|
||
await page.gotoExisting(seedData.sshExecutorId);
|
||
await expect(page.pinnedFingerprint()).toHaveText("SHA256:wrong-fingerprint-on-purpose");
|
||
|
||
await page.clickTest();
|
||
await page.waitForTestResult();
|
||
await expect(page.fingerprintChangeWarning()).toBeVisible();
|
||
await expect(page.observedFingerprint()).toHaveText(seedData.sshTarget.hostFingerprint);
|
||
});
|
||
});
|