Merge branch '3.1.x'

This commit is contained in:
spencergibb
2023-02-21 11:55:45 -05:00
3 changed files with 13 additions and 1 deletions

View File

@@ -78,7 +78,7 @@ public class RoutePredicateHandlerMapping extends AbstractHandlerMapping {
protected Mono<?> getHandlerInternal(ServerWebExchange exchange) {
// don't handle requests on management port if set and different than server port
if (this.managementPortType == DIFFERENT && this.managementPort != null
&& exchange.getRequest().getURI().getPort() == this.managementPort) {
&& exchange.getRequest().getLocalAddress().getPort() == this.managementPort) {
return Mono.empty();
}
exchange.getAttributes().put(GATEWAY_HANDLER_MAPPER_ATTR, getSimpleName());

View File

@@ -26,6 +26,7 @@ import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import io.netty.util.internal.PlatformDependent;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junitpioneer.jupiter.RetryingTest;
import reactor.core.publisher.Mono;
import reactor.netty.http.client.HttpClient;
@@ -71,6 +72,7 @@ class ModifyRequestBodyGatewayFilterFactorySslTimeoutTests extends BaseWebClient
@BeforeEach
public void setup() {
try {
System.err.println("in github = " + System.getenv("GITHUB_ACTIONS"));
SslContext sslContext = SslContextBuilder.forClient().trustManager(InsecureTrustManagerFactory.INSTANCE)
.build();
HttpClient httpClient = HttpClient.create().secure(ssl -> ssl.sslContext(sslContext));
@@ -82,6 +84,7 @@ class ModifyRequestBodyGatewayFilterFactorySslTimeoutTests extends BaseWebClient
}
@Test
@DisabledIfEnvironmentVariable(named = "GITHUB_ACTIONS", matches = "true")
void modifyRequestBodySSLTimeout() {
testClient.post().uri("/post").header("Host", "www.modifyrequestbodyssltimeout.org")
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML_VALUE)
@@ -90,6 +93,7 @@ class ModifyRequestBodyGatewayFilterFactorySslTimeoutTests extends BaseWebClient
.isEqualTo("handshake timed out after 1ms");
}
@DisabledIfEnvironmentVariable(named = "GITHUB_ACTIONS", matches = "true")
@RetryingTest(3)
void modifyRequestBodyRelease() {
releaseCount.set(0);
@@ -107,6 +111,7 @@ class ModifyRequestBodyGatewayFilterFactorySslTimeoutTests extends BaseWebClient
}
@Test
@DisabledIfEnvironmentVariable(named = "GITHUB_ACTIONS", matches = "true")
void modifyRequestBodyHappenedError() {
testClient.post().uri("/post").header("Host", "www.modifyrequestbodyexception.org")
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML_VALUE)

View File

@@ -60,6 +60,13 @@ public class RoutePredicateHandlerMappingIntegrationTests extends BaseWebClientT
.expectStatus().isNotFound();
}
@Test
public void requestsToManagementPortAndHostHeaderReturn404() {
String host = "example.com:8888";
testClient.mutate().baseUrl("http://localhost:" + managementPort).build().get().uri("/get").header("host", host)
.exchange().expectStatus().isNotFound();
}
@Test
public void andNotWorksWithMissingParameter() {
testClient.get().uri("/andnotquery").exchange().expectBody(String.class).isEqualTo("notsupplied");