|
|
|
@ -51,6 +51,7 @@ import static org.mockito.Mockito.verify;
|
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
|
* @author Venil Noronha
|
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
|
* @author Madhura Bhave
|
|
|
|
|
*/
|
|
|
|
|
public class WebRequestTraceFilterTests {
|
|
|
|
|
|
|
|
|
@ -168,6 +169,43 @@ public class WebRequestTraceFilterTests {
|
|
|
|
|
assertThat(map.get("request").toString()).isEqualTo("{Accept=application/json}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@SuppressWarnings({ "unchecked" })
|
|
|
|
|
public void filterDoesNotAddAuthorizationHeaderWithoutAuthorizationHeaderInclude()
|
|
|
|
|
throws ServletException, IOException {
|
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
|
|
|
|
|
request.addHeader("Authorization", "my-auth-header");
|
|
|
|
|
MockHttpServletResponse response = new MockHttpServletResponse();
|
|
|
|
|
this.filter.doFilterInternal(request, response, new FilterChain() {
|
|
|
|
|
@Override
|
|
|
|
|
public void doFilter(ServletRequest request, ServletResponse response)
|
|
|
|
|
throws IOException, ServletException {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Map<String, Object> info = this.repository.findAll().iterator().next().getInfo();
|
|
|
|
|
Map<String, Object> headers = (Map<String, Object>) info.get("headers");
|
|
|
|
|
assertThat(((Map) headers.get("request"))).hasSize(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@SuppressWarnings({ "unchecked" })
|
|
|
|
|
public void filterAddsAuthorizationHeaderWhenAuthorizationHeaderIncluded()
|
|
|
|
|
throws ServletException, IOException {
|
|
|
|
|
this.properties.setInclude(EnumSet.of(Include.REQUEST_HEADERS, Include.AUTHORIZATION_HEADER));
|
|
|
|
|
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
|
|
|
|
|
request.addHeader("Authorization", "my-auth-header");
|
|
|
|
|
MockHttpServletResponse response = new MockHttpServletResponse();
|
|
|
|
|
this.filter.doFilterInternal(request, response, new FilterChain() {
|
|
|
|
|
@Override
|
|
|
|
|
public void doFilter(ServletRequest request, ServletResponse response)
|
|
|
|
|
throws IOException, ServletException {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Map<String, Object> info = this.repository.findAll().iterator().next().getInfo();
|
|
|
|
|
Map<String, Object> headers = (Map<String, Object>) info.get("headers");
|
|
|
|
|
assertThat(((Map) headers.get("request"))).containsKey("Authorization");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@SuppressWarnings({ "unchecked" })
|
|
|
|
|
public void filterDoesNotAddResponseCookiesWithCookiesExclude()
|
|
|
|
|