Search in sources :

Example 11 with ChangePasswordForm

use of org.orcid.frontend.web.forms.ChangePasswordForm in project ORCID-Source by ORCID.

the class ChangePasswordFormValidatorTest method testPasswordMissingNumberInvalid.

@Test
public void testPasswordMissingNumberInvalid() {
    ChangePasswordForm form = new ChangePasswordForm();
    form.setOldPassword("£$$$$$$r");
    Set<ConstraintViolation<ChangePasswordForm>> violations = validator.validate(form);
    Map<String, String> allErrorValues = retrieveErrorKeyAndMessage(violations);
    String password = allErrorValues.get("oldPassword");
    assertEquals("Passwords must be 8 or more characters and contain at least 1 number and at least 1 alpha character or symbol", password);
    //add in a number
    form.setOldPassword("£$$$$$r1");
    violations = validator.validate(form);
    allErrorValues = retrieveErrorKeyAndMessage(violations);
    password = allErrorValues.get("oldPassword");
    assertNull(password);
}
Also used : ChangePasswordForm(org.orcid.frontend.web.forms.ChangePasswordForm) ConstraintViolation(javax.validation.ConstraintViolation) Test(org.junit.Test)

Aggregations

ConstraintViolation (javax.validation.ConstraintViolation)11 Test (org.junit.Test)11 ChangePasswordForm (org.orcid.frontend.web.forms.ChangePasswordForm)11