use of org.orcid.core.exception.OrcidAccessControlException in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_KeywordsTest method testReadPublicScope_Keywords.
@Test
public void testReadPublicScope_Keywords() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
// Public works
Response r = serviceDelegator.viewKeywords(ORCID);
assertNotNull(r);
assertEquals(Keywords.class.getName(), r.getEntity().getClass().getName());
Keywords k = (Keywords) r.getEntity();
assertNotNull(k);
Utils.verifyLastModified(k.getLastModifiedDate());
assertEquals(3, k.getKeywords().size());
boolean found1 = false, found2 = false, found3 = false;
for (Keyword element : k.getKeywords()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 9) {
found1 = true;
} else if (element.getPutCode() == 10) {
found2 = true;
} else if (element.getPutCode() == 11) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
r = serviceDelegator.viewKeyword(ORCID, 9L);
assertNotNull(r);
assertEquals(Keyword.class.getName(), r.getEntity().getClass().getName());
// Limited where am the source of should work
serviceDelegator.viewKeyword(ORCID, 10L);
// Limited where am not the source of should fail
try {
serviceDelegator.viewKeyword(ORCID, 12L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
// Private where am the source of should work
serviceDelegator.viewKeyword(ORCID, 11L);
// Private where am not the source of should fail
try {
serviceDelegator.viewKeyword(ORCID, 13L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
}
use of org.orcid.core.exception.OrcidAccessControlException in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_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();
}
}
use of org.orcid.core.exception.OrcidAccessControlException in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_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();
}
}
use of org.orcid.core.exception.OrcidAccessControlException in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_AddressesTest method testReadPublicScope_Address.
@Test
public void testReadPublicScope_Address() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
// Public works
Response r = serviceDelegator.viewAddresses(ORCID);
assertNotNull(r);
assertEquals(Addresses.class.getName(), r.getEntity().getClass().getName());
Addresses a = (Addresses) r.getEntity();
assertNotNull(a);
assertEquals("/0000-0000-0000-0003/address", a.getPath());
Utils.verifyLastModified(a.getLastModifiedDate());
assertEquals(3, a.getAddress().size());
boolean found9 = false, found10 = false, found11 = false;
for (Address address : a.getAddress()) {
if (address.getPutCode() == 9) {
found9 = true;
} else if (address.getPutCode() == 10) {
found10 = true;
} else if (address.getPutCode() == 11) {
found11 = true;
} else {
fail("Invalid put code " + address.getPutCode());
}
}
assertTrue(found9);
assertTrue(found10);
assertTrue(found11);
r = serviceDelegator.viewAddress(ORCID, 9L);
assertNotNull(r);
assertEquals(Address.class.getName(), r.getEntity().getClass().getName());
// Limited where am the source should work
serviceDelegator.viewAddress(ORCID, 10L);
try {
// Limited am not the source should fail
serviceDelegator.viewAddress(ORCID, 12L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
// Private where am the source should work
serviceDelegator.viewAddress(ORCID, 11L);
try {
// Private am not the source should fail
serviceDelegator.viewAddress(ORCID, 13L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
}
use of org.orcid.core.exception.OrcidAccessControlException in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_EducationsTest method testReadPublicScope_Educations.
@Test
public void testReadPublicScope_Educations() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewEducation(ORCID, 20L);
assertNotNull(r);
assertEquals(Education.class.getName(), r.getEntity().getClass().getName());
r = serviceDelegator.viewEducationSummary(ORCID, 20L);
assertNotNull(r);
assertEquals(EducationSummary.class.getName(), r.getEntity().getClass().getName());
// Limited that am the source of should work
serviceDelegator.viewEducation(ORCID, 21L);
serviceDelegator.viewEducationSummary(ORCID, 21L);
// Limited that am not the source of should fail
try {
serviceDelegator.viewEducation(ORCID, 23L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
try {
serviceDelegator.viewEducationSummary(ORCID, 23L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
// Private that am the source of should work
serviceDelegator.viewEducation(ORCID, 22L);
serviceDelegator.viewEducationSummary(ORCID, 22L);
// Private that am not the source of should fails
try {
serviceDelegator.viewEducation(ORCID, 24L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
try {
serviceDelegator.viewEducationSummary(ORCID, 24L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
}
Aggregations