Run M1's end-to-end slice, and fix the two bugs it found

The whole vertical slice now runs against a real Keycloak, a real API, a
real PostgreSQL and a real sshd: sign in through the browser flow, enroll
with the identity-provider key binding, unlock, create a host, sync it,
read it back on a second machine, unlock again with no network, accept an
unseen host key, and open an interactive shell. Opt-in, because it needs
the development stack; skipped with a message naming the commands.

It found two bugs on its first run, and both are the same class: two
sides of a stub agreeing with each other about something the
specification never said.

**The API never applied DodoSshJsonContext to its HTTP JSON options.**
Minimal APIs therefore used the framework's web defaults, which write an
enum as a number. Every request DTO carrying one failed to bind against a
client writing the specified string form — which is the entire sync
surface, unreachable from the real client, with a 400 naming only the
parameter. The documented guarantee that request bodies reject unmapped
members was likewise not in effect anywhere.

Nothing caught it because the API tests posted with PostAsJsonAsync's
defaults, so they and the server had independently settled on integers.
Those tests now serialise through the contract, which is the deeper fix:
removing the new configuration fails 13 of them. Copying settings into
options a host owns is itself the hazard the context warns about, so
ApplyTo lives beside the settings it mirrors and ApplyToTests pins the
transformation, including that inserting the resolver leaves the caller's
own in place.

**The realm registered a loopback redirect URI Keycloak rejects.**
`http://127.0.0.1:*/callback` looks more explicit than the RFC 8252 form
and is broken: Keycloak's wildcards are trailing-only, so the `*` parses
as a literal port and every authorization request came back "Invalid
parameter: redirect_uri". Providers ignore the port for loopback hosts,
which is the whole mechanism, so the correct registration is
`http://127.0.0.1/callback` — path pinned, port free. The value the
server advertises through the discovery document said the same wrong
thing and now says the right one.

Two smaller things, both documented in docs/platform-flags.md:

- --import-realm skips a realm that already exists, so editing the realm
  file and restarting Keycloak changes nothing and serves stale
  configuration. The container has to be recreated. The compose comment
  claimed the opposite.
- Keycloak marks its session cookies Secure even over plain HTTP, because
  SameSite=None requires it. A spec-conformant client drops them and the
  login POST answers 400 with no message; browsers complete the flow only
  because they exempt loopback. Harmless for the product, fatal for
  automation, so ScriptedBrowser carries the cookies by hand and says why.

Also: the server enforces a 64 MiB floor on the passphrase KDF, so this
suite cannot use the 8 MiB profile the other client suites take for
speed. Those only get away with it because their in-memory servers have
no policy — worth knowing rather than rediscovering.

638 tests. The solution-wide run stays green with the stack down: exit
code 8 means "no tests ran", which the platform reports as failure, so
the opt-in project ignores exactly that code.
This commit is contained in:
2026-07-29 11:37:49 +02:00
parent 49f617b450
commit 1d262b7ccc
20 changed files with 1801 additions and 97 deletions
+33 -2
View File
@@ -83,6 +83,35 @@ dotnet run --project src/DodoSSH.Api
It listens on `http://localhost:5233`, serving `/healthz/live`, `/healthz/ready` and — in
Development — `/openapi/v1.json`.
### End-to-end verification
One suite runs against a real server rather than a stub, and it is opt-in because it needs the stack:
```bash
docker compose -f deploy/docker-compose.dev.yml up -d
```
```bash
dotnet ef database update --project src/DodoSSH.Infrastructure
```
```bash
dotnet run --project src/DodoSSH.Api
```
```bash
DODOSSH_E2E=1 dotnet test tests/DodoSSH.SystemTests
```
It signs in through a real Keycloak, enrolls, unlocks, creates a host, syncs it, reads it back on a second
simulated machine, unlocks again with no network, and opens a shell on a real `sshd`. Skipped otherwise,
with a message naming the commands above.
It is worth its weight: on its first run it found a loopback redirect URI the realm registered in a form
Keycloak rejects, and a JSON configuration gap that made the whole sync surface unreachable from the real
client while every other test passed. Both are the same class of bug — two sides of a stub agreeing with
each other about something the specification never said.
Development and testing are currently **Windows-only**. Anything known or suspected to differ on
Linux and macOS is tracked in [`docs/platform-flags.md`](docs/platform-flags.md), along with the
deployment gotchas that have already cost time once. Read it before assuming something works
@@ -110,8 +139,10 @@ off-Windows.
vault-backed: server URL → browser sign-in → enroll → unlock → host list → terminal. The shell's whole
path is covered by tests against an in-memory server, so the states that matter most (the recovery code
that cannot be skipped, the unlock that needs no network) are checked rather than remembered.
*Remaining:* the manual end-to-end run against the real API and a real Keycloak from
`deploy/docker-compose.dev.yml`, which is what M1's definition of done actually asks for.
*Verified end to end:* `tests/DodoSSH.SystemTests` drives the whole slice against a real Keycloak, a
real API, a real PostgreSQL and a real `sshd` — sign-in, the identity-provider key binding, enrollment,
offline unlock, a host through the vault to a second machine, and an interactive shell. See
[End-to-end verification](#end-to-end-verification).
Known gaps in the client, stated rather than implied by the interface: credentials are not a synced
entity type yet, so a connection still asks for a password; known host keys live in memory for one