Account recovery acceptance against Cosmos¶
This exercises the packaged backend's real Cosmos stores, independently of mocked HTTP tests. See the journey verification record for results, session recovery for product rules, and the workspace protocol for Windows/WSL ownership.
Use a disposable emulator, a synthetic signing key, and synthetic players. Never point this
runner at production, import production player documents, or use the production signing key.
The runner creates the minigames database and seven containers using the partition paths in
tf/data/cosmos.tf. Each invocation creates unique synthetic players and Practice puzzles;
the synthetic Daily puzzle uses the current Pacific date. Remove the dedicated emulator when
acceptance is finished instead of retaining its test data.
Local container arrangement¶
Source edits and browser checks run in the active Windows worktree. Sync tracked sources to
the WSL mirror using the workspace protocol before Docker checks. Run all Docker commands
through wsl.exe -d Ubuntu-26.04 --exec from native PowerShell.
The tested arrangement is:
| Component | Container | Endpoint within their shared network namespace |
|---|---|---|
| Cosmos emulator | minigames-acct-cosmos-acceptance |
https://localhost:8081 |
| Exact backend image | minigames-acct-backend-db-acceptance |
http://localhost:8082 |
| Disposable Node runner | minigames-acct-db-runner |
Calls those two endpoints only |
The backend uses port 8082 because the emulator's own health service uses 8080. Publish only
loopback ports: 45236 to backend 8082 and, if needed, 48081 to Cosmos 8081. The emulator and
backend share a network namespace with --network container:minigames-acct-cosmos-acceptance.
Leave unrelated containers alone.
The verified emulator image is:
mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-latest@sha256:db53613dae19d0a3d5ad50688d14aa6e957af082dafea56b52e1bd3a6b3f1406
Start it with --protocol https --enable-telemetry false. Export its public root certificate
from /scripts/certs/rootCA.crt into the active Windows worktree's excluded
.local/account-db-acceptance/emulator-ca.crt. Generate a random 32-byte base64 signing key
locally and place only Cookie__SigningKey=<synthetic key> in the sibling synthetic.env.
Do not print or commit environment files. Copy only those two files explicitly to the mirror's
matching .local/ directory; ordinary source sync deliberately excludes .local/.
Run the backend with these settings:
ASPNETCORE_ENVIRONMENT=Development
ASPNETCORE_URLS=http://0.0.0.0:8082
Cosmos__AccountEndpoint=https://localhost:8081
Cosmos__UseEmulator=true
Supply synthetic.env with --env-file. Mount emulator-ca.crt read-only at
/usr/local/share/ca-certificates/acceptance-emulator.crt, then run
docker exec --user 0 minigames-acct-backend-db-acceptance update-ca-certificates once to
provision trust in that temporary container. The application retains its image's non-root user.
Override the health command to probe http://localhost:8082/health/live. Both /health/live
and /health/ready must return HTTP 200. Keep certificate verification enabled throughout.
Run the persistence checks¶
From native PowerShell, after the setup above:
wsl.exe -d Ubuntu-26.04 --exec docker run --rm --name minigames-acct-db-runner --network container:minigames-acct-cosmos-acceptance --env-file /home/justin/repos/minigames/.local/account-db-acceptance/synthetic.env -e NODE_EXTRA_CA_CERTS=/work/emulator-ca.crt -e ACCOUNT_RECOVERY_ACCEPTANCE=isolated-emulator --mount type=bind,src=/home/justin/repos/minigames/.local/account-db-acceptance,dst=/work,readonly --mount type=bind,src=/home/justin/repos/minigames/scripts/verify-account-recovery-emulator.mjs,dst=/verify.mjs,readonly node:24-alpine@sha256:a0b9bf06e4e6193cf7a0f58816cc935ff8c2a908f81e6f1a95432d679c54fbfd node /verify.mjs
The runner uses Node built-ins, requires explicit emulator acknowledgement, refuses redirects, and bounds each request to 30 seconds. A failure exits nonzero. It checks:
- Missing Letter Golf progress is distinct from a request failure; saved words survive renewal.
- Expired signed sessions cannot mutate either game's persisted play, including its ETag.
- Different players cannot restore one another's progress; expected-player mismatch is explicit.
- Reverse Cross revisions, replayed saves, and conflicting saves follow the API contract.
- Reverse Cross completion retries preserve server-owned duration and completion identity.
- A Daily completion contributes one start/completion and one streak day; retries preserve stats.
- Late writes cannot overwrite completed Reverse Cross or seeded-completed Letter Golf Dailies.
Do not run it repeatedly within the gameplay rate-limit window: it intentionally respects the unchanged 20-request-per-minute policy and treats HTTP 429 as a failure. Allow the window to clear before repeating. Practice completion repair may create an empty player profile; the check asserts that Practice does not contribute eligible stats.
Boundaries and cleanup¶
The runner signs synthetic sessions to exercise persistence boundaries. It does not prove fresh Google authentication or the OIDC prepare/commit ownership handoff. The vNext emulator also does not enforce Cosmos authentication; it cannot prove Azure managed identity/RBAC, production indexing, capacity, or RU behavior. See the official emulator limitations.
Actual Google acceptance uses the configured provider and a controlled test browser separately. Keep provider credentials, cookies, account identifiers, and logs out of tracked fixtures. When that acceptance no longer needs these containers, remove only the dedicated backend and emulator: