Search in sources :

Example 1 with InMemoryExpiringCodeStore

use of org.cloudfoundry.identity.uaa.codestore.InMemoryExpiringCodeStore in project uaa by cloudfoundry.

the class ResetPasswordAuthenticationFilterTest method setup.

@Before
public void setup() {
    codeStore = new InMemoryExpiringCodeStore(new TimeServiceImpl());
    code = codeStore.generateCode("{}", new Timestamp(System.currentTimeMillis() + 10 * 60 * 1000), "", IdentityZoneHolder.get().getId()).getCode();
    password = "test";
    passwordConfirmation = "test";
    email = "test@test.org";
    request = new MockHttpServletRequest("POST", "/reset_password.do");
    request.setParameter("code", code);
    request.setParameter("password", password);
    request.setParameter("password_confirmation", passwordConfirmation);
    request.setParameter("email", email);
    response = mock(HttpServletResponse.class);
    chain = mock(FilterChain.class);
    service = mock(ResetPasswordService.class);
    user = new ScimUser("id", "username", "first name", "last name");
    resetPasswordResponse = new ResetPasswordService.ResetPasswordResponse(user, "/", null);
    when(service.resetPassword(any(ExpiringCode.class), eq(password))).thenReturn(resetPasswordResponse);
    authenticationSuccessHandler = mock(AuthenticationSuccessHandler.class);
    entryPoint = mock(AuthenticationEntryPoint.class);
    filter = new ResetPasswordAuthenticationFilter(service, authenticationSuccessHandler, entryPoint, codeStore);
}
Also used : ScimUser(org.cloudfoundry.identity.uaa.scim.ScimUser) AuthenticationSuccessHandler(org.springframework.security.web.authentication.AuthenticationSuccessHandler) TimeServiceImpl(org.cloudfoundry.identity.uaa.util.TimeServiceImpl) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) FilterChain(javax.servlet.FilterChain) HttpServletResponse(javax.servlet.http.HttpServletResponse) Timestamp(java.sql.Timestamp) InMemoryExpiringCodeStore(org.cloudfoundry.identity.uaa.codestore.InMemoryExpiringCodeStore) ExpiringCode(org.cloudfoundry.identity.uaa.codestore.ExpiringCode) AuthenticationEntryPoint(org.springframework.security.web.AuthenticationEntryPoint) Before(org.junit.Before)

Aggregations

Timestamp (java.sql.Timestamp)1 FilterChain (javax.servlet.FilterChain)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 ExpiringCode (org.cloudfoundry.identity.uaa.codestore.ExpiringCode)1 InMemoryExpiringCodeStore (org.cloudfoundry.identity.uaa.codestore.InMemoryExpiringCodeStore)1 ScimUser (org.cloudfoundry.identity.uaa.scim.ScimUser)1 TimeServiceImpl (org.cloudfoundry.identity.uaa.util.TimeServiceImpl)1 Before (org.junit.Before)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 AuthenticationEntryPoint (org.springframework.security.web.AuthenticationEntryPoint)1 AuthenticationSuccessHandler (org.springframework.security.web.authentication.AuthenticationSuccessHandler)1