mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-05-31 09:12:14 +00:00
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:
parent
6510274854
commit
d96b4a0463
@ -232,6 +232,7 @@ public class WebSecurityTests {
|
|||||||
@Override
|
@Override
|
||||||
public void configurePathMatch(PathMatchConfigurer configurer) {
|
public void configurePathMatch(PathMatchConfigurer configurer) {
|
||||||
configurer.setUseSuffixPatternMatch(true);
|
configurer.setUseSuffixPatternMatch(true);
|
||||||
|
configurer.setUseTrailingSlashMatch(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -662,6 +662,7 @@ public class AuthorizeRequestsTests {
|
|||||||
@Override
|
@Override
|
||||||
public void configurePathMatch(PathMatchConfigurer configurer) {
|
public void configurePathMatch(PathMatchConfigurer configurer) {
|
||||||
configurer.setUseSuffixPatternMatch(true);
|
configurer.setUseSuffixPatternMatch(true);
|
||||||
|
configurer.setUseTrailingSlashMatch(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -491,6 +491,7 @@ public class HttpSecurityRequestMatchersTests {
|
|||||||
@Override
|
@Override
|
||||||
public void configurePathMatch(PathMatchConfigurer configurer) {
|
public void configurePathMatch(PathMatchConfigurer configurer) {
|
||||||
configurer.setUseSuffixPatternMatch(true);
|
configurer.setUseSuffixPatternMatch(true);
|
||||||
|
configurer.setUseTrailingSlashMatch(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -262,6 +262,7 @@ public class UrlAuthorizationConfigurerTests {
|
|||||||
@Override
|
@Override
|
||||||
public void configurePathMatch(PathMatchConfigurer configurer) {
|
public void configurePathMatch(PathMatchConfigurer configurer) {
|
||||||
configurer.setUseSuffixPatternMatch(true);
|
configurer.setUseSuffixPatternMatch(true);
|
||||||
|
configurer.setUseTrailingSlashMatch(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ public class WebTestClientHtmlUnitDriverBuilderTests {
|
|||||||
class HelloWorldController {
|
class HelloWorldController {
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@GetMapping(produces = MediaType.TEXT_HTML_VALUE)
|
@GetMapping(path = "/", produces = MediaType.TEXT_HTML_VALUE)
|
||||||
String index() {
|
String index() {
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
return "<html>\n"
|
return "<html>\n"
|
||||||
|
@ -188,6 +188,7 @@ class AuthorizeHttpRequestsDslTests {
|
|||||||
open class LegacyMvcMatchingConfig : WebMvcConfigurer {
|
open class LegacyMvcMatchingConfig : WebMvcConfigurer {
|
||||||
override fun configurePathMatch(configurer: PathMatchConfigurer) {
|
override fun configurePathMatch(configurer: PathMatchConfigurer) {
|
||||||
configurer.setUseSuffixPatternMatch(true)
|
configurer.setUseSuffixPatternMatch(true)
|
||||||
|
configurer.setUseTrailingSlashMatch(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +178,7 @@ class AuthorizeRequestsDslTests {
|
|||||||
open class LegacyMvcMatchingConfig : WebMvcConfigurer {
|
open class LegacyMvcMatchingConfig : WebMvcConfigurer {
|
||||||
override fun configurePathMatch(configurer: PathMatchConfigurer) {
|
override fun configurePathMatch(configurer: PathMatchConfigurer) {
|
||||||
configurer.setUseSuffixPatternMatch(true)
|
configurer.setUseSuffixPatternMatch(true)
|
||||||
|
configurer.setUseTrailingSlashMatch(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ class ServerJwtDslTests {
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
internal class BaseController {
|
internal class BaseController {
|
||||||
@GetMapping
|
@GetMapping("/")
|
||||||
fun index() {
|
fun index() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
</http>
|
</http>
|
||||||
|
|
||||||
<mvc:annotation-driven>
|
<mvc:annotation-driven>
|
||||||
<mvc:path-matching suffix-pattern="true"/>
|
<mvc:path-matching suffix-pattern="true" trailing-slash="true"/>
|
||||||
</mvc:annotation-driven>
|
</mvc:annotation-driven>
|
||||||
|
|
||||||
<b:bean name="path" class="org.springframework.security.config.http.InterceptUrlConfigTests.PathController"/>
|
<b:bean name="path" class="org.springframework.security.config.http.InterceptUrlConfigTests.PathController"/>
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
</http>
|
</http>
|
||||||
|
|
||||||
<mvc:annotation-driven>
|
<mvc:annotation-driven>
|
||||||
<mvc:path-matching suffix-pattern="true"/>
|
<mvc:path-matching suffix-pattern="true" trailing-slash="true"/>
|
||||||
</mvc:annotation-driven>
|
</mvc:annotation-driven>
|
||||||
|
|
||||||
<b:bean name="path" class="org.springframework.security.config.http.InterceptUrlConfigTests.PathController"/>
|
<b:bean name="path" class="org.springframework.security.config.http.InterceptUrlConfigTests.PathController"/>
|
||||||
|
@ -95,7 +95,7 @@ public class SecurityMockMvcRequestPostProcessorsAuthenticationStatelessTests {
|
|||||||
@RestController
|
@RestController
|
||||||
static class Controller {
|
static class Controller {
|
||||||
|
|
||||||
@RequestMapping
|
@RequestMapping("/")
|
||||||
String hello() {
|
String hello() {
|
||||||
return "Hello";
|
return "Hello";
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ public class SecurityMockMvcRequestPostProcessorsTestSecurityContextStatelessTes
|
|||||||
@RestController
|
@RestController
|
||||||
static class Controller {
|
static class Controller {
|
||||||
|
|
||||||
@RequestMapping
|
@RequestMapping("/")
|
||||||
String hello() {
|
String hello() {
|
||||||
return "Hello";
|
return "Hello";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user