Skip to content

Make mockoidc subject assertions version-agnostic - #7078

Merged
jhrozek merged 1 commit into
mainfrom
fix-authserver-test-mockoidc-sub
Nov 7, 2026
Merged

jhrozek merged 1 commit into
mainfrom
fix-authserver-test-mockoidc-sub

Conversation

@jhrozek

@jhrozek jhrozek commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • TestIntegration_MultiUpstreamSequentialChain only passes with the current mockoidc pin because that version leaves sub out of the userinfo response. The test configures SubjectFields: ["sub", "email"], so the upstream subject silently falls back to the email, and the assertions check for the email domain.
  • Newer mockoidc (the Renovate bump in Update github.com/oauth2-proxy/mockoidc digest to e06ed0b #7073) returns sub from userinfo. The product code then correctly picks sub, UpstreamSubject becomes user-from-provider-1, and the test fails even though nothing is wrong in the auth server.
  • The two UpstreamSubject assertions now accept either the sub or 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

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe): Test-only change that removes a hidden dependency on a mockoidc version

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

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. The mockoidc userinfo difference was found by diffing the two module versions (mockUserinfo gains a sub field).

Does this introduce a user-facing change?

No

Special notes for reviewers

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]>
@github-actions github-actions Bot added the size/XS Extra small PR: < 100 lines changed label Nov 7, 2026

@rdimitrov rdimitrov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

codecov Bot commented Nov 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.86%. Comparing base (9350573) to head (2ba02c1).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jhrozek
jhrozek merged commit 1fe6b8c into main Nov 7, 2026
47 checks passed
@jhrozek
jhrozek deleted the fix-authserver-test-mockoidc-sub branch November 7, 2026 19:20
@github-actions github-actions Bot mentioned this pull request Nov 10, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants