Search in sources :

Example 6 with OrcidAccessControlException

use of org.orcid.core.exception.OrcidAccessControlException in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_DistinctionsTest method testReadPublicScope_Distinctions.

@Test
public void testReadPublicScope_Distinctions() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewDistinction(ORCID, 27L);
    assertNotNull(r);
    assertEquals(Distinction.class.getName(), r.getEntity().getClass().getName());
    r = serviceDelegator.viewDistinctionSummary(ORCID, 27L);
    assertNotNull(r);
    assertEquals(DistinctionSummary.class.getName(), r.getEntity().getClass().getName());
    // Limited that am the source of should work
    serviceDelegator.viewDistinction(ORCID, 28L);
    serviceDelegator.viewDistinctionSummary(ORCID, 28L);
    // Limited that am not the source of should fail
    try {
        serviceDelegator.viewDistinction(ORCID, 30L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewDistinctionSummary(ORCID, 30L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    // Private that am the source of should work
    serviceDelegator.viewDistinction(ORCID, 29L);
    serviceDelegator.viewDistinctionSummary(ORCID, 29L);
    // Private that am not the source of should fails
    try {
        serviceDelegator.viewDistinction(ORCID, 31L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewDistinctionSummary(ORCID, 31L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) DistinctionSummary(org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) OrcidDuplicatedActivityException(org.orcid.core.exception.OrcidDuplicatedActivityException) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 7 with OrcidAccessControlException

use of org.orcid.core.exception.OrcidAccessControlException in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_EmploymentsTest method testReadPublicScope_Employments.

@Test
public void testReadPublicScope_Employments() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewEmployment(ORCID, 17L);
    assertNotNull(r);
    assertEquals(Employment.class.getName(), r.getEntity().getClass().getName());
    r = serviceDelegator.viewEmploymentSummary(ORCID, 17L);
    assertNotNull(r);
    assertEquals(EmploymentSummary.class.getName(), r.getEntity().getClass().getName());
    // Limited that am the source of should work
    serviceDelegator.viewEmployment(ORCID, 18L);
    serviceDelegator.viewEmploymentSummary(ORCID, 18L);
    // Limited that am not the source of should fail
    try {
        serviceDelegator.viewEmployment(ORCID, 23L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewEmploymentSummary(ORCID, 23L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    // Private that am the source of should work
    serviceDelegator.viewEmployment(ORCID, 19L);
    serviceDelegator.viewEmploymentSummary(ORCID, 19L);
    // Private that am not the source of should fail
    try {
        serviceDelegator.viewEmployment(ORCID, 24L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewEmploymentSummary(ORCID, 24L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) EmploymentSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) OrcidDuplicatedActivityException(org.orcid.core.exception.OrcidDuplicatedActivityException) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 8 with OrcidAccessControlException

use of org.orcid.core.exception.OrcidAccessControlException in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_FundingTest method testReadPublicScope_Funding.

@Test
public void testReadPublicScope_Funding() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    // Public works
    Response r = serviceDelegator.viewFunding(ORCID, 10L);
    assertNotNull(r);
    assertEquals(Funding.class.getName(), r.getEntity().getClass().getName());
    r = serviceDelegator.viewFundingSummary(ORCID, 10L);
    assertNotNull(r);
    assertEquals(FundingSummary.class.getName(), r.getEntity().getClass().getName());
    // Limited that am the source of should work
    serviceDelegator.viewFunding(ORCID, 11L);
    serviceDelegator.viewFundingSummary(ORCID, 11L);
    // Limited that am not the source of should fail
    try {
        serviceDelegator.viewFunding(ORCID, 13L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewFundingSummary(ORCID, 13L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    // Private that am the source of should work
    serviceDelegator.viewFunding(ORCID, 12L);
    serviceDelegator.viewFundingSummary(ORCID, 12L);
    // Private am not the source of should fail
    try {
        serviceDelegator.viewFunding(ORCID, 14L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewFundingSummary(ORCID, 14L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 9 with OrcidAccessControlException

use of org.orcid.core.exception.OrcidAccessControlException in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testReadPublicScope_InvitedPositions.

@Test
public void testReadPublicScope_InvitedPositions() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewInvitedPosition(ORCID, 32L);
    assertNotNull(r);
    assertEquals(InvitedPosition.class.getName(), r.getEntity().getClass().getName());
    r = serviceDelegator.viewInvitedPositionSummary(ORCID, 32L);
    assertNotNull(r);
    assertEquals(InvitedPositionSummary.class.getName(), r.getEntity().getClass().getName());
    // Limited that am the source of should work
    serviceDelegator.viewInvitedPosition(ORCID, 33L);
    serviceDelegator.viewInvitedPositionSummary(ORCID, 33L);
    // Private that am the source of should work
    serviceDelegator.viewInvitedPosition(ORCID, 34L);
    serviceDelegator.viewInvitedPositionSummary(ORCID, 34L);
    // Limited that am not the source of should fail
    try {
        serviceDelegator.viewInvitedPosition(ORCID, 35L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewInvitedPositionSummary(ORCID, 35L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    // Private that am not the source of should fails
    try {
        serviceDelegator.viewInvitedPosition(ORCID, 35L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewInvitedPositionSummary(ORCID, 35L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) InvitedPositionSummary(org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) OrcidDuplicatedActivityException(org.orcid.core.exception.OrcidDuplicatedActivityException) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 10 with OrcidAccessControlException

use of org.orcid.core.exception.OrcidAccessControlException in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_PeerReviewsTest method testReadPublicScope_PeerReview.

@Test
public void testReadPublicScope_PeerReview() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    // Public works
    Response r = serviceDelegator.viewPeerReview(ORCID, 9L);
    assertNotNull(r);
    assertEquals(PeerReview.class.getName(), r.getEntity().getClass().getName());
    r = serviceDelegator.viewPeerReviewSummary(ORCID, 9L);
    assertNotNull(r);
    assertEquals(PeerReviewSummary.class.getName(), r.getEntity().getClass().getName());
    // Limited where am the source of should work
    serviceDelegator.viewPeerReview(ORCID, 10L);
    serviceDelegator.viewPeerReviewSummary(ORCID, 10L);
    // Limited where am not the source of should fail
    try {
        serviceDelegator.viewPeerReview(ORCID, 12L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewPeerReviewSummary(ORCID, 12L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    // Limited where am the source of should work
    serviceDelegator.viewPeerReview(ORCID, 11L);
    serviceDelegator.viewPeerReviewSummary(ORCID, 11L);
    // Limited where am not the source of should fail
    try {
        serviceDelegator.viewPeerReview(ORCID, 13L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewPeerReviewSummary(ORCID, 13L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) OrcidDuplicatedActivityException(org.orcid.core.exception.OrcidDuplicatedActivityException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

OrcidAccessControlException (org.orcid.core.exception.OrcidAccessControlException)31 NoResultException (javax.persistence.NoResultException)25 Response (javax.ws.rs.core.Response)25 Test (org.junit.Test)25 OrcidUnauthorizedException (org.orcid.core.exception.OrcidUnauthorizedException)25 OrcidVisibilityException (org.orcid.core.exception.OrcidVisibilityException)25 VisibilityMismatchException (org.orcid.core.exception.VisibilityMismatchException)25 WrongSourceException (org.orcid.core.exception.WrongSourceException)25 DBUnitTest (org.orcid.test.DBUnitTest)25 OrcidDuplicatedActivityException (org.orcid.core.exception.OrcidDuplicatedActivityException)9 OrcidValidationException (org.orcid.core.exception.OrcidValidationException)7 ActivityIdentifierValidationException (org.orcid.core.exception.ActivityIdentifierValidationException)6 OAuth2Authentication (org.springframework.security.oauth2.provider.OAuth2Authentication)4 OAuth2Request (org.springframework.security.oauth2.provider.OAuth2Request)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ExceedMaxNumberOfPutCodesException (org.orcid.core.exception.ExceedMaxNumberOfPutCodesException)2 OrcidNoResultException (org.orcid.core.exception.OrcidNoResultException)2 ScopePathType (org.orcid.jaxb.model.message.ScopePathType)2 Filterable (org.orcid.jaxb.model.common_v2.Filterable)1