Skip to content

test(matrix): deploy↔GitHub-link block integration tests (move exempt→mapped)#253

Merged
mastermanas805 merged 2 commits into
masterfrom
test/github-deploy-block-integration-2026-06-05
Jun 4, 2026
Merged

test(matrix): deploy↔GitHub-link block integration tests (move exempt→mapped)#253
mastermanas805 merged 2 commits into
masterfrom
test/github-deploy-block-integration-2026-06-05

Conversation

@mastermanas805

Copy link
Copy Markdown
Member

What

Closes the D17 / matrix-W6 deploy↔GitHub-link routes in the done-bar route-coverage guard's routeCoverageExemptions with a real DB-backed handler-integration suite, moving the three /api/v1/deployments/:id/github rows exempt → routeTestMap.

Routes moved exempt → mapped

Route Test
POST /api/v1/deployments/:id/github TestGitHubDeployBlock_Connect_OwnerHappyPath
GET /api/v1/deployments/:id/github TestGitHubDeployBlock_Get_ConnectedShape
DELETE /api/v1/deployments/:id/github TestGitHubDeployBlock_Disconnect_RemovesConnection

New suite

internal/handlers/github_deploy_block_integration_test.go — 15 TestGitHubDeployBlock_* tests driving each route through the production RequireAuth + PopulateTeamRole + RequireWritable chain (NewTestAppWithServices mirrors router.New) against a real Postgres (SetupTestDB). Reuses existing helpers (MustCreateTeamDB, MustSignSessionJWT, seedInternalDeploy, CreateUser, UniqueEmail) — none redefined.

Coverage:

  • Happy path (owner): connect 201 / get / disconnect
  • Authz model (these routes carry NO RequireRole — ownership is team-scoped):
    • owner 2xx, member-same-team allowed (proves no false owner-only gate)
    • non-member cross-team 404 (never 403 — no existence leak) on all three verbs
    • unauthenticated 401
  • Tier gate: anonymous 402 github_requires_paid_tier; hobby 201 (lowest paid tier that can deploy)
  • Contract: webhook_url + webhook_secret returned once (64-char hex); already_connected 409; invalid_repo 400; idempotent disconnect (200 deleted=false); not-connected 200 connected=false; encrypt-at-rest (stored secret is ciphertext, not plaintext); cross-team rejection leaves the owner's row intact; default branch → main.

Kept exempt (with sharpened justification)

The github-app integration rows (GET /integrations/github/{install,callback}, POST /webhooks/github, POST /webhooks/github/:webhook_id) stay exempt — they need a real GitHub App (OAuth install redirect, App-secret-HMAC callbacks/webhooks) and the per-connection receiver is HMAC-auth'd with no session chain to drive here; its signature/branch-match/rate-limit/idempotency internals are already covered by the whitebox suites (github_deploy_test.go, github_deploy_receive_arms_coverage_test.go).

Verification

  • Failing-then-passing: confirmed the done-bar guard reds without the covering test file and greens with it.
  • Both done-bar guards (TestDoneBar_EveryRouteCovered, TestDoneBar_TestMapPointsAtRealTests) GREEN; reverse-drift clean.
  • New suite: 15/15 pass against platform DB + Redis.
  • go build ./... + go vet ./... clean; touched files gofmt'd.
  • Full ./... local reds only on pre-existing env-absence flakes (customer-DB:5434, NATS, GitHub-App config) — identical failure set with my changes stashed, so this PR introduces zero regressions. CI authoritative.

🤖 Generated with Claude Code

…→mapped)

Close the D17 / matrix-W6 deploy↔GitHub-link routes in the done-bar
route-coverage guard's routeCoverageExemptions with a real DB-backed
handler-integration suite, moving the three /api/v1/deployments/:id/github
rows exempt → routeTestMap.

New suite (internal/handlers/github_deploy_block_integration_test.go,
TestGitHubDeployBlock_*, 15 tests) drives each route through the production
RequireAuth + PopulateTeamRole + RequireWritable chain
(NewTestAppWithServices mirrors router.New) against a real Postgres:

  POST   /api/v1/deployments/:id/github  → Connect
  GET    /api/v1/deployments/:id/github  → Get
  DELETE /api/v1/deployments/:id/github  → Disconnect

Coverage: happy path (owner), member-same-team allowed (no false owner-only
gate — these routes carry NO RequireRole), non-member cross-team 404 (never
403, no existence leak), unauth 401, tier gate (anonymous 402 /
hobby-allowed 201), contract (webhook_url + secret-once-64char,
already_connected 409, invalid_repo 400, idempotent disconnect,
not-connected 200, encrypt-at-rest ciphertext persisted).

The github-app integration rows (install/callback redirect, App-secret-HMAC
webhooks) and the per-connection PUBLIC receive endpoint
(/webhooks/github/:webhook_id, HMAC-auth'd, no session chain) stay exempt
with sharpened justifications — they need a real GitHub App and have no
RequireAuth chain to drive; the receiver's signature/branch/rate-limit/
idempotency internals are covered by the whitebox suites.

Both done-bar guards stay GREEN (failing-then-passing verified: the guard
reds without the covering tests). New gate-relevant tests pass; full ./...
local reds only on pre-existing env-absence flakes (customer-DB:5434, NATS,
GitHub-App config) — identical failure set with changes stashed, so this PR
introduces zero regressions. CI authoritative.

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