Set the useTrailingSlashMatch to true for tests

The Spring MVC changed the default behavior for trailing slash match
with https://github.com/spring-projects/spring-framework/issues/28552.
This causes failures in Spring Security's tests.

Setting the `useTrailingSlashMatch` to `true` ensures that Spring
Security will work for users who have modified the default configuration.
Specifing the request mapper with trailing slash path ensures that the tests
are successful when default behavior is used.

Closes gh-11451
This commit is contained in:
Igor Bolic
2022-07-04 11:56:21 +02:00
committed by Josh Cummings
parent 6510274854
commit d96b4a0463
12 changed files with 12 additions and 6 deletions

View File

@@ -232,6 +232,7 @@ public class WebSecurityTests {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseSuffixPatternMatch(true);
configurer.setUseTrailingSlashMatch(true);
}
}

View File

@@ -662,6 +662,7 @@ public class AuthorizeRequestsTests {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseSuffixPatternMatch(true);
configurer.setUseTrailingSlashMatch(true);
}
}

View File

@@ -491,6 +491,7 @@ public class HttpSecurityRequestMatchersTests {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseSuffixPatternMatch(true);
configurer.setUseTrailingSlashMatch(true);
}
}

View File

@@ -262,6 +262,7 @@ public class UrlAuthorizationConfigurerTests {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseSuffixPatternMatch(true);
configurer.setUseTrailingSlashMatch(true);
}
}

View File

@@ -74,7 +74,7 @@ public class WebTestClientHtmlUnitDriverBuilderTests {
class HelloWorldController {
@ResponseBody
@GetMapping(produces = MediaType.TEXT_HTML_VALUE)
@GetMapping(path = "/", produces = MediaType.TEXT_HTML_VALUE)
String index() {
// @formatter:off
return "<html>\n"