@Test
public void shouldRejectUserThatHasNotRequiredRole() throws ServletException, IOException {

    // given
    final LdapProperties ldapProperties = mockLdapPropertiesWithRequiredRole("roleX");
    final LdapRoleAuthenticationFilter filter = new LdapRoleAuthenticationFilter(ldapProperties);
    final HttpServletRequest request = mockRequestWithAvailableRoles("roleA", "roleB");
    final HttpServletResponse response = mockResponse();
    final FilterChain filterChain = mockFilterChain();
    // when
    filter.doFilterInternal(request, response, filterChain);
    // then
    verifyZeroInteractions(filterChain);
    verify(response).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}