Search in sources :

Example 1 with AccountStatusUserDetailsChecker

use of org.springframework.security.authentication.AccountStatusUserDetailsChecker in project spring-security by spring-projects.

the class AbstractRememberMeServicesTests method autoLoginShouldFailIfUserAccountIsLocked.

@Test
public void autoLoginShouldFailIfUserAccountIsLocked() {
    MockRememberMeServices services = new MockRememberMeServices(uds);
    services.setUserDetailsChecker(new AccountStatusUserDetailsChecker());
    uds.toReturn = new User("joe", "password", false, true, true, true, joe.getAuthorities());
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setCookies(createLoginCookie("cookie:1:2"));
    MockHttpServletResponse response = new MockHttpServletResponse();
    Authentication result = services.autoLogin(request, response);
    assertThat(result).isNull();
    assertCookieCancelled(response);
}
Also used : AccountStatusUserDetailsChecker(org.springframework.security.authentication.AccountStatusUserDetailsChecker) User(org.springframework.security.core.userdetails.User) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Authentication(org.springframework.security.core.Authentication) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test) PrepareOnlyThisForTest(org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)

Aggregations

Test (org.junit.Test)1 PrepareOnlyThisForTest (org.powermock.core.classloader.annotations.PrepareOnlyThisForTest)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 AccountStatusUserDetailsChecker (org.springframework.security.authentication.AccountStatusUserDetailsChecker)1 Authentication (org.springframework.security.core.Authentication)1 User (org.springframework.security.core.userdetails.User)1