Search in sources :

Example 46 with PersonExternalIdentifier

use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_GeneralTest method testOrcidProfileCreate_CANT_UpdateOnClaimedAccounts.

@Test
public void testOrcidProfileCreate_CANT_UpdateOnClaimedAccounts() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewAddress(ORCID, 9L);
    assertNotNull(response);
    Address a = (Address) response.getEntity();
    assertNotNull(a);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateAddress(ORCID, a.getPutCode(), a);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewEducation(ORCID, 20L);
    assertNotNull(response);
    Education edu = (Education) response.getEntity();
    assertNotNull(edu);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateEducation(ORCID, edu.getPutCode(), edu);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewEmployment(ORCID, 17L);
    assertNotNull(response);
    Employment emp = (Employment) response.getEntity();
    assertNotNull(emp);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateEmployment(ORCID, emp.getPutCode(), emp);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewExternalIdentifier(ORCID, 13L);
    assertNotNull(response);
    PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(extId);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateExternalIdentifier(ORCID, extId.getPutCode(), extId);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewFunding(ORCID, 10L);
    assertNotNull(response);
    Funding f = (Funding) response.getEntity();
    assertNotNull(f);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateFunding(ORCID, f.getPutCode(), f);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewKeyword(ORCID, 9L);
    assertNotNull(response);
    Keyword k = (Keyword) response.getEntity();
    assertNotNull(k);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateKeyword(ORCID, k.getPutCode(), k);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewOtherName(ORCID, 13L);
    assertNotNull(response);
    OtherName o = (OtherName) response.getEntity();
    assertNotNull(o);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateOtherName(ORCID, o.getPutCode(), o);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewPeerReview(ORCID, 9L);
    assertNotNull(response);
    PeerReview p = (PeerReview) response.getEntity();
    assertNotNull(p);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updatePeerReview(ORCID, p.getPutCode(), p);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewResearcherUrl(ORCID, 13L);
    assertNotNull(response);
    ResearcherUrl r = (ResearcherUrl) response.getEntity();
    assertNotNull(r);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateResearcherUrl(ORCID, r.getPutCode(), r);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewWork(ORCID, 11L);
    assertNotNull(response);
    Work w = (Work) response.getEntity();
    assertNotNull(w);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateWork(ORCID, w.getPutCode(), w);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
}
Also used : Response(javax.ws.rs.core.Response) Address(org.orcid.jaxb.model.record_v2.Address) Keyword(org.orcid.jaxb.model.record_v2.Keyword) Education(org.orcid.jaxb.model.record_v2.Education) Employment(org.orcid.jaxb.model.record_v2.Employment) Funding(org.orcid.jaxb.model.record_v2.Funding) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Work(org.orcid.jaxb.model.record_v2.Work) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 47 with PersonExternalIdentifier

use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testUpdateExternalIdentifierLeavingVisibilityNullTest.

@Test
public void testUpdateExternalIdentifierLeavingVisibilityNullTest() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED, ScopePathType.PERSON_UPDATE);
    Response response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 2L);
    assertNotNull(response);
    PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(extId);
    assertEquals(Visibility.PUBLIC, extId.getVisibility());
    extId.setVisibility(null);
    response = serviceDelegator.updateExternalIdentifier("4444-4444-4444-4442", 2L, extId);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    extId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(extId);
    assertEquals(Visibility.PUBLIC, extId.getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 48 with PersonExternalIdentifier

use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testViewExternalIdentifiers.

@Test
public void testViewExternalIdentifiers() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewExternalIdentifiers("4444-4444-4444-4442");
    assertNotNull(response);
    PersonExternalIdentifiers extIds = (PersonExternalIdentifiers) response.getEntity();
    assertNotNull(extIds);
    assertEquals("/4444-4444-4444-4442/external-identifiers", extIds.getPath());
    Utils.verifyLastModified(extIds.getLastModifiedDate());
    List<PersonExternalIdentifier> extIdsList = extIds.getExternalIdentifiers();
    assertNotNull(extIdsList);
    assertEquals(3, extIdsList.size());
    for (PersonExternalIdentifier extId : extIdsList) {
        Utils.verifyLastModified(extId.getLastModifiedDate());
        assertThat(extId.getPutCode(), anyOf(is(2L), is(3L), is(5L)));
        assertThat(extId.getValue(), anyOf(is("abc123"), is("abc456"), is("abc012")));
        assertNotNull(extId.getUrl());
        assertThat(extId.getUrl().getValue(), anyOf(is("http://www.facebook.com/abc123"), is("http://www.facebook.com/abc456"), is("http://www.facebook.com/abc012")));
        assertEquals("Facebook", extId.getType());
        assertNotNull(extId.getSource());
        if (extId.getPutCode().equals(2L)) {
            assertEquals(Visibility.PUBLIC, extId.getVisibility());
            assertEquals("APP-5555555555555555", extId.getSource().retrieveSourcePath());
        } else if (extId.getPutCode().equals(3L)) {
            assertEquals(Visibility.LIMITED, extId.getVisibility());
            assertEquals("4444-4444-4444-4442", extId.getSource().retrieveSourcePath());
        } else {
            assertEquals(Visibility.PRIVATE, extId.getVisibility());
            assertEquals("APP-5555555555555555", extId.getSource().retrieveSourcePath());
        }
    }
}
Also used : Response(javax.ws.rs.core.Response) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 49 with PersonExternalIdentifier

use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testViewExternalIdentifierReadPublic.

@Test
public void testViewExternalIdentifierReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewExternalIdentifier(ORCID, 13L);
    PersonExternalIdentifier element = (PersonExternalIdentifier) r.getEntity();
    assertNotNull(element);
    assertEquals("/0000-0000-0000-0003/external-identifiers/13", element.getPath());
    Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
Also used : Response(javax.ws.rs.core.Response) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 50 with PersonExternalIdentifier

use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ExternalIdentifiersTest method testViewPublicExternalIdentifier.

@Test
public void testViewPublicExternalIdentifier() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.PERSON_READ_LIMITED);
    Response response = serviceDelegator.viewExternalIdentifier("4444-4444-4444-4442", 2L);
    assertNotNull(response);
    PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(extId);
    assertEquals("/4444-4444-4444-4442/external-identifiers/2", extId.getPath());
    Utils.verifyLastModified(extId.getLastModifiedDate());
    assertEquals("Facebook", extId.getType());
    assertEquals(Long.valueOf(2), extId.getPutCode());
    assertEquals("abc123", extId.getValue());
    assertNotNull(extId.getUrl());
    assertEquals("http://www.facebook.com/abc123", extId.getUrl().getValue());
    assertEquals(Visibility.PUBLIC, extId.getVisibility());
    assertNotNull(extId.getSource());
    assertEquals("APP-5555555555555555", extId.getSource().retrieveSourcePath());
    assertNotNull(extId.getCreatedDate());
    Utils.verifyLastModified(extId.getLastModifiedDate());
}
Also used : Response(javax.ws.rs.core.Response) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)104 Test (org.junit.Test)93 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)49 Address (org.orcid.jaxb.model.record_v2.Address)44 Keyword (org.orcid.jaxb.model.record_v2.Keyword)44 OtherName (org.orcid.jaxb.model.record_v2.OtherName)42 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)42 Email (org.orcid.jaxb.model.record_v2.Email)41 Biography (org.orcid.jaxb.model.record_v2.Biography)33 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)33 Person (org.orcid.jaxb.model.record_v2.Person)32 Addresses (org.orcid.jaxb.model.record_v2.Addresses)31 Emails (org.orcid.jaxb.model.record_v2.Emails)31 Keywords (org.orcid.jaxb.model.record_v2.Keywords)31 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)31 Name (org.orcid.jaxb.model.record_v2.Name)29 DBUnitTest (org.orcid.test.DBUnitTest)21 Response (javax.ws.rs.core.Response)19 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)19 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)19