use of org.orcid.pojo.SecurityQuestion in project ORCID-Source by ORCID.
the class ManageProfileControllerTest method testSetSecurityQuestionWithEmptyAnswer.
@Test
public void testSetSecurityQuestionWithEmptyAnswer() {
SecurityQuestion s = new SecurityQuestion();
s.setPassword("password");
s.setSecurityAnswer("");
s.setSecurityQuestionId(1L);
controller.setSecurityQuestion(s);
assertEquals(1, s.getErrors().size());
assertEquals("manage.pleaseProvideAnAnswer", s.getErrors().get(0));
verify(mockProfileEntityManager, times(0)).updateSecurityQuestion(Mockito.anyString(), Mockito.any(), Mockito.any());
}
use of org.orcid.pojo.SecurityQuestion in project ORCID-Source by ORCID.
the class ManageProfileController method getSecurityQuestion.
@RequestMapping(value = "/security-question.json", method = RequestMethod.GET)
@ResponseBody
public SecurityQuestion getSecurityQuestion() {
ProfileEntity profile = profileEntityCacheManager.retrieve(getCurrentUserOrcid());
SecurityQuestion securityQuestion = new SecurityQuestion();
if (profile.getSecurityQuestion() != null) {
Long id = Long.valueOf(profile.getSecurityQuestion().getId());
String encryptedAnswer = profile.getEncryptedSecurityAnswer();
if (!PojoUtil.isEmpty(encryptedAnswer)) {
securityQuestion.setSecurityAnswer(encryptionManager.decryptForInternalUse(encryptedAnswer));
}
securityQuestion.setSecurityQuestionId(id);
}
return securityQuestion;
}
use of org.orcid.pojo.SecurityQuestion in project ORCID-Source by ORCID.
the class ManageProfileControllerTest method testSetSecurityQuestionWithIvalidPassword.
@Test
public void testSetSecurityQuestionWithIvalidPassword() {
SecurityQuestion s = new SecurityQuestion();
s.setPassword("invalid password");
s.setSecurityAnswer("answer");
s.setSecurityQuestionId(1L);
controller.setSecurityQuestion(s);
assertEquals(1, s.getErrors().size());
assertEquals("check_password_modal.incorrect_password", s.getErrors().get(0));
verify(mockProfileEntityManager, times(0)).updateSecurityQuestion(Mockito.anyString(), Mockito.any(), Mockito.any());
}
use of org.orcid.pojo.SecurityQuestion in project ORCID-Source by ORCID.
the class ManageProfileControllerTest method testSetSecurityQuestion.
@Test
public void testSetSecurityQuestion() {
SecurityContextHolder.getContext().setAuthentication(getAuthentication(USER_ORCID));
SecurityQuestion s = new SecurityQuestion();
s.setPassword("password");
s.setSecurityAnswer("answer");
s.setSecurityQuestionId(1L);
controller.setSecurityQuestion(s);
assertEquals(1, s.getErrors().size());
assertEquals("manage.securityQuestionUpdated", s.getErrors().get(0));
verify(mockProfileEntityManager, times(1)).updateSecurityQuestion(Mockito.eq(USER_ORCID), Mockito.eq(Integer.valueOf(1)), Mockito.eq("answer"));
}
Aggregations