Search in sources :

Example 1 with OneTimeResetPasswordForm

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;
}
Also used : OneTimeResetPasswordForm(org.orcid.frontend.web.forms.OneTimeResetPasswordForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with OneTimeResetPasswordForm

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());
}
Also used : RedirectAttributes(org.springframework.web.servlet.mvc.support.RedirectAttributes) BindingResult(org.springframework.validation.BindingResult) OneTimeResetPasswordForm(org.orcid.frontend.web.forms.OneTimeResetPasswordForm) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with OneTimeResetPasswordForm

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);
}
Also used : OneTimeResetPasswordForm(org.orcid.frontend.web.forms.OneTimeResetPasswordForm) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

OneTimeResetPasswordForm (org.orcid.frontend.web.forms.OneTimeResetPasswordForm)3 Test (org.junit.Test)2 DBUnitTest (org.orcid.test.DBUnitTest)2 BindingResult (org.springframework.validation.BindingResult)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 RedirectAttributes (org.springframework.web.servlet.mvc.support.RedirectAttributes)1