Search in sources :

Example 26 with InvalidPasswordException

use of org.cloudfoundry.identity.uaa.scim.exception.InvalidPasswordException in project uaa by cloudfoundry.

the class ResetPasswordAuthenticationFilterTest method error_during_password_reset_invalid_password_exception.

@Test
public void error_during_password_reset_invalid_password_exception() throws Exception {
    reset(service);
    InvalidPasswordException failed = new InvalidPasswordException("failed", HttpStatus.BAD_REQUEST);
    when(service.resetPassword(any(ExpiringCode.class), anyString())).thenThrow(failed);
    error_during_password_reset(failed.getClass());
    verify(service, times(1)).resetPassword(any(ExpiringCode.class), eq(password));
}
Also used : ExpiringCode(org.cloudfoundry.identity.uaa.codestore.ExpiringCode) InvalidPasswordException(org.cloudfoundry.identity.uaa.scim.exception.InvalidPasswordException) Test(org.junit.Test)

Example 27 with InvalidPasswordException

use of org.cloudfoundry.identity.uaa.scim.exception.InvalidPasswordException in project uaa by cloudfoundry.

the class UaaPasswordPolicyValidatorTests method validatePassword.

private void validatePassword(String password, String... expectedErrors) {
    ScimUser user = new ScimUser();
    user.setOrigin(OriginKeys.UAA);
    try {
        validator.validate(password);
        if (expectedErrors != null && expectedErrors.length > 0) {
            fail();
        }
    } catch (InvalidPasswordException e) {
        if (expectedErrors.length == 0) {
            fail("Didn't expect InvalidPasswordException, but messages were " + e.getErrorMessages());
        }
        for (String expectedError : expectedErrors) {
            assertTrue("Errors should contain:" + expectedError, e.getErrorMessages().contains(expectedError));
        }
    }
}
Also used : ScimUser(org.cloudfoundry.identity.uaa.scim.ScimUser) InvalidPasswordException(org.cloudfoundry.identity.uaa.scim.exception.InvalidPasswordException)

Aggregations

InvalidPasswordException (org.cloudfoundry.identity.uaa.scim.exception.InvalidPasswordException)27 Test (org.junit.jupiter.api.Test)10 ScimUser (org.cloudfoundry.identity.uaa.scim.ScimUser)9 ExpiringCode (org.cloudfoundry.identity.uaa.codestore.ExpiringCode)8 Timestamp (java.sql.Timestamp)5 BadCredentialsException (org.springframework.security.authentication.BadCredentialsException)5 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)5 Date (java.util.Date)4 UaaAuthentication (org.cloudfoundry.identity.uaa.authentication.UaaAuthentication)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 Test (org.junit.Test)4 Authentication (org.springframework.security.core.Authentication)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 InvalidCodeException (org.cloudfoundry.identity.uaa.authentication.InvalidCodeException)3 UaaException (org.cloudfoundry.identity.uaa.error.UaaException)3 ScimMeta (org.cloudfoundry.identity.uaa.scim.ScimMeta)3 UaaUser (org.cloudfoundry.identity.uaa.user.UaaUser)3 SecurityContext (org.springframework.security.core.context.SecurityContext)3 PasswordConfirmationValidation (org.cloudfoundry.identity.uaa.account.PasswordConfirmationValidation)2 PasswordConfirmationException (org.cloudfoundry.identity.uaa.account.PasswordConfirmationValidation.PasswordConfirmationException)2