Polish
Group all contextPath tests together
This commit is contained in:
@@ -87,6 +87,35 @@ public class ForwardedHeaderFilterTests {
|
|||||||
assertEquals("/foo/bar/baz", filterAndGetContextPath());
|
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
|
@Test
|
||||||
public void requestUri() throws Exception {
|
public void requestUri() throws Exception {
|
||||||
this.request.addHeader(X_FORWARDED_PREFIX, "/");
|
this.request.addHeader(X_FORWARDED_PREFIX, "/");
|
||||||
@@ -231,35 +260,6 @@ public class ForwardedHeaderFilterTests {
|
|||||||
assertEquals("http://localhost/prefix/mvc-showcase", actual.getRequestURL().toString());
|
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
|
@Test
|
||||||
public void sendRedirectWithAbsolutePath() throws Exception {
|
public void sendRedirectWithAbsolutePath() throws Exception {
|
||||||
this.request.addHeader(X_FORWARDED_PROTO, "https");
|
this.request.addHeader(X_FORWARDED_PROTO, "https");
|
||||||
|
|||||||
Reference in New Issue
Block a user