use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationControllerTest method regEmailsAdditonalValidateUnclaimedAccountTest.
@Test
public void regEmailsAdditonalValidateUnclaimedAccountTest() {
String additionalEmail = "email1@test.orcid.org";
String orcid = "0000-0000-0000-0000";
when(emailManager.emailExists(additionalEmail)).thenReturn(true);
when(emailManager.findOrcidIdByEmail(additionalEmail)).thenReturn(orcid);
when(profileEntityManager.isProfileClaimedByEmail(additionalEmail)).thenReturn(false);
when(profileEntityManager.isDeactivated(orcid)).thenReturn(false);
when(emailManager.isAutoDeprecateEnableForEmail(additionalEmail)).thenReturn(true);
Registration reg = new Registration();
List<Text> emailsAdditionalList = new ArrayList<Text>();
Text emailAdditional = new Text();
emailAdditional.setValue(additionalEmail);
emailsAdditionalList.add(emailAdditional);
reg.setEmailsAdditional(emailsAdditionalList);
reg = registrationController.regEmailsAdditionalValidate(servletRequest, reg, false, true);
assertNotNull(reg);
// No errors, since the account can be auto deprecated
assertTrue(reg.getEmail().getErrors().isEmpty());
assertNotNull(reg.getEmailsAdditional());
for (Text emailAdditionalListItem : reg.getEmailsAdditional()) {
assertNotNull(emailAdditionalListItem.getErrors());
assertTrue(emailAdditionalListItem.getErrors().isEmpty());
}
}
use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationControllerTest method regEmailValidateDeactivatedAccountTest.
@Test
public void regEmailValidateDeactivatedAccountTest() {
String email = "email1@test.orcid.org";
String orcid = "0000-0000-0000-0000";
when(emailManager.emailExists(email)).thenReturn(true);
when(emailManager.findOrcidIdByEmail(email)).thenReturn(orcid);
when(profileEntityManager.isProfileClaimedByEmail(email)).thenReturn(false);
// Set it as deactivated
when(profileEntityManager.isDeactivated(orcid)).thenReturn(true);
Registration reg = new Registration();
reg.setEmail(Text.valueOf("email1@test.orcid.org"));
reg.setEmailConfirm(Text.valueOf("email1@test.orcid.org"));
reg = registrationController.regEmailValidate(servletRequest, reg, false, true);
assertNotNull(reg);
assertNotNull(reg.getEmail());
assertNotNull(reg.getEmail().getErrors());
assertEquals(1, reg.getEmail().getErrors().size());
assertTrue(reg.getEmail().getErrors().get(0).startsWith("orcid.frontend.verify.deactivated_email"));
}
use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationControllerTest method regEmailValidateUnclaimedAccountTest.
@Test
public void regEmailValidateUnclaimedAccountTest() {
String email = "email1@test.orcid.org";
String orcid = "0000-0000-0000-0000";
when(emailManager.emailExists(email)).thenReturn(true);
when(emailManager.findOrcidIdByEmail(email)).thenReturn(orcid);
when(profileEntityManager.isProfileClaimedByEmail(email)).thenReturn(false);
when(profileEntityManager.isDeactivated(orcid)).thenReturn(false);
when(emailManager.isAutoDeprecateEnableForEmail(email)).thenReturn(true);
Registration reg = new Registration();
reg.setEmail(Text.valueOf("email1@test.orcid.org"));
reg.setEmailConfirm(Text.valueOf("email1@test.orcid.org"));
reg = registrationController.regEmailValidate(servletRequest, reg, false, true);
assertNotNull(reg);
assertNotNull(reg.getEmail());
assertNotNull(reg.getEmail().getErrors());
// No errors, since the account can be auto deprecated
assertTrue(reg.getEmail().getErrors().isEmpty());
}
use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationController method getRegister.
@RequestMapping(value = "/register.json", method = RequestMethod.GET)
@ResponseBody
public Registration getRegister(HttpServletRequest request, HttpServletResponse response) {
// Remove the session hash if needed
if (request.getSession().getAttribute(GRECAPTCHA_SESSION_ATTRIBUTE_NAME) != null) {
request.getSession().removeAttribute(GRECAPTCHA_SESSION_ATTRIBUTE_NAME);
}
Registration reg = new Registration();
reg.getEmail().setRequired(true);
reg.getEmailConfirm().setRequired(true);
reg.getEmailsAdditional().get(0).setRequired(false);
reg.getFamilyNames().setRequired(false);
reg.getGivenNames().setRequired(true);
reg.getSendChangeNotifications().setValue(true);
reg.getSendOrcidNews().setValue(true);
reg.getSendMemberUpdateRequests().setValue(true);
reg.getSendEmailFrequencyDays().setValue(SendEmailFrequency.WEEKLY.value());
reg.getTermsOfUse().setValue(false);
Boolean isOauth2ScreensRequest = (Boolean) request.getSession().getAttribute(OrcidOauth2Constants.OAUTH_2SCREENS);
if (isOauth2ScreensRequest != null) {
reg.setCreationType(Text.valueOf(CreationMethod.MEMBER_REFERRED.value()));
} else {
reg.setCreationType(Text.valueOf(CreationMethod.DIRECT.value()));
}
setError(reg.getTermsOfUse(), "validations.acceptTermsAndConditions");
RequestInfoForm requestInfoForm = (RequestInfoForm) request.getSession().getAttribute(OauthControllerBase.REQUEST_INFO_FORM);
if (requestInfoForm != null) {
if (!PojoUtil.isEmpty(requestInfoForm.getUserEmail())) {
reg.getEmail().setValue(requestInfoForm.getUserEmail());
}
if (!PojoUtil.isEmpty(requestInfoForm.getUserGivenNames())) {
reg.getGivenNames().setValue(requestInfoForm.getUserGivenNames());
}
if (!PojoUtil.isEmpty(requestInfoForm.getUserFamilyNames())) {
reg.getFamilyNames().setValue(requestInfoForm.getUserFamilyNames());
}
}
long numVal = generateRandomNumForValidation();
reg.setValNumServer(numVal);
reg.setValNumClient(0);
return reg;
}
use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.
the class RegistrationManagerImplTest method testCreateMinimalRegistrationWithExistingUnclaimedEmailAdditionalNotAutoDeprecatable.
@Test
public void testCreateMinimalRegistrationWithExistingUnclaimedEmailAdditionalNotAutoDeprecatable() {
// Create the user, but set it as unclaimed
String email = "new_user_" + System.currentTimeMillis() + "@test.orcid.org";
// Create a record by a member
OrcidProfile orcidProfile = createBasicProfile(email, false, CLIENT_ID_AUTODEPRECATE_DISABLED);
orcidProfile = orcidProfileManager.createOrcidProfile(orcidProfile, true, true);
assertNotNull(orcidProfile);
assertNotNull(orcidProfile.getOrcidIdentifier());
assertNotNull(orcidProfile.getOrcidIdentifier().getPath());
try {
String email2 = "new_user2_" + System.currentTimeMillis() + "@test.orcid.org";
List<Text> emailsAdditionalList = new ArrayList<Text>();
Text emailAdditional = new Text();
emailAdditional.setValue(email);
emailsAdditionalList.add(emailAdditional);
Registration form = createRegistrationFormMultipleEmails(email2, emailsAdditionalList, true);
registrationManager.createMinimalRegistration(form, true, java.util.Locale.ENGLISH, "0.0.0.0");
fail();
} catch (InvalidRequestException e) {
assertEquals("Unable to register user due: Autodeprecate is not enabled for " + email, e.getMessage());
} catch (Exception e) {
fail();
}
}
Aggregations