use of org.orcid.frontend.web.forms.ManagePasswordOptionsForm 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 org.orcid.frontend.web.forms.ManagePasswordOptionsForm 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 org.orcid.frontend.web.forms.ManagePasswordOptionsForm 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);
}
Aggregations