Search in sources :

Example 6 with AuthenticationException

use of org.craftercms.security.exception.AuthenticationException in project profile by craftercms.

the class LoginFailureHandlerImplTest method testSendError.

@Test
public void testSendError() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    RequestContext context = new RequestContext(request, response, null);
    handler.handle(context, new AuthenticationException());
    assertEquals(HttpServletResponse.SC_UNAUTHORIZED, response.getStatus());
    assertTrue(response.isCommitted());
}
Also used : AuthenticationException(org.craftercms.security.exception.AuthenticationException) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) RequestContext(org.craftercms.commons.http.RequestContext) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Aggregations

AuthenticationException (org.craftercms.security.exception.AuthenticationException)6 Test (org.junit.Test)4 RequestContext (org.craftercms.commons.http.RequestContext)2 Authentication (org.craftercms.security.authentication.Authentication)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 PersistentLogin (org.craftercms.profile.api.PersistentLogin)1 ProfileException (org.craftercms.profile.api.exceptions.ProfileException)1 CookieTheftException (org.craftercms.security.exception.rememberme.CookieTheftException)1 InvalidCookieException (org.craftercms.security.exception.rememberme.InvalidCookieException)1 RememberMeException (org.craftercms.security.exception.rememberme.RememberMeException)1