Search in sources :

Example 26 with WorkBulk

use of org.orcid.jaxb.model.record_rc3.WorkBulk in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_WorksTest method testViewBulkWorks.

@Test
public void testViewBulkWorks() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewBulkWorks(ORCID, "11,12,13,16");
    WorkBulk workBulk = (WorkBulk) response.getEntity();
    assertNotNull(workBulk);
    assertNotNull(workBulk.getBulk());
    assertEquals(4, workBulk.getBulk().size());
    assertTrue(workBulk.getBulk().get(0) instanceof Work);
    assertTrue(workBulk.getBulk().get(1) instanceof Work);
    // private work but matching source
    assertTrue(workBulk.getBulk().get(2) instanceof Work);
    // private work not matching source
    assertTrue(workBulk.getBulk().get(3) instanceof OrcidError);
}
Also used : Response(javax.ws.rs.core.Response) OrcidError(org.orcid.jaxb.model.error_v2.OrcidError) WorkBulk(org.orcid.jaxb.model.record_v2.WorkBulk) Work(org.orcid.jaxb.model.record_v2.Work) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 27 with WorkBulk

use of org.orcid.jaxb.model.record_rc3.WorkBulk in project ORCID-Source by ORCID.

the class OrcidSecurityManager_WorkBulkTest method testPrivateWorkBulkReadLimitedToken.

@Test
public void testPrivateWorkBulkReadLimitedToken() {
    WorkBulk workBulk = new WorkBulk();
    workBulk.setBulk(Arrays.asList(createWork(Visibility.PRIVATE, CLIENT_2)));
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_LIMITED);
    orcidSecurityManager.checkAndFilter(ORCID_1, workBulk, ScopePathType.ORCID_WORKS_READ_LIMITED);
    assertNotNull(workBulk);
    assertEquals(1, workBulk.getBulk().size());
    assertTrue(workBulk.getBulk().get(0) instanceof OrcidError);
}
Also used : OrcidError(org.orcid.jaxb.model.error_v2.OrcidError) WorkBulk(org.orcid.jaxb.model.record_v2.WorkBulk) Test(org.junit.Test)

Example 28 with WorkBulk

use of org.orcid.jaxb.model.record_rc3.WorkBulk in project ORCID-Source by ORCID.

the class OrcidSecurityManager_WorkBulkTest method testPrivateWorkBulkReadLimitedTokenMixedSources.

@Test
public void testPrivateWorkBulkReadLimitedTokenMixedSources() {
    WorkBulk workBulk = new WorkBulk();
    workBulk.setBulk(Arrays.asList(createWork(Visibility.PRIVATE, CLIENT_1), createWork(Visibility.PRIVATE, CLIENT_2)));
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_2, ScopePathType.READ_LIMITED);
    orcidSecurityManager.checkAndFilter(ORCID_1, workBulk, ScopePathType.ORCID_WORKS_READ_LIMITED);
    assertNotNull(workBulk);
    assertEquals(2, workBulk.getBulk().size());
    assertTrue(workBulk.getBulk().get(0) instanceof OrcidError);
    assertTrue(workBulk.getBulk().get(1) instanceof Work);
}
Also used : OrcidError(org.orcid.jaxb.model.error_v2.OrcidError) WorkBulk(org.orcid.jaxb.model.record_v2.WorkBulk) Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test)

Example 29 with WorkBulk

use of org.orcid.jaxb.model.record_rc3.WorkBulk in project ORCID-Source by ORCID.

the class OrcidSecurityManager_WorkBulkTest method testPrivateWorkBulkReadLimitedTokenNoSource.

@Test
public void testPrivateWorkBulkReadLimitedTokenNoSource() {
    WorkBulk workBulk = new WorkBulk();
    workBulk.setBulk(Arrays.asList(createWork(Visibility.PRIVATE, null)));
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_2, ScopePathType.READ_LIMITED);
    orcidSecurityManager.checkAndFilter(ORCID_1, workBulk, ScopePathType.ORCID_WORKS_READ_LIMITED);
    assertNotNull(workBulk);
    assertEquals(1, workBulk.getBulk().size());
    assertTrue(workBulk.getBulk().get(0) instanceof OrcidError);
}
Also used : OrcidError(org.orcid.jaxb.model.error_v2.OrcidError) WorkBulk(org.orcid.jaxb.model.record_v2.WorkBulk) Test(org.junit.Test)

Example 30 with WorkBulk

use of org.orcid.jaxb.model.record_rc3.WorkBulk in project ORCID-Source by ORCID.

the class OrcidSecurityManager_WorkBulkTest method testLimitedWorkBulkReadPublicTokenMixedSources.

@Test
public void testLimitedWorkBulkReadPublicTokenMixedSources() {
    WorkBulk workBulk = new WorkBulk();
    workBulk.setBulk(Arrays.asList(createWork(Visibility.PUBLIC, CLIENT_1), createWork(Visibility.LIMITED, CLIENT_2)));
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_PUBLIC);
    orcidSecurityManager.checkAndFilter(ORCID_1, workBulk, ScopePathType.ORCID_WORKS_READ_LIMITED);
    assertNotNull(workBulk);
    assertEquals(2, workBulk.getBulk().size());
    assertTrue(workBulk.getBulk().get(0) instanceof Work);
    assertTrue(workBulk.getBulk().get(1) instanceof OrcidError);
}
Also used : OrcidError(org.orcid.jaxb.model.error_v2.OrcidError) WorkBulk(org.orcid.jaxb.model.record_v2.WorkBulk) Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)39 WorkBulk (org.orcid.jaxb.model.record_v2.WorkBulk)36 Work (org.orcid.jaxb.model.record_v2.Work)22 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)21 ClientResponse (com.sun.jersey.api.client.ClientResponse)16 BulkElement (org.orcid.jaxb.model.record_v2.BulkElement)9 Response (javax.ws.rs.core.Response)7 DBUnitTest (org.orcid.test.DBUnitTest)7 BaseTest (org.orcid.core.BaseTest)5 WorkBulk (org.orcid.jaxb.model.record_rc3.WorkBulk)5 WorkBulk (org.orcid.jaxb.model.record_rc4.WorkBulk)5 Url (org.orcid.jaxb.model.common_v2.Url)4 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)4 Title (org.orcid.jaxb.model.common_v2.Title)3 OrcidError (org.orcid.jaxb.model.error_rc3.OrcidError)3 OrcidError (org.orcid.jaxb.model.error_rc4.OrcidError)3 BulkElement (org.orcid.jaxb.model.record_rc3.BulkElement)3 Work (org.orcid.jaxb.model.record_rc3.Work)3 BulkElement (org.orcid.jaxb.model.record_rc4.BulkElement)3 Work (org.orcid.jaxb.model.record_rc4.Work)3