diff --git a/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/test/BaseWebClientTests.java b/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/test/BaseWebClientTests.java index c7020fd0b..31c95cc22 100644 --- a/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/test/BaseWebClientTests.java +++ b/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/test/BaseWebClientTests.java @@ -66,18 +66,20 @@ public class BaseWebClientTests { @Before public void setup() { - ClientHttpConnector httpConnector = new ReactorClientHttpConnector(); + setup(new ReactorClientHttpConnector(), "http://localhost:" + port); + } - baseUri = "http://localhost:" + port; + protected void setup(ClientHttpConnector httpConnector, String baseUri) { + this.baseUri = baseUri; this.webClient = WebClient.builder().clientConnector(httpConnector) - .baseUrl(baseUri).build(); - this.testClient = WebTestClient.bindToServer().baseUrl(baseUri).build(); + .baseUrl(this.baseUri).build(); + this.testClient = WebTestClient.bindToServer(httpConnector).baseUrl(this.baseUri) + .build(); } @Configuration @RibbonClients({ - @RibbonClient(name = "testservice", configuration = TestRibbonConfig.class), - @RibbonClient(name = "myservice", configuration = TestRibbonConfig.class) }) + @RibbonClient(name = "testservice", configuration = TestRibbonConfig.class) }) @Import(PermitAllSecurityConfiguration.class) public static class DefaultTestConfig { diff --git a/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/test/ssl/SingleCertSSLTests.java b/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/test/ssl/SingleCertSSLTests.java index d45101850..6af15d4d9 100644 --- a/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/test/ssl/SingleCertSSLTests.java +++ b/spring-cloud-gateway-core/src/test/java/org/springframework/cloud/gateway/test/ssl/SingleCertSSLTests.java @@ -32,15 +32,12 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.cloud.gateway.test.BaseWebClientTests; import org.springframework.context.annotation.Import; import org.springframework.http.ResponseEntity; -import org.springframework.http.client.reactive.ClientHttpConnector; import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.reactive.function.client.WebClient; import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; @@ -55,16 +52,10 @@ public class SingleCertSSLTests extends BaseWebClientTests { try { SslContext sslContext = SslContextBuilder.forClient() .trustManager(InsecureTrustManagerFactory.INSTANCE).build(); - HttpClient httpClient = HttpClient.create().secure(ssl -> { - ssl.sslContext(sslContext); - }); - ClientHttpConnector httpConnector = new ReactorClientHttpConnector( - httpClient); - baseUri = "https://localhost:" + port; - this.webClient = WebClient.builder().clientConnector(httpConnector) - .baseUrl(baseUri).build(); - this.testClient = WebTestClient.bindToServer(httpConnector).baseUrl(baseUri) - .build(); + HttpClient httpClient = HttpClient.create() + .secure(ssl -> ssl.sslContext(sslContext)); + setup(new ReactorClientHttpConnector(httpClient), + "https://localhost:" + port); } catch (SSLException e) { throw new RuntimeException(e); diff --git a/spring-cloud-gateway-core/src/test/resources/application-logging.yml b/spring-cloud-gateway-core/src/test/resources/application-logging.yml new file mode 100644 index 000000000..c07e955ae --- /dev/null +++ b/spring-cloud-gateway-core/src/test/resources/application-logging.yml @@ -0,0 +1,8 @@ +logging: + level: + org.springframework.cloud.gateway: TRACE + org.springframework.http.server.reactive: DEBUG + org.springframework.web.reactive: DEBUG + org.springframework.boot.autoconfigure.web: DEBUG + reactor.netty: DEBUG + redisratelimiter: DEBUG \ No newline at end of file diff --git a/spring-cloud-gateway-core/src/test/resources/application-multi-cert-ssl.yml b/spring-cloud-gateway-core/src/test/resources/application-multi-cert-ssl.yml index 60c3d3637..5ab3bed37 100644 --- a/spring-cloud-gateway-core/src/test/resources/application-multi-cert-ssl.yml +++ b/spring-cloud-gateway-core/src/test/resources/application-multi-cert-ssl.yml @@ -1,5 +1,4 @@ test: - hostport: httpbin.org:80 uri: lb:https://testservice server: @@ -28,11 +27,3 @@ spring: args: pattern: /** -logging: - level: - org.springframework.cloud.gateway: TRACE - org.springframework.http.server.reactive: DEBUG - org.springframework.web.reactive: DEBUG - reactor.ipc.netty: DEBUG - redisratelimiter: DEBUG - diff --git a/spring-cloud-gateway-core/src/test/resources/application-redis-rate-limiter-config.yml b/spring-cloud-gateway-core/src/test/resources/application-redis-rate-limiter-config.yml index 1fd28017e..85ac957d9 100644 --- a/spring-cloud-gateway-core/src/test/resources/application-redis-rate-limiter-config.yml +++ b/spring-cloud-gateway-core/src/test/resources/application-redis-rate-limiter-config.yml @@ -1,6 +1,3 @@ -test: - uri: lb://myservice - spring: cloud: gateway: diff --git a/spring-cloud-gateway-core/src/test/resources/application-redis-rate-limiter-default-config.yml b/spring-cloud-gateway-core/src/test/resources/application-redis-rate-limiter-default-config.yml index 603bd9b35..e1ba40799 100644 --- a/spring-cloud-gateway-core/src/test/resources/application-redis-rate-limiter-default-config.yml +++ b/spring-cloud-gateway-core/src/test/resources/application-redis-rate-limiter-default-config.yml @@ -1,6 +1,3 @@ -test: - uri: lb://myservice - spring: cloud: gateway: diff --git a/spring-cloud-gateway-core/src/test/resources/application-remote-address.yml b/spring-cloud-gateway-core/src/test/resources/application-remote-address.yml index 0fdef541f..12795440c 100644 --- a/spring-cloud-gateway-core/src/test/resources/application-remote-address.yml +++ b/spring-cloud-gateway-core/src/test/resources/application-remote-address.yml @@ -1,6 +1,3 @@ -test: - uri: lb://myservice - spring: cloud: gateway: diff --git a/spring-cloud-gateway-core/src/test/resources/application-removenonproxyheaders.yml b/spring-cloud-gateway-core/src/test/resources/application-removenonproxyheaders.yml index d4fa27325..f95895dbb 100644 --- a/spring-cloud-gateway-core/src/test/resources/application-removenonproxyheaders.yml +++ b/spring-cloud-gateway-core/src/test/resources/application-removenonproxyheaders.yml @@ -7,7 +7,6 @@ spring: routes: # ===================================== - id: remove_request_header_test - # uri: http://httpbin.org:80 uri: lb://testservice predicates: - Host=**.removenonproxyheaders.org diff --git a/spring-cloud-gateway-core/src/test/resources/application-request-header-web-filter.yml b/spring-cloud-gateway-core/src/test/resources/application-request-header-web-filter.yml index 73cd8ad3e..3778f9a44 100644 --- a/spring-cloud-gateway-core/src/test/resources/application-request-header-web-filter.yml +++ b/spring-cloud-gateway-core/src/test/resources/application-request-header-web-filter.yml @@ -1,7 +1,3 @@ -test: - hostport: httpbin.org:80 - uri: lb://testservice - spring: cloud: gateway: diff --git a/spring-cloud-gateway-core/src/test/resources/application-request-parameter-web-filter.yml b/spring-cloud-gateway-core/src/test/resources/application-request-parameter-web-filter.yml index 2a23b506f..b0190007d 100644 --- a/spring-cloud-gateway-core/src/test/resources/application-request-parameter-web-filter.yml +++ b/spring-cloud-gateway-core/src/test/resources/application-request-parameter-web-filter.yml @@ -1,7 +1,3 @@ -test: - hostport: httpbin.org:80 - uri: lb://testservice - spring: cloud: gateway: diff --git a/spring-cloud-gateway-core/src/test/resources/application-save-session-web-filter.yml b/spring-cloud-gateway-core/src/test/resources/application-save-session-web-filter.yml index 2bb160083..110bb930d 100644 --- a/spring-cloud-gateway-core/src/test/resources/application-save-session-web-filter.yml +++ b/spring-cloud-gateway-core/src/test/resources/application-save-session-web-filter.yml @@ -1,7 +1,3 @@ -test: - hostport: httpbin.org:80 - uri: lb://testservice - spring: cloud: gateway: diff --git a/spring-cloud-gateway-core/src/test/resources/application-single-cert-ssl.yml b/spring-cloud-gateway-core/src/test/resources/application-single-cert-ssl.yml index 7c184e4f2..61866d25b 100644 --- a/spring-cloud-gateway-core/src/test/resources/application-single-cert-ssl.yml +++ b/spring-cloud-gateway-core/src/test/resources/application-single-cert-ssl.yml @@ -1,5 +1,4 @@ test: - hostport: httpbin.org:80 uri: lb:https://testservice server: @@ -28,11 +27,3 @@ spring: args: pattern: /** -logging: - level: - org.springframework.cloud.gateway: TRACE - org.springframework.http.server.reactive: DEBUG - org.springframework.web.reactive: DEBUG - reactor.ipc.netty: DEBUG - redisratelimiter: DEBUG - diff --git a/spring-cloud-gateway-core/src/test/resources/application-weights-404.yml b/spring-cloud-gateway-core/src/test/resources/application-weights-404.yml index 95b460841..49ffb6d5b 100644 --- a/spring-cloud-gateway-core/src/test/resources/application-weights-404.yml +++ b/spring-cloud-gateway-core/src/test/resources/application-weights-404.yml @@ -1,6 +1,3 @@ -test: - uri: lb://testservice - spring: cloud: gateway: diff --git a/spring-cloud-gateway-core/src/test/resources/application.yml b/spring-cloud-gateway-core/src/test/resources/application.yml index 0a0b2491b..8b2933954 100644 --- a/spring-cloud-gateway-core/src/test/resources/application.yml +++ b/spring-cloud-gateway-core/src/test/resources/application.yml @@ -5,6 +5,9 @@ test: uri: lb://testservice spring: + profiles: + include: logging + cloud: gateway: globalcors: @@ -141,7 +144,7 @@ spring: # ===================================== - id: load_balancer_client_test - uri: lb://myservice + uri: lb://testservice predicates: - Host=**.loadbalancerclient.org @@ -346,17 +349,7 @@ spring: hystrix.command.successcmd.execution.isolation.thread.timeoutInMilliseconds: 5000 -logging: - level: - org.springframework.cloud.gateway: TRACE - org.springframework.http.server.reactive: DEBUG - org.springframework.web.reactive: DEBUG - org.springframework.boot.autoconfigure.web: DEBUG - reactor.netty: DEBUG - redisratelimiter: DEBUG - eureka: client: enabled: false -# port: 8081