Search in sources :

Example 6 with ChangePasswordForm

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

the class ChangePasswordFormValidatorTest method testPasswordWithSymbolButNotCharacterValid.

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

Example 7 with ChangePasswordForm

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

the class ChangePasswordFormValidatorTest method testSymbolsPermitttedButNotRequired.

@Test
public void testSymbolsPermitttedButNotRequired() throws Exception {
    ChangePasswordForm form = new ChangePasswordForm();
    form.setOldPassword("Ben Kingsley  is my no. 1 actor");
    form.setPassword("passw0rd");
    form.setRetypedPassword("passw0rd");
    Set<ConstraintViolation<ChangePasswordForm>> errors = validator.validate(form);
    assertEquals("Should be no errors", 0, errors.size());
    //check that the test doesn't break when symbols introduced
    form.setPassword("p$ssw0rd");
    form.setRetypedPassword("p$ssw0rd");
    errors = validator.validate(form);
    assertEquals("Should be no errors", 0, errors.size());
}
Also used : ChangePasswordForm(org.orcid.frontend.web.forms.ChangePasswordForm) ConstraintViolation(javax.validation.ConstraintViolation) Test(org.junit.Test)

Example 8 with ChangePasswordForm

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

the class ChangePasswordFormValidatorTest method testPasswordLengthMin8.

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

Example 9 with ChangePasswordForm

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

the class ChangePasswordFormValidatorTest method testPasswordNumbersOnlyInvalid.

@Test
public void testPasswordNumbersOnlyInvalid() {
    ChangePasswordForm form = new ChangePasswordForm();
    form.setOldPassword("12345678");
    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 char
    form.setOldPassword("12345678b");
    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)

Example 10 with ChangePasswordForm

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

the class ChangePasswordFormValidatorTest method testSpacesPermittted.

@Test
public void testSpacesPermittted() throws Exception {
    ChangePasswordForm form = new ChangePasswordForm();
    form.setPassword("Ben Kingsley  is my no. 1 actor");
    form.setRetypedPassword("Ben Kingsley  is my no. 1 actor");
    form.setOldPassword("ååååååå1å");
    Set<ConstraintViolation<ChangePasswordForm>> errors = validator.validate(form);
    assertEquals("Should be no errors", 0, errors.size());
}
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