Repository navigation
refactor(api): inject Azure revoke client factory - #1471
Merged
Merged
Conversation
calculateAzureRevoke and revokeAzurePurchase each constructed azidentity.NewDefaultAzureCredential and the armreservations clients inline, so no test could reach either function without walking the live Azure credential chain (az/pwsh spawn, macOS keychain prompts). Add Handler.newAzureRevokeClients, a factory seam mirroring the AzureSPProber.NewClient pattern: nil means "use the production default" (unchanged credential + client construction), and tests can override it with the existing stubCalcRefundClient/stubReturnClient fakes. Both handlers now route through buildAzureRevokeClients, with new tests covering the happy path and a factory-error path for each.
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAzure revoke client construction is centralized behind an optional injected factory. Both revoke handlers use shared builders, and tests cover successful client creation plus credential-factory error propagation. ChangesAzure revoke injection
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Member
Author
|
@coderabbitai review |
Contributor
✅ Action performedReview finished.
|
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.
Closes #1463
Problem
calculateAzureRevokeandrevokeAzurePurchaseininternal/api/handler_purchases_revoke.goeach calledazidentity.NewDefaultAzureCredential(nil)and thenarmreservations.NewCalculateRefundClient/armreservations.NewReturnClientinline, with no injection seam. The injectable interfaces
(
azureCalculateRefundClient/azureReturnClient) already existed and wereconsumed by
callAzureReturn, but any test that reached either of these twofunctions directly would walk the live Azure credential chain (spawning
az/pwsh, popping macOS keychain prompts).Fix
Added
Handler.newAzureRevokeClients, an injectable factory field mirroringthe
AzureSPProber.NewClientpattern (internal/commitmentopts/probe_azure.go).A nil field means "use the production default", so all existing production
construction sites are unchanged. Both handlers now route through a new
buildAzureRevokeClientshelper that returns the injected factory's resultwhen set, or falls back to the original
DefaultAzureCredential+armreservationsconstruction otherwise. Error message text is preservedexactly on both paths.
Tests added
TestCalculateAzureRevoke_Success/TestCalculateAzureRevoke_ClientFactoryErrorTestRevokeAzurePurchase_Success/TestRevokeAzurePurchase_ClientFactoryErrorAll drive the two previously-unreachable handlers end-to-end through the new
seam using the existing
stubCalcRefundClient/stubReturnClientfakes, withno live Azure client involved.
Verification
gofmt -l internal/— cleango vet ./internal/api/— cleango test ./internal/api/ -count=1— 1815 passedgo build ./...— clean🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests