Skip to content

Ensure mockOAuth2Login works without springSecurity()#18816

Closed
wonderfulrosemari wants to merge 1 commit intospring-projects:mainfrom
wonderfulrosemari:gh-18782-mock-oauth2-login-401
Closed

Ensure mockOAuth2Login works without springSecurity()#18816
wonderfulrosemari wants to merge 1 commit intospring-projects:mainfrom
wonderfulrosemari:gh-18782-mock-oauth2-login-401

Conversation

@wonderfulrosemari
Copy link
Copy Markdown
Contributor

Closes gh-18782

Ensure mockOAuth2Login() works even when
SecurityMockServerConfigurers.springSecurity() has not been explicitly
applied to WebTestClient.

Previously, mockOAuth2Login() added SetupMutatorFilter but assumed
MutatorFilter already existed. In setups like @SpringBootTest +
@AutoConfigureWebTestClient, that assumption can be false, resulting in
a missing reactive SecurityContext and a 401 response.

Changes include:

  • ensure MutatorFilter is present in MutatorWebTestClientConfigurer
    before adding SetupMutatorFilter
  • add regression coverage for mockOAuth2Login() when springSecurity()
    is not explicitly applied

Signed-off-by: wonderfulrosemari <whwlsgur1419@naver.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 27, 2026
@jzheaux jzheaux self-assigned this Mar 5, 2026
@jzheaux jzheaux added status: blocked An issue that's blocked on an external project change and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 5, 2026
@jzheaux
Copy link
Copy Markdown
Contributor

jzheaux commented Mar 5, 2026

I'm not convinced that we should make this change, and so I've blocked the PR while discussion continues on #18782

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: blocked An issue that's blocked on an external project change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SecurityMockServerConfigurers.mockOAuth2Login() keeps returning 401

3 participants