Skip to content

test(matrix): W4 deploy-approval block integration suite (move exempt→mapped)#254

Merged
mastermanas805 merged 1 commit into
masterfrom
test/deploy-approval-integration-2026-06-05
Jun 5, 2026
Merged

test(matrix): W4 deploy-approval block integration suite (move exempt→mapped)#254
mastermanas805 merged 1 commit into
masterfrom
test/deploy-approval-integration-2026-06-05

Conversation

@mastermanas805

Copy link
Copy Markdown
Member

What

Closes the deploy-approval route on the done-bar route-coverage tail (USER-FLOW-INVENTORY §W4). GET /approve/:token was in routeCoverageExemptions with no mapped test; this adds a DB-backed handler-integration suite and moves it routeCoverageExemptions → routeTestMap.

The route + contract (read from internal/handlers/promote_approval.go)

GET /approve/:token is the public email-link approval landing for non-dev env promotes. The 32-byte random token IS the credential — no auth chain (wired in router.go above the /api/v1 RequireAuth group), so the email URL works for an anonymous click. The handler renders HTML / redirects across four token branches + a per-IP rate limit.

Tests (internal/handlers/approve_block_{helpers,routes}_test.go, package handlers_test)

approveBlockApp mirrors the production wiring (app.Get("/approve/:token", NewPromoteApprovalHandler(db, rdb).Approve)) against a real migrated Postgres (testhelpers.SetupTestDB) + miniredis. Coverage:

  • TestApproveBlock_ValidPendingToken — valid pending token → 302 to dashboard/<id>?approved=1 and the row is PERSISTED as approved (source-of-truth state change); single-use second click → 410 already-used.
  • TestApproveBlock_NonPendingToken — approved/rejected/executed token → 410 already-used, no state change.
  • TestApproveBlock_ExpiredToken — past-expiry pending token → 410 + row flipped to expired.
  • TestApproveBlock_InvalidToken — unknown token → 404 invalid (no probing oracle).
  • TestApproveBlock_RateLimit — per-IP/sec burst → 429.

All helpers reuse existing seams (miniRedis, models.CreatePromoteApproval, testhelpers.SetupTestDB) — no redefinitions. All changes are _test.go files (no production code).

Done-bar

Both guards green: route mapped to TestApproveBlock_ValidPendingToken, test name resolves via the AST scan, no stale rows. Rebased on origin/master (#253 deploy↔GitHub-link merge) — both sets of moves kept.

Gate

internal/router + the new TestApproveBlock_* suite green. Full ./... reds only on the documented pre-existing local flakes (internal/models TestGetExpiredDeployments/TestLinkGitHubID; internal/handlers TestQueue_* NATS-dependent 503) — verified identical on clean origin/master with files stashed. CI authoritative.

🤖 Generated with Claude Code

…→mapped)

Covers the public email-link approval landing GET /approve/:token
(USER-FLOW-INVENTORY §W4), which was in routeCoverageExemptions with no
mapped test. New DB-backed handler-integration suite in package
handlers_test drives the route through the production wiring
(approveBlockApp mirrors router.go's
app.Get("/approve/:token", NewPromoteApprovalHandler(db, rdb).Approve))
against a real migrated Postgres + miniredis, asserting the real contract
(read from promote_approval.go):

  - valid pending token → 302 to dashboard ?approved=1 + row PERSISTED
    'approved' (source-of-truth state change)
  - single-use: second click on an approved token → 410 already-used
  - already-resolved (approved/rejected/executed) → 410, no state change
  - past-expiry pending token → 410 + row flipped to 'expired'
  - unknown token → 404 invalid (no probing oracle)
  - per-IP/sec rate-limit burst → 429

The route is public — the 32-byte token IS the credential, no auth chain
(matches router.go wiring above the /api/v1 RequireAuth group), so the
suite tests the token paths, not a session JWT.

Done-bar guard: GET /approve/:token moves routeCoverageExemptions →
routeTestMap (TestApproveBlock_ValidPendingToken). Both done-bar guards
stay green (route mapped, test name resolves via AST scan, no stale rows).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mastermanas805 mastermanas805 enabled auto-merge (squash) June 4, 2026 23:58
@mastermanas805 mastermanas805 merged commit 4dfd318 into master Jun 5, 2026
18 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