Commonize OIDC handler test cases with table-driven generation#111
Open
Commonize OIDC handler test cases with table-driven generation#111
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors oidc_handling_test.go to generate OIDC handler URL/auth/log assertion cases via shared, table-driven helpers, reducing repetitive per-ecosystem/per-provider boilerplate while aiming to keep the same coverage.
Changes:
- Adds
oidcProviderFields+buildEcosystemCaseshelpers and supporting structs to generate OIDC test cases across providers. - Rewrites
TestOIDCURLsAreAuthenticatedto use provider variants per ecosystem (including special-case overrides like NuGet mocks and Python/simplebehavior). - Normalizes provider token-exchange endpoint mocks within the shared test runner.
Show a summary per file
| File | Description |
|---|---|
| internal/handlers/oidc_handling_test.go | Replaces many hand-written OIDC URL/auth test cases with helper-generated, table-driven cases and provider-specific token-exchange mocks. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 2
0950347 to
a12df54
Compare
a12df54 to
64f83e1
Compare
64f83e1 to
f74dbdc
Compare
Replace 65 hand-written test cases (13 ecosystems × 5 providers) with table-driven generation using buildEcosystemCases helper. Each ecosystem defines its variants compactly — provider credential fields are shared via oidcProviderFields, and expected log lines / auth URLs are derived automatically with explicit overrides for special cases. Reduces oidc_handling_test.go from 1846 to 685 lines (~63%) while preserving identical test coverage: same 65 test cases, same test names, same assertions, same provider mock endpoints. Special cases handled explicitly: - Docker/Helm JFrog: host-derived log targets - Go proxy/Terraform Azure: host-based credentials - Python GCP: index-url with /simple suffix stripping - RubyGems: dual url+host credential fields - NuGet: service index discovery mocks and resource URL registration - Composer JFrog: dual registry+url fields Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
f74dbdc to
406e23d
Compare
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.
Commonize OIDC handler test cases with table-driven generation
Follow-up from #108 — reduces repetitive test code while preserving identical coverage.
Problem
oidc_handling_test.gohad 65 hand-written test cases (13 ecosystems × 5 OIDC providers) with near-identical structure. Adding a new provider required copying ~13 blocks; adding a new ecosystem required copying ~5 blocks. Each block repeated the same provider credential fields, handler factory, and assertion logic.Approach
Introduce
buildEcosystemCaseshelper andoidcProviderFieldsshared function:oidcProviderFields(provider)— returns provider-specific credential fields (aws-region, tenant-id, etc.) shared across all ecosystemsbuildEcosystemCases(name, factory, logLabel, variants)— generates test cases by merging ecosystem URL config with provider fields, deriving log lines and auth URLs automaticallySpecial cases preserved with explicit overrides:
index-urlwith/simplesuffix strippingurl+hostcredential fieldsregistry+urlfieldsResult
oidcProviderFields+ 1 line per ecosystembuildEcosystemCasescall with 5 variants