Issue #5224 - Updating ForwardedRequestCustomizerTest expectations

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2020-09-08 12:34:53 -05:00
parent e2134b13d7
commit 2896ed31d6
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
2 changed files with 8 additions and 10 deletions

View File

@ -598,18 +598,18 @@ public class ForwardedRequestCustomizer implements Customizer
@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;
}
}

View File

@ -508,8 +508,8 @@ public class ForwardedRequestCustomizerTest
"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)")
@ -523,8 +523,8 @@ public class ForwardedRequestCustomizerTest
"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)")
@ -645,7 +645,6 @@ public class ForwardedRequestCustomizerTest
@ParameterizedTest(name = "{0}")
@MethodSource("cases")
@SuppressWarnings("unused")
public void testDefaultBehavior(Request request, Expectations expectations) throws Exception
{
request.configure(customizer);
@ -661,7 +660,6 @@ public class ForwardedRequestCustomizerTest
@ParameterizedTest(name = "{0}")
@MethodSource("cases")
@SuppressWarnings("unused")
public void testConfiguredBehavior(Request request, Expectations expectations) throws Exception
{
request.configure(customizerConfigured);