Repository navigation
fix(api): restore base build - drop removed Session.Role from handler_purchases_test (regression from #528) - #975
Conversation
…_purchases_test (regression from #528) PR #528 introduced TestHandler_getPurchaseDetails_NotFound_IsClientError using Role:"admin" in a Session literal, but Session.Role was removed in #940/#907. This caused go vet to fail on internal/api, breaking the base build. Replace the stale Role field with mockAuth.grantAdmin() following the established pattern used throughout handler_purchases_test.go. Also includes gofmt whitespace fixes to handler_purchases_guards_test.go caught by the pre-commit hook (semicolons split to newlines).
|
Warning Review limit reached
More reviews will be available in 38 minutes and 53 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
TestHandler_getPurchaseDetails_NotFound_IsClientErrorusingRole: "admin"in a&Session{}literal, butSession.Rolewas removed in fix(api/purchases): base build broken - session.Role removed by #907 but still used in authorizeSessionExecuteDirect (#803) #940/Revamp authorization: group-membership-only (remove roles), require >=1 group per user #907.go vet ./internal/api/to fail withunknown field Role in struct literal of type Session, breaking the base build for anyone onfeat/multicloud-web-frontend.Role: "admin"field and addmockAuth.grantAdmin()following the established pattern used in 30+ other tests in the same file (see comment at mocks_test.go:881-897).Changes
internal/api/handler_purchases_test.goline 1644: removeRole: "admin"fromadminSessionliteral; addmockAuth.grantAdmin()soHasPermissionAPIis properly stubbed.internal/api/handler_purchases_guards_test.go: gofmt formatting only (semicolons split to newlines, caught by pre-commit hook).Verification
go vet ./internal/api/: no issuesgofmt -l: cleango build ./...: successgo test ./internal/api/ -count=1: 1458 passedSKIP=terraform_validate pre-commit run --all-files: all passedTest plan
go vet ./internal/api/returns 0 issuesTestHandler_getPurchaseDetails_NotFound_IsClientErrorpasses and still asserts the 404 ClientError regression for sec(purchases): GetExecutionByID returns error on not-found, causing 500 instead of 404 — leaks execution UUID existence to unauthenticated callers #431