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.
109 lines
3.9 KiB
TypeScript
109 lines
3.9 KiB
TypeScript
import { test, expect } from "../../fixtures/ssh-test-base";
|
||
import { startBastionAndTarget, stopBastionAndTarget } from "../../helpers/ssh-bastion";
|
||
import path from "node:path";
|
||
|
||
/**
|
||
* ProxyJump end-to-end: two-container topology where target is only
|
||
* reachable from inside the bastion's Docker network. A successful test
|
||
* against `target` MUST have traversed the bastion. Chained ProxyJump
|
||
* (a -> b -> target) is out of v1 scope; we assert it fails clearly.
|
||
*
|
||
* Covers e2e-plan.md group N (N1–N3). Bastion topology is set up per-test
|
||
* because it's heavier than the default fixture's single-sshd model.
|
||
*/
|
||
test.describe("ssh executor — ProxyJump", () => {
|
||
test("direct connect (no ProxyJump) succeeds against the bastion's own port", async ({
|
||
apiClient,
|
||
backend,
|
||
}, testInfo) => {
|
||
test.setTimeout(180_000);
|
||
const bastion = startBastionAndTarget(
|
||
testInfo.workerIndex,
|
||
path.join(backend.tmpDir, "ssh-bastion-direct"),
|
||
);
|
||
try {
|
||
const result = await apiClient.testSSHConnection({
|
||
name: "N0 direct",
|
||
host: bastion.bastion.host,
|
||
port: bastion.bastion.port,
|
||
user: bastion.bastion.user,
|
||
identity_source: "file",
|
||
identity_file: bastion.bastion.identityFile,
|
||
});
|
||
expect(result.success).toBe(true);
|
||
} finally {
|
||
stopBastionAndTarget(bastion);
|
||
}
|
||
});
|
||
|
||
test("ProxyJump through bastion reaches the otherwise-unreachable target", async ({
|
||
apiClient,
|
||
backend,
|
||
}, testInfo) => {
|
||
test.setTimeout(240_000);
|
||
const handles = startBastionAndTarget(
|
||
testInfo.workerIndex,
|
||
path.join(backend.tmpDir, "ssh-bastion-jump"),
|
||
);
|
||
try {
|
||
// Without ProxyJump, target should be unreachable from the host.
|
||
const direct = await apiClient.testSSHConnection({
|
||
name: "N1 direct (should fail)",
|
||
host: handles.targetInternalHost,
|
||
port: 22,
|
||
user: handles.target.user,
|
||
identity_source: "file",
|
||
identity_file: handles.target.identityFile,
|
||
});
|
||
expect(direct.success).toBe(false);
|
||
|
||
// With ProxyJump set to the bastion, target should be reachable.
|
||
// Note: the SSH executor parses ProxyJump as a host:port string. The
|
||
// bastion is reachable from the host on 127.0.0.1:<bastionPort>.
|
||
const viaJump = await apiClient.testSSHConnection({
|
||
name: "N1 via jump",
|
||
host: handles.targetInternalHost,
|
||
port: 22,
|
||
user: handles.target.user,
|
||
identity_source: "file",
|
||
identity_file: handles.target.identityFile,
|
||
proxy_jump: `${handles.bastion.user}@${handles.bastion.host}:${handles.bastion.port}`,
|
||
});
|
||
expect(viaJump.success).toBe(true);
|
||
expect(viaJump.fingerprint).toBe(handles.target.hostFingerprint);
|
||
} finally {
|
||
stopBastionAndTarget(handles);
|
||
}
|
||
});
|
||
|
||
test("chained ProxyJump (a -> b -> target) fails with a clear error", async ({
|
||
apiClient,
|
||
backend,
|
||
}, testInfo) => {
|
||
test.setTimeout(180_000);
|
||
const handles = startBastionAndTarget(
|
||
testInfo.workerIndex,
|
||
path.join(backend.tmpDir, "ssh-bastion-chained"),
|
||
);
|
||
try {
|
||
// Comma-separated chained ProxyJump is intentionally unsupported in
|
||
// v1. The first hop will accept, the second hop should fail because
|
||
// ResolveSSHTarget treats the value as a single bastion identifier.
|
||
const result = await apiClient.testSSHConnection({
|
||
name: "N3 chained",
|
||
host: handles.targetInternalHost,
|
||
port: 22,
|
||
user: handles.target.user,
|
||
identity_source: "file",
|
||
identity_file: handles.target.identityFile,
|
||
proxy_jump: `${handles.bastion.user}@${handles.bastion.host}:${handles.bastion.port},another-hop`,
|
||
});
|
||
expect(result.success).toBe(false);
|
||
const handshake = result.steps.find((s) => s.name === "SSH handshake");
|
||
expect(handshake?.error).toMatch(/bastion|resolve|connect|chain/i);
|
||
} finally {
|
||
stopBastionAndTarget(handles);
|
||
}
|
||
});
|
||
});
|