|
@@ -16,6 +16,8 @@
|
|
|
|
|
|
package org.springframework.security.config.annotation.web.configurers;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
import org.junit.jupiter.api.AfterEach;
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
@@ -36,6 +38,8 @@ import org.springframework.security.web.DefaultSecurityFilterChain;
|
|
|
import org.springframework.security.web.FilterChainProxy;
|
|
|
import org.springframework.security.web.SecurityFilterChain;
|
|
|
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
|
|
+import org.springframework.security.web.util.matcher.RequestMatcher;
|
|
|
+import org.springframework.test.util.ReflectionTestUtils;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
|
@@ -88,10 +92,12 @@ public class HttpSecuritySecurityMatchersNoMvcTests {
|
|
|
setup();
|
|
|
this.request.setServletPath("/path/");
|
|
|
this.springSecurityFilterChain.doFilter(this.request, this.response, this.chain);
|
|
|
+ List<RequestMatcher> requestMatchers = this.springSecurityFilterChain.getFilterChains().stream()
|
|
|
+ .map((chain) -> ((DefaultSecurityFilterChain) chain).getRequestMatcher())
|
|
|
+ .map((matcher) -> ReflectionTestUtils.getField(matcher, "requestMatchers"))
|
|
|
+ .map((matchers) -> (List<RequestMatcher>) matchers).findFirst().get();
|
|
|
assertThat(this.response.getStatus()).isEqualTo(HttpServletResponse.SC_OK);
|
|
|
- assertThat(this.springSecurityFilterChain.getFilterChains())
|
|
|
- .extracting((c) -> ((DefaultSecurityFilterChain) c).getRequestMatcher())
|
|
|
- .hasOnlyElementsOfType(AntPathRequestMatcher.class);
|
|
|
+ assertThat(requestMatchers).hasOnlyElementsOfType(AntPathRequestMatcher.class);
|
|
|
}
|
|
|
|
|
|
public void loadConfig(Class<?>... configs) {
|