test(matrix): W3 billing/api-keys/audit route coverage (move exempt→mapped)#257
Merged
mastermanas805 merged 1 commit intoJun 5, 2026
Conversation
…apped)
Closes the 10 billing/api-keys/audit routes in the done-bar route guard's
routeCoverageExemptions, moving them to routeTestMap pointed at real DB-backed
handler-integration tests:
- billing invoices/update-payment/change-plan → billing_portal_arms_bvwave
(fake BillingPortal seam; success arm = valid hobby→pro; no-downgrade policy
pinned by the W3 billing-block suite). Real Razorpay leg deferred to e2e.
- billing/usage → new TestBAAUsage_* (production RequireAuth chain, real PG)
- promotion/validate → TestValidatePromotion_ValidCode_ReturnsDiscount
- api-keys create/list/revoke → TestAPIKeys_CreateListRevoke_HappyPath
- audit read + CSV → TestAudit_HappyPath / TestAuditCSV_Shape
Adds billing_apikeys_audit_block_integration_test.go: a production-auth-chain
layer (RequireAuth + PopulateTeamRole + RequireWritable, real session JWTs +
real Postgres/Redis) covering the gaps the existing suites left — api-keys +
billing/usage cross-team isolation, non-owner-member authz, and unauth 401.
Both done-bar guards stay green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes the billing / api-keys / audit triage in the done-bar route guard (
internal/router/route_donebar_guard_test.go): 10 routes move fromrouteCoverageExemptions→routeTestMap, each pointed at a real DB-backed handler-integration test.GET /api/v1/billing/invoicesTestBilling_ListInvoicesAPI_PortalArms_bvwavePOST /api/v1/billing/update-paymentTestBilling_UpdatePaymentMethodAPI_PortalArms_bvwavePOST /api/v1/billing/change-planTestBilling_ChangePlanAPI_PortalArms_bvwave(success arm = valid hobby→pro; no-downgrade/same-plan/Team-not-buyable pinned by the W3 billing-block suite #247)GET /api/v1/billing/usageTestBAAUsage_HappyPath_RealDB(new)POST /api/v1/billing/promotion/validateTestValidatePromotion_ValidCode_ReturnsDiscountPOST/GET /api/v1/auth/api-keys,DELETE /api/v1/auth/api-keys/:idTestAPIKeys_CreateListRevoke_HappyPathGET /api/v1/auditTestAudit_HappyPath_ReturnsRowsForTeamGET /api/v1/audit.csvTestAuditCSV_Shape_HeaderAndRowsNew tests
internal/handlers/billing_apikeys_audit_block_integration_test.go— a production-auth-chain layer (RequireAuth+PopulateTeamRole+RequireWritable, real session JWTs + real Postgres/Redis) covering the gaps the existing suites left:TestBAAApiKeys_CrossTeamIsolation_*— team B cannot see or revoke (404, not 200) team A's key.TestBAAApiKeys_Member_CanManageOwnTeamKeys,TestBAAApiKeys_Unauthenticated_401.TestBAAUsage_HappyPath_RealDB,TestBAAUsage_CrossTeamIsolation_AReflectsOnlyOwnRows,TestBAAUsage_Member_CanRead.TestBAAAudit_Member_CanReadOwnTeam,TestBAAAuditCSV_CrossTeamIsolation.The Razorpay external leg (invoices/update-payment) is faked via the
SetBillingPortalForTestPortalseam — a real Razorpay call is deferred to the live-cluster e2e; the API contract (success/circuit-open/razorpay-error arms) is asserted here.Verification
TestDoneBar_EveryRouteCovered,TestDoneBar_TestMapPointsAtRealTests) GREEN.make gate: touched packages (internal/handlers,internal/router) green; full./...reds only on documented pre-existing flakes (TestLinkGitHubID,TestGetDeploymentsExpiringSoon_*,TestGetExpiredDeployments_*) — verified identical on clean origin/master with these files stashed. CI authoritative.🤖 Generated with Claude Code