|
|
|
@ -85,6 +85,35 @@ public class ForwardedHeaderFilterTests {
@@ -85,6 +85,35 @@ public class ForwardedHeaderFilterTests {
|
|
|
|
|
assertEquals("/foo/bar/baz", filterAndGetContextPath()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void contextPathWithForwardedPrefix() throws Exception { |
|
|
|
|
this.request.addHeader(X_FORWARDED_PREFIX, "/prefix"); |
|
|
|
|
this.request.setContextPath("/mvc-showcase"); |
|
|
|
|
|
|
|
|
|
String actual = filterAndGetContextPath(); |
|
|
|
|
assertEquals("/prefix", actual); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void contextPathWithForwardedPrefixTrailingSlash() throws Exception { |
|
|
|
|
this.request.addHeader(X_FORWARDED_PREFIX, "/prefix/"); |
|
|
|
|
this.request.setContextPath("/mvc-showcase"); |
|
|
|
|
|
|
|
|
|
String actual = filterAndGetContextPath(); |
|
|
|
|
assertEquals("/prefix", actual); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void contextPathPreserveEncoding() throws Exception { |
|
|
|
|
this.request.setContextPath("/app%20"); |
|
|
|
|
this.request.setRequestURI("/app%20/path/"); |
|
|
|
|
HttpServletRequest actual = filterAndGetWrappedRequest(); |
|
|
|
|
|
|
|
|
|
assertEquals("/app%20", actual.getContextPath()); |
|
|
|
|
assertEquals("/app%20/path/", actual.getRequestURI()); |
|
|
|
|
assertEquals("http://localhost/app%20/path/", actual.getRequestURL().toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void requestUri() throws Exception { |
|
|
|
|
this.request.addHeader(X_FORWARDED_PREFIX, "/"); |
|
|
|
@ -227,35 +256,6 @@ public class ForwardedHeaderFilterTests {
@@ -227,35 +256,6 @@ public class ForwardedHeaderFilterTests {
|
|
|
|
|
assertEquals("http://localhost/prefix/mvc-showcase", actual.getRequestURL().toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void contextPathWithForwardedPrefix() throws Exception { |
|
|
|
|
this.request.addHeader(X_FORWARDED_PREFIX, "/prefix"); |
|
|
|
|
this.request.setContextPath("/mvc-showcase"); |
|
|
|
|
|
|
|
|
|
String actual = filterAndGetContextPath(); |
|
|
|
|
assertEquals("/prefix", actual); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void contextPathWithForwardedPrefixTrailingSlash() throws Exception { |
|
|
|
|
this.request.addHeader(X_FORWARDED_PREFIX, "/prefix/"); |
|
|
|
|
this.request.setContextPath("/mvc-showcase"); |
|
|
|
|
|
|
|
|
|
String actual = filterAndGetContextPath(); |
|
|
|
|
assertEquals("/prefix", actual); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void contextPathPreserveEncoding() throws Exception { |
|
|
|
|
this.request.setContextPath("/app%20"); |
|
|
|
|
this.request.setRequestURI("/app%20/path/"); |
|
|
|
|
HttpServletRequest actual = filterAndGetWrappedRequest(); |
|
|
|
|
|
|
|
|
|
assertEquals("/app%20", actual.getContextPath()); |
|
|
|
|
assertEquals("/app%20/path/", actual.getRequestURI()); |
|
|
|
|
assertEquals("http://localhost/app%20/path/", actual.getRequestURL().toString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void sendRedirectWithAbsolutePath() throws Exception { |
|
|
|
|
this.request.addHeader(X_FORWARDED_PROTO, "https"); |
|
|
|
|