|
|
|
@ -67,6 +67,29 @@ public class ForwardedHeadersFilterTests {
@@ -67,6 +67,29 @@ public class ForwardedHeadersFilterTests {
|
|
|
|
|
.containsEntry("for", "\"10.0.0.1:80\""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void noHostHeader() throws UnknownHostException { |
|
|
|
|
MockServerHttpRequest request = MockServerHttpRequest |
|
|
|
|
.get("http://localhost/get") |
|
|
|
|
.remoteAddress(new InetSocketAddress(InetAddress.getByName("10.0.0.1"), 80)) |
|
|
|
|
.build(); |
|
|
|
|
|
|
|
|
|
ForwardedHeadersFilter filter = new ForwardedHeadersFilter(); |
|
|
|
|
|
|
|
|
|
HttpHeaders headers = filter.filter(request.getHeaders(), MockServerWebExchange.from(request)); |
|
|
|
|
|
|
|
|
|
assertThat(headers.get(FORWARDED_HEADER)).hasSize(1); |
|
|
|
|
|
|
|
|
|
List<Forwarded> forwardeds = ForwardedHeadersFilter.parse(headers.get(FORWARDED_HEADER)); |
|
|
|
|
|
|
|
|
|
assertThat(forwardeds).hasSize(1); |
|
|
|
|
Forwarded forwarded = forwardeds.get(0); |
|
|
|
|
|
|
|
|
|
assertThat(forwarded.getValues()) |
|
|
|
|
.containsEntry("proto", "http") |
|
|
|
|
.containsEntry("for", "\"10.0.0.1:80\""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void forwardedParsedCorrectly() { |
|
|
|
|
String[] valid = new String[] { |
|
|
|
|