|
|
@ -122,14 +122,34 @@ class WebMvcMetricsAutoConfigurationTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void filterRegistrationBacksOff() {
|
|
|
|
void filterRegistrationBacksOffWithAnotherWebMvcMetricsFilterRegistration() {
|
|
|
|
this.contextRunner.withUserConfiguration(TestWebMvcMetricsFilterConfiguration.class).run((context) -> {
|
|
|
|
this.contextRunner.withUserConfiguration(TestWebMvcMetricsFilterRegistrationConfiguration.class)
|
|
|
|
|
|
|
|
.run((context) -> {
|
|
|
|
assertThat(context).hasSingleBean(FilterRegistrationBean.class);
|
|
|
|
assertThat(context).hasSingleBean(FilterRegistrationBean.class);
|
|
|
|
assertThat(context.getBean(FilterRegistrationBean.class))
|
|
|
|
assertThat(context.getBean(FilterRegistrationBean.class))
|
|
|
|
.isSameAs(context.getBean("testWebMvcMetricsFilter"));
|
|
|
|
.isSameAs(context.getBean("testWebMvcMetricsFilter"));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void filterRegistrationBacksOffWithAnotherWebMvcMetricsFilter() {
|
|
|
|
|
|
|
|
this.contextRunner.withUserConfiguration(TestWebMvcMetricsFilterConfiguration.class)
|
|
|
|
|
|
|
|
.run((context) -> assertThat(context).doesNotHaveBean(FilterRegistrationBean.class)
|
|
|
|
|
|
|
|
.hasSingleBean(WebMvcMetricsFilter.class));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void filterRegistrationDoesNotBackOffWithOtherFilterRegistration() {
|
|
|
|
|
|
|
|
this.contextRunner.withUserConfiguration(TestFilterRegistrationConfiguration.class)
|
|
|
|
|
|
|
|
.run((context) -> assertThat(context).hasBean("testFilter").hasBean("webMvcMetricsFilter"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void filterRegistrationDoesNotBackOffWithOtherFilter() {
|
|
|
|
|
|
|
|
this.contextRunner.withUserConfiguration(TestFilterConfiguration.class)
|
|
|
|
|
|
|
|
.run((context) -> assertThat(context).hasBean("testFilter").hasBean("webMvcMetricsFilter"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void afterMaxUrisReachedFurtherUrisAreDenied(CapturedOutput output) {
|
|
|
|
void afterMaxUrisReachedFurtherUrisAreDenied(CapturedOutput output) {
|
|
|
|
this.contextRunner.withUserConfiguration(TestController.class)
|
|
|
|
this.contextRunner.withUserConfiguration(TestController.class)
|
|
|
@ -258,7 +278,7 @@ class WebMvcMetricsAutoConfigurationTests {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
static class TestWebMvcMetricsFilterConfiguration {
|
|
|
|
static class TestWebMvcMetricsFilterRegistrationConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@Bean
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@ -268,4 +288,35 @@ class WebMvcMetricsAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
|
|
|
|
static class TestWebMvcMetricsFilterConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
|
|
|
WebMvcMetricsFilter testWebMvcMetricsFilter() {
|
|
|
|
|
|
|
|
return new WebMvcMetricsFilter(null, null, null, null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
|
|
|
|
static class TestFilterRegistrationConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
|
|
|
FilterRegistrationBean<Filter> testFilter() {
|
|
|
|
|
|
|
|
return mock(FilterRegistrationBean.class);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Configuration(proxyBeanMethods = false)
|
|
|
|
|
|
|
|
static class TestFilterConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
|
|
|
Filter testFilter() {
|
|
|
|
|
|
|
|
return mock(Filter.class);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|