|
|
|
@ -59,7 +59,8 @@ class SecurityRequestMatchersManagementContextConfigurationTests { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void registersRequestMatcherProviderIfMvcPresent() { |
|
|
|
void registersRequestMatcherProviderIfMvcPresent() { |
|
|
|
this.contextRunner.withUserConfiguration(TestMvcConfiguration.class).run((context) -> { |
|
|
|
this.contextRunner.withUserConfiguration(TestMvcConfiguration.class).run((context) -> { |
|
|
|
AntPathRequestMatcherProvider matcherProvider = context.getBean(AntPathRequestMatcherProvider.class); |
|
|
|
PathPatternRequestMatcherProvider matcherProvider = context |
|
|
|
|
|
|
|
.getBean(PathPatternRequestMatcherProvider.class); |
|
|
|
RequestMatcher requestMatcher = matcherProvider.getRequestMatcher("/example", null); |
|
|
|
RequestMatcher requestMatcher = matcherProvider.getRequestMatcher("/example", null); |
|
|
|
assertThat(requestMatcher).extracting("pattern") |
|
|
|
assertThat(requestMatcher).extracting("pattern") |
|
|
|
.isEqualTo(PathPatternParser.defaultInstance.parse("/custom/example")); |
|
|
|
.isEqualTo(PathPatternParser.defaultInstance.parse("/custom/example")); |
|
|
|
@ -71,7 +72,8 @@ class SecurityRequestMatchersManagementContextConfigurationTests { |
|
|
|
this.contextRunner.withClassLoader(new FilteredClassLoader("org.springframework.web.servlet.DispatcherServlet")) |
|
|
|
this.contextRunner.withClassLoader(new FilteredClassLoader("org.springframework.web.servlet.DispatcherServlet")) |
|
|
|
.withUserConfiguration(TestJerseyConfiguration.class) |
|
|
|
.withUserConfiguration(TestJerseyConfiguration.class) |
|
|
|
.run((context) -> { |
|
|
|
.run((context) -> { |
|
|
|
AntPathRequestMatcherProvider matcherProvider = context.getBean(AntPathRequestMatcherProvider.class); |
|
|
|
PathPatternRequestMatcherProvider matcherProvider = context |
|
|
|
|
|
|
|
.getBean(PathPatternRequestMatcherProvider.class); |
|
|
|
RequestMatcher requestMatcher = matcherProvider.getRequestMatcher("/example", null); |
|
|
|
RequestMatcher requestMatcher = matcherProvider.getRequestMatcher("/example", null); |
|
|
|
assertThat(requestMatcher).extracting("pattern") |
|
|
|
assertThat(requestMatcher).extracting("pattern") |
|
|
|
.isEqualTo(PathPatternParser.defaultInstance.parse("/admin/example")); |
|
|
|
.isEqualTo(PathPatternParser.defaultInstance.parse("/admin/example")); |
|
|
|
@ -81,20 +83,20 @@ class SecurityRequestMatchersManagementContextConfigurationTests { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void mvcRequestMatcherProviderConditionalOnDispatcherServletClass() { |
|
|
|
void mvcRequestMatcherProviderConditionalOnDispatcherServletClass() { |
|
|
|
this.contextRunner.withClassLoader(new FilteredClassLoader("org.springframework.web.servlet.DispatcherServlet")) |
|
|
|
this.contextRunner.withClassLoader(new FilteredClassLoader("org.springframework.web.servlet.DispatcherServlet")) |
|
|
|
.run((context) -> assertThat(context).doesNotHaveBean(AntPathRequestMatcherProvider.class)); |
|
|
|
.run((context) -> assertThat(context).doesNotHaveBean(PathPatternRequestMatcherProvider.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void mvcRequestMatcherProviderConditionalOnDispatcherServletPathBean() { |
|
|
|
void mvcRequestMatcherProviderConditionalOnDispatcherServletPathBean() { |
|
|
|
new WebApplicationContextRunner() |
|
|
|
new WebApplicationContextRunner() |
|
|
|
.withConfiguration(AutoConfigurations.of(SecurityRequestMatchersManagementContextConfiguration.class)) |
|
|
|
.withConfiguration(AutoConfigurations.of(SecurityRequestMatchersManagementContextConfiguration.class)) |
|
|
|
.run((context) -> assertThat(context).doesNotHaveBean(AntPathRequestMatcherProvider.class)); |
|
|
|
.run((context) -> assertThat(context).doesNotHaveBean(PathPatternRequestMatcherProvider.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void jerseyRequestMatcherProviderConditionalOnResourceConfigClass() { |
|
|
|
void jerseyRequestMatcherProviderConditionalOnResourceConfigClass() { |
|
|
|
this.contextRunner.withClassLoader(new FilteredClassLoader("org.glassfish.jersey.server.ResourceConfig")) |
|
|
|
this.contextRunner.withClassLoader(new FilteredClassLoader("org.glassfish.jersey.server.ResourceConfig")) |
|
|
|
.run((context) -> assertThat(context).doesNotHaveBean(AntPathRequestMatcherProvider.class)); |
|
|
|
.run((context) -> assertThat(context).doesNotHaveBean(PathPatternRequestMatcherProvider.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@ -102,7 +104,7 @@ class SecurityRequestMatchersManagementContextConfigurationTests { |
|
|
|
new WebApplicationContextRunner() |
|
|
|
new WebApplicationContextRunner() |
|
|
|
.withConfiguration(AutoConfigurations.of(SecurityRequestMatchersManagementContextConfiguration.class)) |
|
|
|
.withConfiguration(AutoConfigurations.of(SecurityRequestMatchersManagementContextConfiguration.class)) |
|
|
|
.withClassLoader(new FilteredClassLoader("org.springframework.web.servlet.DispatcherServlet")) |
|
|
|
.withClassLoader(new FilteredClassLoader("org.springframework.web.servlet.DispatcherServlet")) |
|
|
|
.run((context) -> assertThat(context).doesNotHaveBean(AntPathRequestMatcherProvider.class)); |
|
|
|
.run((context) -> assertThat(context).doesNotHaveBean(PathPatternRequestMatcherProvider.class)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
@Configuration(proxyBeanMethods = false) |
|
|
|
|