Search in sources :

Example 6 with DispatcherFilter

use of org.springframework.boot.devtools.remote.server.DispatcherFilter in project spring-boot by spring-projects.

the class RemoteDevToolsAutoConfigurationTests method invokeRestartWithDefaultSetup.

@Test
void invokeRestartWithDefaultSetup() 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, "supersecret");
    filter.doFilter(this.request, this.response, this.chain);
    assertRestartInvoked(true);
}
Also used : DispatcherFilter(org.springframework.boot.devtools.remote.server.DispatcherFilter) Test(org.junit.jupiter.api.Test)

Example 7 with DispatcherFilter

use of org.springframework.boot.devtools.remote.server.DispatcherFilter in project spring-boot by spring-projects.

the class RemoteDevToolsAutoConfigurationTests method devToolsHealthReturns200.

@Test
void devToolsHealthReturns200() throws Exception {
    this.context = getContext(() -> loadContext("spring.devtools.remote.secret:supersecret"));
    DispatcherFilter filter = this.context.getBean(DispatcherFilter.class);
    this.request.setRequestURI(DEFAULT_CONTEXT_PATH);
    this.request.addHeader(DEFAULT_SECRET_HEADER_NAME, "supersecret");
    this.response.setStatus(500);
    filter.doFilter(this.request, this.response, this.chain);
    assertThat(this.response.getStatus()).isEqualTo(200);
}
Also used : DispatcherFilter(org.springframework.boot.devtools.remote.server.DispatcherFilter) Test(org.junit.jupiter.api.Test)

Example 8 with DispatcherFilter

use of org.springframework.boot.devtools.remote.server.DispatcherFilter in project spring-boot by spring-projects.

the class RemoteDevToolsAutoConfigurationTests method ignoresUnmappedUrl.

@Test
void ignoresUnmappedUrl() throws Exception {
    this.context = getContext(() -> loadContext("spring.devtools.remote.secret:supersecret"));
    DispatcherFilter filter = this.context.getBean(DispatcherFilter.class);
    this.request.setRequestURI("/restart");
    this.request.addHeader(DEFAULT_SECRET_HEADER_NAME, "supersecret");
    filter.doFilter(this.request, this.response, this.chain);
    assertRestartInvoked(false);
}
Also used : DispatcherFilter(org.springframework.boot.devtools.remote.server.DispatcherFilter) Test(org.junit.jupiter.api.Test)

Example 9 with DispatcherFilter

use of org.springframework.boot.devtools.remote.server.DispatcherFilter in project spring-boot by spring-projects.

the class RemoteDevToolsAutoConfigurationTests method invokeTunnelWithDefaultSetup.

@Test
public void invokeTunnelWithDefaultSetup() throws Exception {
    loadContext("spring.devtools.remote.secret:supersecret");
    DispatcherFilter filter = this.context.getBean(DispatcherFilter.class);
    this.request.setRequestURI(DEFAULT_CONTEXT_PATH + "/debug");
    this.request.addHeader(DEFAULT_SECRET_HEADER_NAME, "supersecret");
    filter.doFilter(this.request, this.response, this.chain);
    assertTunnelInvoked(true);
}
Also used : DispatcherFilter(org.springframework.boot.devtools.remote.server.DispatcherFilter) Test(org.junit.Test)

Example 10 with DispatcherFilter

use of org.springframework.boot.devtools.remote.server.DispatcherFilter in project spring-boot by spring-projects.

the class RemoteDevToolsAutoConfigurationTests method devToolsHealthWithCustomServerContextPathReturns200.

@Test
void devToolsHealthWithCustomServerContextPathReturns200() 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);
    this.request.addHeader(DEFAULT_SECRET_HEADER_NAME, "supersecret");
    this.response.setStatus(500);
    filter.doFilter(this.request, this.response, this.chain);
    assertThat(this.response.getStatus()).isEqualTo(200);
}
Also used : DispatcherFilter(org.springframework.boot.devtools.remote.server.DispatcherFilter) Test(org.junit.jupiter.api.Test)

Aggregations

DispatcherFilter (org.springframework.boot.devtools.remote.server.DispatcherFilter)14 Test (org.junit.jupiter.api.Test)11 MockMvc (org.springframework.test.web.servlet.MockMvc)4 Test (org.junit.Test)3 Filter (jakarta.servlet.Filter)1 PropertyPlaceholderAutoConfiguration (org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration)1 SourceDirectoryUrlFilter (org.springframework.boot.devtools.restart.server.SourceDirectoryUrlFilter)1 AnnotationConfigServletWebApplicationContext (org.springframework.boot.web.servlet.context.AnnotationConfigServletWebApplicationContext)1 MockServletContext (org.springframework.mock.web.MockServletContext)1