Skip to content

Commit

Permalink
Issue #5224 - Updating ForwardedRequestCustomizerTest expectations
Browse files Browse the repository at this point in the history
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
  • Loading branch information
joakime committed Sep 8, 2020
1 parent e2134b1 commit 2896ed3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -598,18 +598,18 @@ public void handleSslSessionId(HttpField field)
@SuppressWarnings("unused")
public void handleHost(HttpField field)
{
HostPort hp = new HostPort(getLeftMost(field.getValue()));
HostPort hostField = new HostPort(getLeftMost(field.getValue()));

if (getForwardedPortAsAuthority() && !StringUtil.isEmpty(getForwardedPortHeader()))
{
if (_host == null)
_host = new PossiblyPartialHostPort(hp.getHost(), hp.getPort());
_host = new PossiblyPartialHostPort(hostField.getHost(), hostField.getPort());
else if (_host instanceof PortSetHostPort)
_host = new HostPort(hp.getHost(), _host.getPort());
_host = new HostPort(hostField.getHost(), hostField.getPort() > 0 ? hostField.getPort() : _host.getPort());
}
else if (_host == null)
{
_host = hp;
_host = hostField;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,8 @@ public static Stream<Arguments> cases()
"X-Forwarded-Server: sub2.example.com"
),
new Expectations()
.scheme("https").serverName("sub1.example.com").serverPort(10002)
.requestURL("https://sub1.example.com:10002/")
.scheme("https").serverName("sub1.example.com").serverPort(10003)
.requestURL("https://sub1.example.com:10003/")
.remoteAddr("127.0.0.1").remotePort(8888)
),
Arguments.of(new Request("X-Forwarded-* (Multiple Ports - Server First)")
Expand All @@ -523,8 +523,8 @@ public static Stream<Arguments> cases()
"X-Forwarded-Host: sub1.example.com:10003"
),
new Expectations()
.scheme("https").serverName("sub1.example.com").serverPort(10002)
.requestURL("https://sub1.example.com:10002/")
.scheme("https").serverName("sub1.example.com").serverPort(10003)
.requestURL("https://sub1.example.com:10003/")
.remoteAddr("127.0.0.1").remotePort(8888)
),
Arguments.of(new Request("X-Forwarded-* (Multiple Ports - setForwardedPortAsAuthority = false)")
Expand Down Expand Up @@ -645,7 +645,6 @@ public static Stream<Arguments> cases()

@ParameterizedTest(name = "{0}")
@MethodSource("cases")
@SuppressWarnings("unused")
public void testDefaultBehavior(Request request, Expectations expectations) throws Exception
{
request.configure(customizer);
Expand All @@ -661,7 +660,6 @@ public void testDefaultBehavior(Request request, Expectations expectations) thro

@ParameterizedTest(name = "{0}")
@MethodSource("cases")
@SuppressWarnings("unused")
public void testConfiguredBehavior(Request request, Expectations expectations) throws Exception
{
request.configure(customizerConfigured);
Expand Down

0 comments on commit 2896ed3

Please sign in to comment.