Search in sources :

Example 11 with Registration

use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.

the class RegistrationManagerImplTest method testCreateMinimalRegistrationWithExistingUnclaimedEmailNotAutoDeprecatable.

@Test
public void testCreateMinimalRegistrationWithExistingUnclaimedEmailNotAutoDeprecatable() {
    //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 {
        Registration form = createRegistrationForm(email, 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();
    }
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Registration(org.orcid.pojo.ajaxForm.Registration) InvalidRequestException(org.springframework.security.oauth2.common.exceptions.InvalidRequestException) InvalidRequestException(org.springframework.security.oauth2.common.exceptions.InvalidRequestException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 12 with Registration

use of org.orcid.pojo.ajaxForm.Registration in project ORCID-Source by ORCID.

the class RegistrationManagerImplTest method createRegistrationForm.

private Registration createRegistrationForm(String email, boolean claimed) {
    Registration registration = new Registration();
    registration.setPassword(Text.valueOf("password"));
    registration.setEmail(Text.valueOf(email));
    registration.setFamilyNames(Text.valueOf("User"));
    registration.setGivenNames(Text.valueOf("New"));
    registration.setCreationType(Text.valueOf(CreationMethod.DIRECT.value()));
    return registration;
}
Also used : Registration(org.orcid.pojo.ajaxForm.Registration)

Example 13 with Registration

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.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);
    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;
}
Also used : Registration(org.orcid.pojo.ajaxForm.Registration) RequestInfoForm(org.orcid.pojo.ajaxForm.RequestInfoForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Registration (org.orcid.pojo.ajaxForm.Registration)13 Test (org.junit.Test)11 DBUnitTest (org.orcid.test.DBUnitTest)11 Locale (java.util.Locale)2 HttpSession (javax.servlet.http.HttpSession)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)2 Checkbox (org.orcid.pojo.ajaxForm.Checkbox)2 RequestInfoForm (org.orcid.pojo.ajaxForm.RequestInfoForm)2 Text (org.orcid.pojo.ajaxForm.Text)2 InvalidRequestException (org.springframework.security.oauth2.common.exceptions.InvalidRequestException)2 Principal (java.security.Principal)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 OrcidOAuth2Authentication (org.orcid.core.oauth.OrcidOAuth2Authentication)1 Visibility (org.orcid.jaxb.model.common_v2.Visibility)1 OauthRegistrationForm (org.orcid.pojo.ajaxForm.OauthRegistrationForm)1 Authentication (org.springframework.security.core.Authentication)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 SessionStatus (org.springframework.web.bind.support.SessionStatus)1