use of org.orcid.frontend.web.forms.OneTimeResetPasswordForm in project ORCID-Source by ORCID.
the class PasswordResetController method getResetPassword.
@RequestMapping(value = "/password-reset.json", method = RequestMethod.GET)
@ResponseBody
public OneTimeResetPasswordForm getResetPassword() {
OneTimeResetPasswordForm form = new OneTimeResetPasswordForm();
form.setSecurityQuestionId(0);
return form;
}
use of org.orcid.frontend.web.forms.OneTimeResetPasswordForm in project ORCID-Source by ORCID.
the class PasswordResetControllerTest method testSubmitConsolidatedPasswordReset.
@Test
public void testSubmitConsolidatedPasswordReset() throws Exception {
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
BindingResult bindingResult = mock(BindingResult.class);
OneTimeResetPasswordForm oneTimeResetPasswordForm = new OneTimeResetPasswordForm();
oneTimeResetPasswordForm.setEncryptedEmail("encrypted string not expired");
when(encryptionManager.decryptForExternalUse(any(String.class))).thenReturn("email=any@orcid.org&issueDate=2070-05-29T17:04:27");
when(bindingResult.hasErrors()).thenReturn(true);
oneTimeResetPasswordForm = passwordResetController.submitPasswordReset(servletRequest, servletResponse, oneTimeResetPasswordForm);
assertFalse(oneTimeResetPasswordForm.getErrors().isEmpty());
oneTimeResetPasswordForm.setPassword("Password#123");
when(bindingResult.hasErrors()).thenReturn(false);
when(orcidProfileManager.retrieveOrcidProfileByEmail(eq("any@orcid.org"), Matchers.<LoadOptions>any())).thenReturn(orcidWithSecurityQuestion());
oneTimeResetPasswordForm = passwordResetController.submitPasswordReset(servletRequest, servletResponse, oneTimeResetPasswordForm);
assertTrue(oneTimeResetPasswordForm.getSuccessRedirectLocation().equals("https://testserver.orcid.org/my-orcid") || oneTimeResetPasswordForm.getSuccessRedirectLocation().equals("https://localhost:8443/orcid-web/my-orcid"));
verify(redirectAttributes, never()).addFlashAttribute("passwordResetLinkExpired", true);
when(encryptionManager.decryptForExternalUse(any(String.class))).thenReturn("email=any@orcid.org&issueDate=1970-05-29T17:04:27");
oneTimeResetPasswordForm = passwordResetController.submitPasswordReset(servletRequest, servletResponse, oneTimeResetPasswordForm);
assertFalse(oneTimeResetPasswordForm.getErrors().isEmpty());
}
use of org.orcid.frontend.web.forms.OneTimeResetPasswordForm in project ORCID-Source by ORCID.
the class PasswordResetControllerTest method testResetPasswordDontFailIfAnyFieldIsEmtpy.
@Test
public void testResetPasswordDontFailIfAnyFieldIsEmtpy() {
OneTimeResetPasswordForm form = new OneTimeResetPasswordForm();
passwordResetController.resetPasswordConfirmValidate(form);
form.setPassword("");
form.setRetypedPassword(null);
passwordResetController.resetPasswordConfirmValidate(form);
form.setPassword(null);
form.setRetypedPassword("");
passwordResetController.resetPasswordConfirmValidate(form);
}
Aggregations