-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure Forwarded and X-Forwarded values are the same
- Loading branch information
1 parent
cbd735f
commit 6e9a414
Showing
5 changed files
with
290 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...c/test/java/io/quarkus/vertx/http/AllowForwardedHeadersOverrideXForwardedHeadersTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 AllowForwardedHeadersOverrideXForwardedHeadersTest { | ||
|
||
@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.allow-forwarded=true\n" + | ||
"quarkus.http.proxy.allow-x-forwarded=true\n" + | ||
"quarkus.http.proxy.strict-forwarded-control=false\n"), | ||
"application.properties")); | ||
|
||
@Test | ||
public void testXForwardedProtoOverridesForwardedProto() { | ||
assertThat(RestAssured.get("/path").asString()).startsWith("http|"); | ||
|
||
RestAssured.given() | ||
.header("Forwarded", "proto=https;for=backend2:5555;host=somehost2") | ||
.header("X-Forwarded-Proto", "http") | ||
.get("/path") | ||
.then() | ||
.body(Matchers.equalTo("http|somehost2|backend2:5555|/path|http://somehost2/path")); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.