Repository navigation
Make mockoidc subject assertions version-agnostic - #7078
Conversation
The multi-upstream chain test relied on the pinned mockoidc leaving "sub" out of the userinfo response, so the upstream subject fell back to the email. Newer mockoidc returns "sub", which changes the subject the auth server correctly picks and fails the test. Accept either the "sub" or the email so the test passes on both versions and the mockoidc bump can land. Co-authored-by: Mecatl <[email protected]>
rdimitrov
left a comment
There was a problem hiding this comment.
Approving: this test-only change correctly unblocks the mockoidc bump in #7073.
Design: The subject comes from the userinfo field mapping in pkg/authserver/upstream, and its sub-before-email precedence is already unit-tested there (oauth2_test.go, userinfo_config_test.go). So the right fix is in this integration test, which was depending on the old mock not returning sub. No product code changes. The two allowed values for each provider don't overlap, and the NotEqual check is kept, so the test still proves each subject came from the correct upstream. #7073's failing CI run fails only at these two assertions. No other test in the package relies on the old mock behaviour.
Follow-up: once #7073 lands, tighten both assertions to the exact sub values (user-from-provider-1 / user-from-provider-2). The comment around pkg/authserver/integration_test.go:2516, which says the mock's userinfo only returns email, will be wrong by then and should be fixed in the same change.
🤖 Reviewed with Claude Code
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7078 +/- ##
==========================================
- Coverage 80.88% 80.86% -0.03%
==========================================
Files 864 864
Lines 88634 88634
==========================================
- Hits 71696 71671 -25
- Misses 16933 16958 +25
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
TestIntegration_MultiUpstreamSequentialChainonly passes with the currentmockoidcpin because that version leavessubout of the userinfo response. The test configuresSubjectFields: ["sub", "email"], so the upstream subject silently falls back to the email, and the assertions check for the email domain.mockoidc(the Renovate bump in Update github.com/oauth2-proxy/mockoidc digest to e06ed0b #7073) returnssubfrom userinfo. The product code then correctly pickssub,UpstreamSubjectbecomesuser-from-provider-1, and the test fails even though nothing is wrong in the auth server.UpstreamSubjectassertions now accept either thesubor the email, so the test passes on the current pin and on the bumped one. This lets Update github.com/oauth2-proxy/mockoidc digest to e06ed0b #7073 go green once it is rebased onto this change.Type of change
mockoidcversionTest plan
task test)task test-e2e)task lint-fix)I did not run the tests locally. CI on this PR is the check on the current pin. The new-version case is the failure already seen in #7073's CI (
integration_test.go:4667), which this change addresses. Themockoidcuserinfo difference was found by diffing the two module versions (mockUserinfogains asubfield).Does this introduce a user-facing change?
No
Special notes for reviewers
subvalue, and the"email"fallback in theSubjectFieldslists of this test file can be dropped. I left that out to keep this change small.integration_test.go:2517saying mockoidc's userinfo does not returnsub. It is not touched here.