use of org.springframework.boot.devtools.remote.server.DispatcherFilter in project spring-boot by spring-projects.
the class RemoteDevToolsAutoConfigurationTests method securityConfigurationWhenWebSecurityConfigurerAdapterIsFound2.
@Test
void securityConfigurationWhenWebSecurityConfigurerAdapterIsFound2() throws Exception {
this.context = getContext(() -> {
AnnotationConfigServletWebApplicationContext context = new AnnotationConfigServletWebApplicationContext();
context.setServletContext(new MockServletContext());
context.register(Config.class, PropertyPlaceholderAutoConfiguration.class, TestWebSecurityConfigurerAdapter.class);
TestPropertyValues.of("spring.devtools.remote.secret:supersecret").applyTo(context);
context.refresh();
return context;
});
DispatcherFilter filter = this.context.getBean(DispatcherFilter.class);
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).apply(springSecurity()).addFilter(filter).build();
mockMvc.perform(MockMvcRequestBuilders.get(DEFAULT_CONTEXT_PATH + "/restart").header(DEFAULT_SECRET_HEADER_NAME, "supersecret")).andExpect(status().isOk());
assertRestartInvoked(true);
}
use of org.springframework.boot.devtools.remote.server.DispatcherFilter in project spring-boot by spring-projects.
the class RemoteDevToolsAutoConfigurationTests method ignoresIfMissingSecretFromRequest.
@Test
void ignoresIfMissingSecretFromRequest() throws Exception {
this.context = getContext(() -> loadContext("spring.devtools.remote.secret:supersecret"));
DispatcherFilter filter = this.context.getBean(DispatcherFilter.class);
this.request.setRequestURI(DEFAULT_CONTEXT_PATH + "/restart");
filter.doFilter(this.request, this.response, this.chain);
assertRestartInvoked(false);
}
use of org.springframework.boot.devtools.remote.server.DispatcherFilter in project spring-boot by spring-projects.
the class RemoteDevToolsAutoConfigurationTests method securityConfigurationShouldAllowAccessToCustomPath.
@Test
void securityConfigurationShouldAllowAccessToCustomPath() throws Exception {
this.context = getContext(() -> loadContext("spring.devtools.remote.secret:supersecret", "server.servlet.context-path:/test", "spring.devtools.remote.context-path:/custom"));
DispatcherFilter filter = this.context.getBean(DispatcherFilter.class);
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).apply(springSecurity()).addFilter(filter).build();
mockMvc.perform(MockMvcRequestBuilders.get("/test/custom/restart").header(DEFAULT_SECRET_HEADER_NAME, "supersecret")).andExpect(status().isOk());
assertRestartInvoked(true);
}
use of org.springframework.boot.devtools.remote.server.DispatcherFilter in project spring-boot by spring-projects.
the class RemoteDevToolsAutoConfigurationTests method invokeRestartWithCustomServerContextPath.
@Test
void invokeRestartWithCustomServerContextPath() throws Exception {
this.context = getContext(() -> loadContext("spring.devtools.remote.secret:supersecret", "server.servlet.context-path:/test"));
DispatcherFilter filter = this.context.getBean(DispatcherFilter.class);
this.request.setRequestURI("/test" + DEFAULT_CONTEXT_PATH + "/restart");
this.request.addHeader(DEFAULT_SECRET_HEADER_NAME, "supersecret");
filter.doFilter(this.request, this.response, this.chain);
assertRestartInvoked(true);
}
Aggregations