Skip to content

feat(e2e): guarded ephemeral test-account API (CI mints accounts to test vs prod)#260

Merged
mastermanas805 merged 3 commits into
masterfrom
feat/e2e-ephemeral-account-clean
Jun 5, 2026
Merged

feat(e2e): guarded ephemeral test-account API (CI mints accounts to test vs prod)#260
mastermanas805 merged 3 commits into
masterfrom
feat/e2e-ephemeral-account-clean

Conversation

@mastermanas805

Copy link
Copy Markdown
Member

Enables CI to mint a real ephemeral test account on prod per run → run the real-backend integration suite → reap. Inert by default (no E2E_ACCOUNT_TOKEN = endpoints 404). is_test_cohort-scoped (live skip-guards neuter billing/churn/email; reap can never touch a real team → 403); never team-tier. Constant-time token guard, rate-limited, audit-logged. Critical safety test: TestE2EAccount_Reap_NonCohortTeam_Forbidden. Foundation for the prod-CI integration-test goal.

🤖 Generated with Claude Code

…s vs prod

POST/DELETE /internal/e2e/account — lets CI mint a real ephemeral test account
on prod per run, exercise integration flows, then reap. Security:
- X-E2E-Token constant-time guard; unset/wrong token → 404 (inert + no existence
  leak). Ships INERT (no E2E_ACCOUNT_TOKEN config = off by default).
- Create makes an is_test_cohort=true team+user (live worker skip-guards neuter
  billing/churn/email/quota), tier ≤ pro — team/growth rejected 400 (Team gated).
  Returns a JWT_SECRET-signed session JWT (no Brevo dependency).
- Reap ONLY deletes is_test_cohort teams — a real team → 403 not_test_cohort
  (the load-bearing safety test: TestE2EAccount_Reap_NonCohortTeam_Forbidden).
- Rate-limited (fail-open), audit-logged (e2e.account.created/reaped),
  metric instant_e2e_account_total{op,result}.

Foundation for running the real-backend integration suite against production
in CI with on-the-fly accounts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mastermanas805 mastermanas805 enabled auto-merge (squash) June 5, 2026 03:41
mastermanas805 and others added 2 commits June 5, 2026 09:52
…+ cover model reap/purge branches

Fixes the CI failures from #260's guarded /internal/e2e/account endpoint
(endpoint + handler tests were correct; only the cross-cutting registries
and a few uncovered model error-branches were missing):

1. codeToAgentAction (helpers.go): add operator-facing agent_action for the
   6 new error codes — not_test_cohort, rand_failed, team_create_failed,
   tier_not_allowed, tier_set_failed, user_create_failed. Fixes
   TestErrorCode_HasAgentAction.
2. auditConsumerSpec (reliability_contract_test.go): register e2e.account.created
   + e2e.account.reaped as IntentionallyNoConsumer (operator-internal, never
   customer-facing). Fixes TestReliability_AuditKinds_EveryConstantHasConsumerSpec.
3. openapi_test.go intentionallyHidden: exempt POST /internal/e2e/account +
   DELETE /internal/e2e/account/{team_id} (CI-only, guarded; mirrors the other
   /internal worker routes). Fixes TestOpenAPI_CoversAllRegisteredRoutes.
4. route_donebar_guard routeTestMap: map the 2 routes to their existing covering
   handler-integration tests (create→MintsTestCohortAndAuthenticatingJWT,
   delete→Reap_TestCohortTeam_Purged). Fixes TestDoneBar_EveryRouteCovered;
   keeps TestDoneBar_TestMapPointsAtRealTests green.
5. e2e_account_errbranches_test.go: white-box sqlmock coverage for the DB-error
   branches of CreateTestCohortTeam, DeleteTeamHard, and MarkTeamResourcesForReaper
   (resource.go 587-592, team.go 414-442) — 100% of the changed lines, satisfying
   the patch-coverage gate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…track dump.rdb

The e2e-account error codes (not_test_cohort, team_create_failed,
user_create_failed, tier_not_allowed, tier_set_failed, rand_failed) are
operator/CI-only — emitted only on the guarded /internal/e2e/account surface
that is inert by default (404 unless E2E_ACCOUNT_TOKEN is set) and driven by
the machine-to-machine E2E harness, never a customer agent.

They were previously added to codeToAgentAction with operator-facing copy,
which violated the customer-facing agent_action contract (TestAgentActionContract
requires every entry to start "Tell the user ..." and carry a customer recovery
URL). Move them to error_envelope_coverage_test.go's coverageAllowlist with a
per-code rationale instead: the 503 arms fall back to AgentActionContactSupport
via respondError's status>=500 path; the 4xx arms (400/403/429) carry a
self-explanatory message with no agent_action, which is correct for a CI caller.

Also untrack dump.rdb (local Redis artifact accidentally committed) and add it
to .gitignore.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mastermanas805 mastermanas805 merged commit 5a62f44 into master Jun 5, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant