|
16 | 16 |
|
17 | 17 | package org.springframework.security.config.annotation.web.configurers;
|
18 | 18 |
|
| 19 | +import java.util.List; |
| 20 | + |
19 | 21 | import jakarta.servlet.http.HttpServletResponse;
|
20 | 22 | import org.junit.jupiter.api.AfterEach;
|
21 | 23 | import org.junit.jupiter.api.BeforeEach;
|
|
36 | 38 | import org.springframework.security.web.FilterChainProxy;
|
37 | 39 | import org.springframework.security.web.SecurityFilterChain;
|
38 | 40 | import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
| 41 | +import org.springframework.security.web.util.matcher.RequestMatcher; |
| 42 | +import org.springframework.test.util.ReflectionTestUtils; |
39 | 43 | import org.springframework.web.bind.annotation.RequestMapping;
|
40 | 44 | import org.springframework.web.bind.annotation.RestController;
|
41 | 45 | import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
@@ -88,10 +92,12 @@ public void securityMatcherWhenNoMvcThenAntMatcher() throws Exception {
|
88 | 92 | setup();
|
89 | 93 | this.request.setServletPath("/path/");
|
90 | 94 | this.springSecurityFilterChain.doFilter(this.request, this.response, this.chain);
|
| 95 | + List<RequestMatcher> requestMatchers = this.springSecurityFilterChain.getFilterChains().stream() |
| 96 | + .map((chain) -> ((DefaultSecurityFilterChain) chain).getRequestMatcher()) |
| 97 | + .map((matcher) -> ReflectionTestUtils.getField(matcher, "requestMatchers")) |
| 98 | + .map((matchers) -> (List<RequestMatcher>) matchers).findFirst().get(); |
91 | 99 | assertThat(this.response.getStatus()).isEqualTo(HttpServletResponse.SC_OK);
|
92 |
| - assertThat(this.springSecurityFilterChain.getFilterChains()) |
93 |
| - .extracting((c) -> ((DefaultSecurityFilterChain) c).getRequestMatcher()) |
94 |
| - .hasOnlyElementsOfType(AntPathRequestMatcher.class); |
| 100 | + assertThat(requestMatchers).hasOnlyElementsOfType(AntPathRequestMatcher.class); |
95 | 101 | }
|
96 | 102 |
|
97 | 103 | public void loadConfig(Class<?>... configs) {
|
|
0 commit comments