Remove Devtools remote debugging support

Closes gh-9489
This commit is contained in:
Stephane Nicoll
2017-06-15 17:59:32 +02:00
parent bc4603925e
commit 8cae031441
16 changed files with 11 additions and 512 deletions

View File

@@ -31,8 +31,6 @@ import org.springframework.boot.devtools.restart.MockRestarter;
import org.springframework.boot.devtools.restart.server.HttpRestartServer;
import org.springframework.boot.devtools.restart.server.SourceFolderUrlFilter;
import org.springframework.boot.devtools.tunnel.server.HttpTunnelServer;
import org.springframework.boot.devtools.tunnel.server.RemoteDebugPortProvider;
import org.springframework.boot.devtools.tunnel.server.SocketTargetServerConnection;
import org.springframework.boot.devtools.tunnel.server.TargetServerConnection;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.Bean;
@@ -154,46 +152,6 @@ public class RemoteDevToolsAutoConfigurationTests {
this.context.getBean("remoteRestartHandlerMapper");
}
@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);
}
@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);
}
@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);
}
@Test
public void disableRemoteDebug() throws Exception {
loadContext("spring.devtools.remote.secret:supersecret",
"spring.devtools.remote.debug.enabled:false");
this.thrown.expect(NoSuchBeanDefinitionException.class);
this.context.getBean("remoteDebugHandlerMapper");
}
@Test
public void devToolsHealthReturns200() throws Exception {
loadContext("spring.devtools.remote.secret:supersecret");
@@ -239,12 +197,6 @@ public class RemoteDevToolsAutoConfigurationTests {
@Import(RemoteDevToolsAutoConfiguration.class)
static class Config {
@Bean
public HttpTunnelServer remoteDebugHttpTunnelServer() {
return new MockHttpTunnelServer(
new SocketTargetServerConnection(new RemoteDebugPortProvider()));
}
@Bean
public HttpRestartServer remoteRestartHttpRestartServer() {
SourceFolderUrlFilter sourceFolderUrlFilter = mock(

View File

@@ -1,72 +0,0 @@
/*
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.devtools.remote.client;
import java.net.ServerSocket;
import javax.net.ServerSocketFactory;
import org.junit.Test;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.mock.env.MockEnvironment;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
/**
* Tests for {@link LocalDebugPortAvailableCondition}.
*
* @author Phillip Webb
*/
public class LocalDebugPortAvailableConditionTests {
private LocalDebugPortAvailableCondition condition = new LocalDebugPortAvailableCondition();
@Test
public void portAvailable() throws Exception {
ConditionOutcome outcome = getOutcome(0);
assertThat(outcome.isMatch()).isTrue();
assertThat(outcome.getMessage())
.isEqualTo("Local Debug Port Condition found local debug port");
}
@Test
public void portInUse() throws Exception {
ServerSocket serverSocket = ServerSocketFactory.getDefault()
.createServerSocket(0);
ConditionOutcome outcome = getOutcome(serverSocket.getLocalPort());
serverSocket.close();
assertThat(outcome.isMatch()).isFalse();
assertThat(outcome.getMessage())
.isEqualTo("Local Debug Port Condition did not find local debug port");
}
private ConditionOutcome getOutcome(int port) {
MockEnvironment environment = new MockEnvironment();
TestPropertyValues.of("spring.devtools.remote.debug.local-port:" + port)
.applyTo(environment);
ConditionContext context = mock(ConditionContext.class);
given(context.getEnvironment()).willReturn(environment);
ConditionOutcome outcome = this.condition.getMatchOutcome(context, null);
return outcome;
}
}

View File

@@ -38,7 +38,6 @@ import org.springframework.boot.devtools.remote.server.Dispatcher;
import org.springframework.boot.devtools.remote.server.DispatcherFilter;
import org.springframework.boot.devtools.restart.MockRestarter;
import org.springframework.boot.devtools.restart.RestartScopeInitializer;
import org.springframework.boot.devtools.tunnel.client.TunnelClient;
import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
@@ -86,11 +85,10 @@ public class RemoteClientConfigurationTests {
}
@Test
public void warnIfDebugAndRestartDisabled() throws Exception {
configure("spring.devtools.remote.debug.enabled:false",
"spring.devtools.remote.restart.enabled:false");
public void warnIfRestartDisabled() throws Exception {
configure("spring.devtools.remote.restart.enabled:false");
assertThat(this.output.toString())
.contains("Remote restart and debug are both disabled");
.contains("Remote restart is disabled");
}
@Test
@@ -140,13 +138,6 @@ public class RemoteClientConfigurationTests {
this.context.getBean(ClassPathFileSystemWatcher.class);
}
@Test
public void remoteDebugDisabled() throws Exception {
configure("spring.devtools.remote.debug.enabled:false");
this.thrown.expect(NoSuchBeanDefinitionException.class);
this.context.getBean(TunnelClient.class);
}
private void configure(String... pairs) {
configure("http://localhost", true, pairs);
}

View File

@@ -146,15 +146,6 @@ public class HttpTunnelConnectionTests {
assertThat(this.requestFactory.getExecutedRequests().size()).isGreaterThan(10);
}
@Test
public void serviceUnavailableResponseLogsWarningAndClosesTunnel() throws Exception {
this.requestFactory.willRespond(HttpStatus.SERVICE_UNAVAILABLE);
TunnelChannel tunnel = openTunnel(true);
assertThat(tunnel.isOpen()).isFalse();
this.outputCapture.expect(containsString(
"Did you forget to start it with remote debugging enabled?"));
}
@Test
public void connectFailureLogsWarning() throws Exception {
this.requestFactory.willRespond(new ConnectException());