-
Notifications
You must be signed in to change notification settings - Fork 38.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MockMvc misbehaves with multiple servlets and ambiguous SecurityFilterChain RequestMatchers #32217
Comments
I was on the fence, because I could see the solution being on either side: either adjust MockMvc to make the request look more like a real request, or adjust the request matcher logic to not rely on the request having a servlet name |
Thanks for the ping @snicoll Thanks for the report @nmck257. I can definitely see why you were conflicted on where to report the issue. There is an issue in Spring Security already, so let's use that ticket for tracking. With that in mind, I think that this ticket can be closed as a duplicate of the previously mentioned ticket in Spring Security. |
Ah, whoops - yeah, that issue looks to indeed be the same. Agreed, this can close as a duplicate. Thanks! |
Affects: 3.1.9-SNAPSHOT (haven't tested other release lines)
Reproducer repo attached.
bugsample.zip
Given the following conditions:
authorizeRequests
->requestMatchers(String...)
overloadWhen the app is booted and handling a real request, then when the
AbstractRequestMatcherRegistry
decides whether to interpret the matcher asAnt
orMvc
, it works as designed and the request proceeds.But when the same code is executed within a
@SpringBootTest
(with awebServerPort
configured) usingMockMvc
, then the decision logic cannot get a servlet name from theHttpServletRequest
(because this object uses aMockHttpServletMapping
with empty-string fields), and throws the following uncaught exception:The text was updated successfully, but these errors were encountered: