use of org.springframework.security.authentication.AuthenticationEventPublisher in project spring-security-oauth by spring-projects.
the class OAuth2AuthenticationProcessingFilterTests method testNoEventsPublishedWithNoToken.
@Test
public void testNoEventsPublishedWithNoToken() throws Exception {
AuthenticationEventPublisher eventPublisher = Mockito.mock(AuthenticationEventPublisher.class);
filter.setAuthenticationEventPublisher(eventPublisher);
filter.doFilter(request, null, chain);
Mockito.verify(eventPublisher, Mockito.never()).publishAuthenticationFailure(Mockito.any(AuthenticationException.class), Mockito.any(Authentication.class));
Mockito.verify(eventPublisher, Mockito.never()).publishAuthenticationSuccess(Mockito.any(Authentication.class));
}
use of org.springframework.security.authentication.AuthenticationEventPublisher in project spring-security-oauth by spring-projects.
the class OAuth2AuthenticationProcessingFilterTests method testSuccessEventsPublishedWithToken.
@Test
public void testSuccessEventsPublishedWithToken() throws Exception {
request.addHeader("Authorization", "Bearer FOO");
AuthenticationEventPublisher eventPublisher = Mockito.mock(AuthenticationEventPublisher.class);
filter.setAuthenticationEventPublisher(eventPublisher);
filter.doFilter(request, null, chain);
Mockito.verify(eventPublisher, Mockito.never()).publishAuthenticationFailure(Mockito.any(AuthenticationException.class), Mockito.any(Authentication.class));
Mockito.verify(eventPublisher).publishAuthenticationSuccess(Mockito.any(Authentication.class));
}
use of org.springframework.security.authentication.AuthenticationEventPublisher in project spring-security-oauth by spring-projects.
the class OAuth2AuthenticationProcessingFilterTests method testFailureEventsPublishedWithBadToken.
@Test
public void testFailureEventsPublishedWithBadToken() throws Exception {
request.addHeader("Authorization", "Bearer BAD");
AuthenticationEventPublisher eventPublisher = Mockito.mock(AuthenticationEventPublisher.class);
filter.setAuthenticationEventPublisher(eventPublisher);
filter.doFilter(request, response, chain);
Mockito.verify(eventPublisher).publishAuthenticationFailure(Mockito.any(AuthenticationException.class), Mockito.any(Authentication.class));
Mockito.verify(eventPublisher, Mockito.never()).publishAuthenticationSuccess(Mockito.any(Authentication.class));
}
Aggregations