SEC-1639: FirewalledRequest is now called on the specific FirewalledRequest instance rather that looping through ServletRequestWrappers.
VirtualFilterChain now accepts the FirewalledRequest in the constructor. The reset method is called directly on the instance passed in instead of looping through the ServletRequestWrappers.
This commit is contained in:
@@ -22,6 +22,7 @@ import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Luke Taylor
|
||||
* @author Rob Winch
|
||||
*/
|
||||
@SuppressWarnings({"unchecked"})
|
||||
public class FilterChainProxyTests {
|
||||
@@ -126,4 +127,30 @@ public class FilterChainProxyTests {
|
||||
fcp.doFilter(request, response, chain);
|
||||
verify(fwr).reset();
|
||||
}
|
||||
}
|
||||
|
||||
// SEC-1639
|
||||
@Test
|
||||
public void bothWrappersAreResetWithNestedFcps() throws Exception {
|
||||
HttpFirewall fw = mock(HttpFirewall.class);
|
||||
FilterChainProxy firstFcp = new FilterChainProxy();
|
||||
LinkedHashMap fcm = new LinkedHashMap();
|
||||
fcm.put(matcher, Arrays.asList(fcp));
|
||||
firstFcp.setFilterChainMap(fcm);
|
||||
firstFcp.setFirewall(fw);
|
||||
fcp.setFirewall(fw);
|
||||
FirewalledRequest firstFwr = mock(FirewalledRequest.class, "firstFwr");
|
||||
when(firstFwr.getRequestURI()).thenReturn("/");
|
||||
when(firstFwr.getContextPath()).thenReturn("");
|
||||
FirewalledRequest fwr = mock(FirewalledRequest.class, "fwr");
|
||||
when(fwr.getRequestURI()).thenReturn("/");
|
||||
when(fwr.getContextPath()).thenReturn("");
|
||||
when(fw.getFirewalledRequest(request)).thenReturn(firstFwr);
|
||||
when(fw.getFirewalledRequest(firstFwr)).thenReturn(fwr);
|
||||
when(fwr.getRequest()).thenReturn(firstFwr);
|
||||
when(firstFwr.getRequest()).thenReturn(request);
|
||||
when(matcher.matches(any(HttpServletRequest.class))).thenReturn(true);
|
||||
firstFcp.doFilter(request, response, chain);
|
||||
verify(firstFwr).reset();
|
||||
verify(fwr).reset();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user