Group all contextPath tests together
This commit is contained in:
Rob Winch 2017-04-10 08:56:48 -05:00
parent 0a9f98f0df
commit f65e1edd58
1 changed files with 29 additions and 29 deletions

View File

@ -87,6 +87,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, "/");
@ -231,35 +260,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");