Use PathPatternRequestMatcher in test

Issue gh-16887
This commit is contained in:
Josh Cummings 2025-07-02 13:55:04 -06:00
parent b6d61b2f10
commit e9506776f1
No known key found for this signature in database
GPG Key ID: 869B37A20E876129

View File

@ -41,13 +41,13 @@ import org.springframework.security.web.context.SecurityContextRepository;
import org.springframework.security.web.csrf.CsrfFilter; import org.springframework.security.web.csrf.CsrfFilter;
import org.springframework.security.web.csrf.CsrfTokenRepository; import org.springframework.security.web.csrf.CsrfTokenRepository;
import org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository; import org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.security.web.util.matcher.AnyRequestMatcher; import org.springframework.security.web.util.matcher.AnyRequestMatcher;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher.pathPattern;
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
public class WebTestUtilsTests { public class WebTestUtilsTests {
@ -226,7 +226,7 @@ public class WebTestUtilsTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.securityMatcher(new AntPathRequestMatcher("/willnotmatchthis")); .securityMatcher(pathPattern("/willnotmatchthis"));
return http.build(); return http.build();
// @formatter:on // @formatter:on
} }