Repository navigation
refactor(oidc): inject Azure Key Vault client factory - #1469
Conversation
Extract the azidentity.NewDefaultAzureCredential + azkeys.NewClient construction out of NewAzureKeyVaultSigner into a package-level newAzureKeyVaultClient hook, mirroring the AzureSPProber.NewClient seam in internal/commitmentopts/probe_azure.go. This lets tests override the hook with a fake and exercise the fully-configured Azure branch of NewSignerFromEnv without spawning the live credential chain (az/pwsh, macOS keychain prompts). Adds TestNewSignerFromEnv_AzureFullyConfigured, which was previously impossible to cover.
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 15 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ 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.
|
Closes #1464
Problem
NewAzureKeyVaultSignerininternal/oidc/azure_signer.gocalledazidentity.NewDefaultAzureCredential(nil)andazkeys.NewClient(...)inline, with no injection seam. Existing tests only exercised
NewAzureKeyVaultSignerFromClientwith a fakeAzureKeyVaultClient. Ininternal/oidc/factory.go, the Azure branch ofNewSignerFromEnvcallsNewAzureKeyVaultSignerwhen bothCUDLY_SIGNING_KEY_VAULT_URLandCUDLY_SIGNING_KEY_NAMEare set, and that branch was untested: any testreaching it would build the live
DefaultAzureCredentialchain, riskingaz/pwshprocess spawns and macOS keychain prompts.Fix
newAzureKeyVaultClientfactory hook inazure_signer.gothat holds the credential + client construction.NewAzureKeyVaultSignernow calls the hook instead of inlining theconstruction. Zero production behavior change (same error wrapping,
same call sequence).
AzureSPProber.NewClientinjected-factory pattern ininternal/commitmentopts/probe_azure.go, adapted to this package'spackage-level-var style since
AzureKeyVaultSignerconstruction is afree function rather than a method on a struct with an overridable
field.
TestNewSignerFromEnv_AzureFullyConfiguredininternal/oidc/azure_factory_test.go, which overrides the hook withthe existing
fakeAzureKeyVaultClient, callsNewSignerFromEnvwithboth Azure env vars set, and asserts a non-nil signer, no error, and
that the hook received the configured vault URL.
(
TestNewSignerFromEnv_AzureHalfConfigured) - it only exercises thehalf-configured and both-empty cases, which return before reaching the
hook, so no further protection was needed.
Verification
gofmt -l internal/- cleango vet ./internal/oidc/- cleango test ./internal/oidc/ -count=1- all tests pass (28 tests,including the new one)
go build ./...- clean🤖 Generated with Claude Code