|
@@ -46,6 +46,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
|
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|
|
+import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
|
|
|
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
import static org.mockito.Mockito.spy;
|
|
@@ -292,7 +294,7 @@ public class AuthorizeRequestsTests {
|
|
|
|
|
|
@Test
|
|
|
public void mvcMatcher() throws Exception {
|
|
|
- loadConfig(MvcMatcherConfig.class);
|
|
|
+ loadConfig(MvcMatcherConfig.class, LegacyMvcMatchingConfig.class);
|
|
|
|
|
|
this.request.setRequestURI("/path");
|
|
|
this.springSecurityFilterChain.doFilter(this.request, this.response, this.chain);
|
|
@@ -350,7 +352,7 @@ public class AuthorizeRequestsTests {
|
|
|
|
|
|
@Test
|
|
|
public void requestWhenMvcMatcherDenyAllThenRespondsWithUnauthorized() throws Exception {
|
|
|
- loadConfig(MvcMatcherInLambdaConfig.class);
|
|
|
+ loadConfig(MvcMatcherInLambdaConfig.class, LegacyMvcMatchingConfig.class);
|
|
|
|
|
|
this.request.setRequestURI("/path");
|
|
|
this.springSecurityFilterChain.doFilter(this.request, this.response, this.chain);
|
|
@@ -410,7 +412,7 @@ public class AuthorizeRequestsTests {
|
|
|
|
|
|
@Test
|
|
|
public void mvcMatcherServletPath() throws Exception {
|
|
|
- loadConfig(MvcMatcherServletPathConfig.class);
|
|
|
+ loadConfig(MvcMatcherServletPathConfig.class, LegacyMvcMatchingConfig.class);
|
|
|
|
|
|
this.request.setServletPath("/spring");
|
|
|
this.request.setRequestURI("/spring/path");
|
|
@@ -487,7 +489,7 @@ public class AuthorizeRequestsTests {
|
|
|
|
|
|
@Test
|
|
|
public void requestWhenMvcMatcherServletPathDenyAllThenMatchesOnServletPath() throws Exception {
|
|
|
- loadConfig(MvcMatcherServletPathInLambdaConfig.class);
|
|
|
+ loadConfig(MvcMatcherServletPathInLambdaConfig.class, LegacyMvcMatchingConfig.class);
|
|
|
|
|
|
this.request.setServletPath("/spring");
|
|
|
this.request.setRequestURI("/spring/path");
|
|
@@ -697,6 +699,14 @@ public class AuthorizeRequestsTests {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Configuration
|
|
|
+ static class LegacyMvcMatchingConfig implements WebMvcConfigurer {
|
|
|
+ @Override
|
|
|
+ public void configurePathMatch(PathMatchConfigurer configurer) {
|
|
|
+ configurer.setUseSuffixPatternMatch(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public void loadConfig(Class<?>... configs) {
|
|
|
this.context = new AnnotationConfigWebApplicationContext();
|
|
|
this.context.register(configs);
|