|
|
|
@ -52,6 +52,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
|
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
|
import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity;
|
|
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -151,9 +152,8 @@ class RemoteDevToolsAutoConfigurationTests {
|
|
|
|
|
void securityConfigurationShouldAllowAccess() 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 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);
|
|
|
|
@ -164,9 +164,8 @@ class RemoteDevToolsAutoConfigurationTests {
|
|
|
|
|
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);
|
|
|
|
|
Filter securityFilterChain = this.context.getBean(BeanIds.SPRING_SECURITY_FILTER_CHAIN, Filter.class);
|
|
|
|
|
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).addFilter(securityFilterChain)
|
|
|
|
|
.addFilter(filter).build();
|
|
|
|
|
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());
|
|
|
|
|