use of javax.validation.ConstraintViolation in project ORCID-Source by ORCID.
the class ChangeSecurityDetailsValidatorTest method allValuesPopulatedHappyPath.
@Test
public void allValuesPopulatedHappyPath() {
ChangeSecurityQuestionForm form = new ChangeSecurityQuestionForm();
form.setSecurityQuestionAnswer("My answer");
form.setSecurityQuestionId(2);
Set<ConstraintViolation<ChangeSecurityQuestionForm>> errors = validator.validate(form);
assertEquals("Should be no errors", 0, errors.size());
}
use of javax.validation.ConstraintViolation in project ORCID-Source by ORCID.
the class ManagePasswordOptionsValidationFormTest method allValuesPopulatedHappyPath.
@Test
public void allValuesPopulatedHappyPath() {
ManagePasswordOptionsForm form = new ManagePasswordOptionsForm();
form.setPassword("passw0rd");
form.setRetypedPassword("passw0rd");
form.setSecurityQuestionId(1);
form.setSecurityQuestionAnswer("stan");
form.setVerificationNumber("9999");
Set<ConstraintViolation<ManagePasswordOptionsForm>> errors = validator.validate(form);
assertEquals("Should be no errors", 0, errors.size());
}
use of javax.validation.ConstraintViolation in project ORCID-Source by ORCID.
the class ManagePasswordOptionsValidationFormTest method testSpacesPermittted.
@Test
public void testSpacesPermittted() throws Exception {
ManagePasswordOptionsForm form = new ManagePasswordOptionsForm();
form.setPassword("Stellan Skasgård is my no. 1 actor");
form.setRetypedPassword("Stellan Skasgård is my no. 1 actor");
form.setSecurityQuestionId(1);
form.setSecurityQuestionAnswer("stan");
form.setVerificationNumber("9999");
Set<ConstraintViolation<ManagePasswordOptionsForm>> errors = validator.validate(form);
assertEquals("Should be no errors", 0, errors.size());
}
use of javax.validation.ConstraintViolation in project ORCID-Source by ORCID.
the class ManagePasswordOptionsValidationFormTest method testRegistrationFormInvalidData.
@Test
public void testRegistrationFormInvalidData() throws Exception {
ManagePasswordOptionsForm form = new ManagePasswordOptionsForm();
form.setSecurityQuestionId(0);
form.setVerificationNumber("999");
Set<ConstraintViolation<ManagePasswordOptionsForm>> violations = validator.validate(form);
Map<String, String> allErrorValues = retrieveErrorKeyAndMessage(violations);
String securityQuestion = allErrorValues.get("securityQuestionId");
String digits = allErrorValues.get("verificationNumber");
assertEquals("Please select a security question.", securityQuestion);
assertEquals("Please enter a 4 digit verification number", digits);
// also try a negative verification number just to make sure
form.setVerificationNumber("-7299");
violations = validator.validate(form);
allErrorValues = retrieveErrorKeyAndMessage(violations);
digits = allErrorValues.get("verificationNumber");
assertEquals("Please enter a 4 digit verification number", digits);
}
use of javax.validation.ConstraintViolation 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);
}
Aggregations