use of org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext in project spring-boot by spring-projects.
the class WebMvcEndpointIntegrationTests method endpointsAreSecureByDefault.
@Test
void endpointsAreSecureByDefault() throws Exception {
this.context = new AnnotationConfigServletWebApplicationContext();
this.context.register(SecureConfiguration.class);
MockMvc mockMvc = createSecureMockMvc();
mockMvc.perform(get("/actuator/beans").accept(MediaType.APPLICATION_JSON)).andExpect(status().isUnauthorized());
}
use of org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext in project spring-boot by spring-projects.
the class WebMvcEndpointIntegrationTests method endpointsAreSecureWithActuatorRoleWithCustomBasePath.
@Test
void endpointsAreSecureWithActuatorRoleWithCustomBasePath() throws Exception {
TestSecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR"));
this.context = new AnnotationConfigServletWebApplicationContext();
this.context.register(SecureConfiguration.class);
TestPropertyValues.of("management.endpoints.web.base-path:/management", "management.endpoints.web.exposure.include=*").applyTo(this.context);
MockMvc mockMvc = createSecureMockMvc();
mockMvc.perform(get("/management/beans")).andExpect(status().isOk());
}
use of org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext in project spring-boot by spring-projects.
the class WebMvcEndpointIntegrationTests method webMvcEndpointHandlerMappingIsConfiguredWithPathPatternParser.
@Test
void webMvcEndpointHandlerMappingIsConfiguredWithPathPatternParser() {
this.context = new AnnotationConfigServletWebApplicationContext();
this.context.register(DefaultConfiguration.class);
this.context.setServletContext(new MockServletContext());
this.context.refresh();
WebMvcEndpointHandlerMapping handlerMapping = this.context.getBean(WebMvcEndpointHandlerMapping.class);
assertThat(handlerMapping.getPatternParser()).isEqualTo(WebMvcAutoConfiguration.pathPatternParser);
}
use of org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext in project spring-boot by spring-projects.
the class ConditionalOnWarDeploymentTests method embeddedServletWebApplicationShouldNotMatch.
@Test
void embeddedServletWebApplicationShouldNotMatch() {
WebApplicationContextRunner contextRunner = new WebApplicationContextRunner(AnnotationConfigServletWebApplicationContext::new);
contextRunner.withUserConfiguration(TestConfiguration.class).run((context) -> assertThat(context).doesNotHaveBean("forWar"));
}
use of org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext in project spring-boot by spring-projects.
the class MustacheAutoConfigurationTests method loadWithServlet.
private void loadWithServlet(Class<?> config) {
this.webContext = new AnnotationConfigServletWebApplicationContext();
TestPropertyValues.of("spring.mustache.prefix=classpath:/mustache-templates/").applyTo(this.webContext);
if (config != null) {
this.webContext.register(config);
}
this.webContext.register(BaseConfiguration.class);
this.webContext.refresh();
}
Aggregations