コード例 #1
0
  @Test
  public void set_secured_headers() throws ServletException, IOException {
    underTest.init(mock(FilterConfig.class));
    HttpServletRequest request = newRequest("GET");

    underTest.doFilter(request, response, chain);

    verify(response, times(3)).addHeader(startsWith("X-"), anyString());

    underTest.destroy();
  }
コード例 #2
0
 private void assertThatMethodIsDenied(String httpMethod) throws IOException, ServletException {
   underTest.doFilter(newRequest(httpMethod), response, chain);
   verify(response).setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
 }
コード例 #3
0
 private void assertThatMethodIsAllowed(String httpMethod) throws IOException, ServletException {
   HttpServletRequest request = newRequest(httpMethod);
   underTest.doFilter(request, response, chain);
   verify(response, never()).setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
   verify(chain).doFilter(request, response);
 }