use of org.springframework.boot.devtools.remote.server.DispatcherFilter in project spring-boot by spring-projects.
the class RemoteDevToolsAutoConfigurationTests method invokeTunnelWithCustomHeaderName.
@Test
public void invokeTunnelWithCustomHeaderName() throws Exception {
loadContext("spring.devtools.remote.secret:supersecret", "spring.devtools.remote.secretHeaderName:customheader");
DispatcherFilter filter = this.context.getBean(DispatcherFilter.class);
this.request.setRequestURI(DEFAULT_CONTEXT_PATH + "/debug");
this.request.addHeader("customheader", "supersecret");
filter.doFilter(this.request, this.response, this.chain);
assertTunnelInvoked(true);
}
use of org.springframework.boot.devtools.remote.server.DispatcherFilter in project spring-boot by spring-projects.
the class RemoteDevToolsAutoConfigurationTests method invokeTunnelWithCustomServerContextPath.
@Test
public void invokeTunnelWithCustomServerContextPath() throws Exception {
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 + "/debug");
this.request.addHeader(DEFAULT_SECRET_HEADER_NAME, "supersecret");
filter.doFilter(this.request, this.response, this.chain);
assertTunnelInvoked(true);
}
use of org.springframework.boot.devtools.remote.server.DispatcherFilter in project spring-boot by spring-projects.
the class RemoteDevToolsAutoConfigurationTests method securityConfigurationShouldAllowAccess.
@Test
void securityConfigurationShouldAllowAccess() throws Exception {
this.context = getContext(() -> loadContext("spring.devtools.remote.secret:supersecret"));
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);
assertThat(this.context.containsBean("devtoolsSecurityFilterChain")).isTrue();
}
use of org.springframework.boot.devtools.remote.server.DispatcherFilter in project spring-boot by spring-projects.
the class RemoteDevToolsAutoConfigurationTests method ignoresInvalidSecretInRequest.
@Test
void ignoresInvalidSecretInRequest() 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");
this.request.addHeader(DEFAULT_SECRET_HEADER_NAME, "invalid");
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 securityConfigurationDoesNotAffectOtherPaths.
@Test
void securityConfigurationDoesNotAffectOtherPaths() throws Exception {
this.context = getContext(() -> loadContext("spring.devtools.remote.secret:supersecret"));
DispatcherFilter filter = this.context.getBean(DispatcherFilter.class);
Filter securityFilterChain = this.context.getBean(BeanIds.SPRING_SECURITY_FILTER_CHAIN, Filter.class);
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).addFilter(securityFilterChain).addFilter(filter).build();
mockMvc.perform(MockMvcRequestBuilders.get("/my-path")).andExpect(status().isUnauthorized());
}
Aggregations