From 50434813532ff5611a05f92c947ed5ffa72848ad Mon Sep 17 00:00:00 2001 From: Peter Palaga Date: Wed, 27 Nov 2024 16:18:38 +0100 Subject: [PATCH] Reproduce Regression after 576ba7c: io.vertx.core.http.HttpServerRequest.absoluteURI() does not contain port anymore #44776 --- .../vertx/http/AllowXForwardedHostTest.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/AllowXForwardedHostTest.java diff --git a/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/AllowXForwardedHostTest.java b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/AllowXForwardedHostTest.java new file mode 100644 index 0000000000000..bb68aa2b740f5 --- /dev/null +++ b/extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/AllowXForwardedHostTest.java @@ -0,0 +1,37 @@ +package io.quarkus.vertx.http; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.hamcrest.Matchers; +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.test.QuarkusUnitTest; +import io.restassured.RestAssured; + +public class AllowXForwardedHostTest { + + @RegisterExtension + static final QuarkusUnitTest config = new QuarkusUnitTest() + .withApplicationRoot((jar) -> jar + .addClasses(ForwardedHandlerInitializer.class) + .addAsResource(new StringAsset( + "quarkus.http.proxy.proxy-address-forwarding=true\n" + + "quarkus.http.proxy.enable-forwarded-host=true\n"), + "application.properties")); + + @Test + public void testXForwardedProtoOverridesForwardedProto() { + assertThat(RestAssured.get("/path").asString()).startsWith("http|"); + + RestAssured.given() + .header("X-Forwarded-Host", "foo") + .get("/path") + .then() + .body( + Matchers.startsWith("http|foo:8081|"), + Matchers.endsWith("|/path|http://foo:8081/path")); + } + +} \ No newline at end of file