mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-02 20:09:21 +00:00
Issue #5224 - Updating ForwardedRequestCustomizerTest expectations
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
parent
e2134b13d7
commit
2896ed31d6
@ -598,18 +598,18 @@ public class ForwardedRequestCustomizer implements Customizer
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public void handleHost(HttpField field)
|
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 (getForwardedPortAsAuthority() && !StringUtil.isEmpty(getForwardedPortHeader()))
|
||||||
{
|
{
|
||||||
if (_host == null)
|
if (_host == null)
|
||||||
_host = new PossiblyPartialHostPort(hp.getHost(), hp.getPort());
|
_host = new PossiblyPartialHostPort(hostField.getHost(), hostField.getPort());
|
||||||
else if (_host instanceof PortSetHostPort)
|
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)
|
else if (_host == null)
|
||||||
{
|
{
|
||||||
_host = hp;
|
_host = hostField;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,8 +508,8 @@ public class ForwardedRequestCustomizerTest
|
|||||||
"X-Forwarded-Server: sub2.example.com"
|
"X-Forwarded-Server: sub2.example.com"
|
||||||
),
|
),
|
||||||
new Expectations()
|
new Expectations()
|
||||||
.scheme("https").serverName("sub1.example.com").serverPort(10002)
|
.scheme("https").serverName("sub1.example.com").serverPort(10003)
|
||||||
.requestURL("https://sub1.example.com:10002/")
|
.requestURL("https://sub1.example.com:10003/")
|
||||||
.remoteAddr("127.0.0.1").remotePort(8888)
|
.remoteAddr("127.0.0.1").remotePort(8888)
|
||||||
),
|
),
|
||||||
Arguments.of(new Request("X-Forwarded-* (Multiple Ports - Server First)")
|
Arguments.of(new Request("X-Forwarded-* (Multiple Ports - Server First)")
|
||||||
@ -523,8 +523,8 @@ public class ForwardedRequestCustomizerTest
|
|||||||
"X-Forwarded-Host: sub1.example.com:10003"
|
"X-Forwarded-Host: sub1.example.com:10003"
|
||||||
),
|
),
|
||||||
new Expectations()
|
new Expectations()
|
||||||
.scheme("https").serverName("sub1.example.com").serverPort(10002)
|
.scheme("https").serverName("sub1.example.com").serverPort(10003)
|
||||||
.requestURL("https://sub1.example.com:10002/")
|
.requestURL("https://sub1.example.com:10003/")
|
||||||
.remoteAddr("127.0.0.1").remotePort(8888)
|
.remoteAddr("127.0.0.1").remotePort(8888)
|
||||||
),
|
),
|
||||||
Arguments.of(new Request("X-Forwarded-* (Multiple Ports - setForwardedPortAsAuthority = false)")
|
Arguments.of(new Request("X-Forwarded-* (Multiple Ports - setForwardedPortAsAuthority = false)")
|
||||||
@ -645,7 +645,6 @@ public class ForwardedRequestCustomizerTest
|
|||||||
|
|
||||||
@ParameterizedTest(name = "{0}")
|
@ParameterizedTest(name = "{0}")
|
||||||
@MethodSource("cases")
|
@MethodSource("cases")
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public void testDefaultBehavior(Request request, Expectations expectations) throws Exception
|
public void testDefaultBehavior(Request request, Expectations expectations) throws Exception
|
||||||
{
|
{
|
||||||
request.configure(customizer);
|
request.configure(customizer);
|
||||||
@ -661,7 +660,6 @@ public class ForwardedRequestCustomizerTest
|
|||||||
|
|
||||||
@ParameterizedTest(name = "{0}")
|
@ParameterizedTest(name = "{0}")
|
||||||
@MethodSource("cases")
|
@MethodSource("cases")
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public void testConfiguredBehavior(Request request, Expectations expectations) throws Exception
|
public void testConfiguredBehavior(Request request, Expectations expectations) throws Exception
|
||||||
{
|
{
|
||||||
request.configure(customizerConfigured);
|
request.configure(customizerConfigured);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user