Search in sources :

Example 1 with WorkBulk

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

the class OrcidSecurityManager_WorkBulkTest method testLimitedWorkBulkReadPublicTokenNoSource.

@Test
public void testLimitedWorkBulkReadPublicTokenNoSource() {
    WorkBulk workBulk = new WorkBulk();
    workBulk.setBulk(Arrays.asList(createWork(Visibility.LIMITED, null), createWork(Visibility.LIMITED, null)));
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_2, 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 OrcidError);
    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) Test(org.junit.Test)

Example 2 with WorkBulk

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

the class OrcidSecurityManager_WorkBulkTest method testMixedPublicAndLimitedWorkBulkReadLimitedToken.

@Test
public void testMixedPublicAndLimitedWorkBulkReadLimitedToken() {
    WorkBulk workBulk = new WorkBulk();
    workBulk.setBulk(Arrays.asList(createWork(Visibility.PUBLIC, CLIENT_2), createWork(Visibility.LIMITED, CLIENT_2)));
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, 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 Work);
    assertTrue(workBulk.getBulk().get(1) instanceof Work);
}
Also used : WorkBulk(org.orcid.jaxb.model.record_v2.WorkBulk) Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test)

Example 3 with WorkBulk

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

the class OrcidSecurityManager_WorkBulkTest method testWorkBulkWrongToken.

@Test(expected = OrcidUnauthorizedException.class)
public void testWorkBulkWrongToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_WORKS_READ_LIMITED);
    WorkBulk workBulk = new WorkBulk();
    orcidSecurityManager.checkAndFilter(ORCID_2, workBulk, ScopePathType.ORCID_WORKS_READ_LIMITED);
    fail();
}
Also used : WorkBulk(org.orcid.jaxb.model.record_v2.WorkBulk) Test(org.junit.Test)

Example 4 with WorkBulk

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

the class OrcidSecurityManager_WorkBulkTest method testPublicWorkBulkReadPublicToken.

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

Example 5 with WorkBulk

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

the class OrcidSecurityManager_WorkBulkTest method testMixedPublicAndLimitedWorkBulkReadPublicToken.

@Test
public void testMixedPublicAndLimitedWorkBulkReadPublicToken() {
    WorkBulk workBulk = new WorkBulk();
    workBulk.setBulk(Arrays.asList(createWork(Visibility.PUBLIC, CLIENT_2), 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