Search in sources :

Example 6 with OrcidUnauthorizedException

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

the class MemberV2ApiServiceDelegator_BiogrphyTest method testReadPublicScope_Biography.

@Test
public void testReadPublicScope_Biography() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewBiography(ORCID);
    assertNotNull(r);
    assertEquals(Biography.class.getName(), r.getEntity().getClass().getName());
    try {
        // Bio for 0000-0000-0000-0002 should be limited
        String otherOrcid = "0000-0000-0000-0002";
        r = serviceDelegator.viewBiography(otherOrcid);
        fail();
    } catch (OrcidUnauthorizedException e) {
    }
}
Also used : Response(javax.ws.rs.core.Response) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) Biography(org.orcid.jaxb.model.record_v2.Biography) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

OrcidUnauthorizedException (org.orcid.core.exception.OrcidUnauthorizedException)6 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)2 Authentication (org.springframework.security.core.Authentication)2 OAuth2Authentication (org.springframework.security.oauth2.provider.OAuth2Authentication)2 AccessControlException (java.security.AccessControlException)1 ArrayList (java.util.ArrayList)1 NoResultException (javax.persistence.NoResultException)1 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 OrcidAccessControlException (org.orcid.core.exception.OrcidAccessControlException)1 OrcidDeprecatedException (org.orcid.core.exception.OrcidDeprecatedException)1 OrcidNotClaimedException (org.orcid.core.exception.OrcidNotClaimedException)1 OrcidVisibilityException (org.orcid.core.exception.OrcidVisibilityException)1 WrongSourceException (org.orcid.core.exception.WrongSourceException)1 Member (org.orcid.core.salesforce.model.Member)1 MemberDetails (org.orcid.core.salesforce.model.MemberDetails)1 SubMember (org.orcid.core.salesforce.model.SubMember)1 LockedException (org.orcid.core.security.aop.LockedException)1 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)1 Biography (org.orcid.jaxb.model.record_v2.Biography)1