use of org.orcid.jaxb.model.v3.dev1.record.OtherName in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_GeneralTest method testOrcidProfileCreate_CANT_UpdateOnClaimedAccounts.
@Test
public void testOrcidProfileCreate_CANT_UpdateOnClaimedAccounts() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewAddress(ORCID, 9L);
assertNotNull(response);
Address a = (Address) response.getEntity();
assertNotNull(a);
try {
SecurityContextTestUtils.setUpSecurityContextForClientOnly();
serviceDelegator.updateAddress(ORCID, a.getPutCode(), a);
fail();
} catch (IllegalStateException e) {
assertEquals("Non client credential scope found in client request", e.getMessage());
}
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
response = serviceDelegator.viewEducation(ORCID, 20L);
assertNotNull(response);
Education edu = (Education) response.getEntity();
assertNotNull(edu);
try {
SecurityContextTestUtils.setUpSecurityContextForClientOnly();
serviceDelegator.updateEducation(ORCID, edu.getPutCode(), edu);
fail();
} catch (IllegalStateException e) {
assertEquals("Non client credential scope found in client request", e.getMessage());
}
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
response = serviceDelegator.viewEmployment(ORCID, 17L);
assertNotNull(response);
Employment emp = (Employment) response.getEntity();
assertNotNull(emp);
try {
SecurityContextTestUtils.setUpSecurityContextForClientOnly();
serviceDelegator.updateEmployment(ORCID, emp.getPutCode(), emp);
fail();
} catch (IllegalStateException e) {
assertEquals("Non client credential scope found in client request", e.getMessage());
}
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
response = serviceDelegator.viewExternalIdentifier(ORCID, 13L);
assertNotNull(response);
PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
assertNotNull(extId);
try {
SecurityContextTestUtils.setUpSecurityContextForClientOnly();
serviceDelegator.updateExternalIdentifier(ORCID, extId.getPutCode(), extId);
fail();
} catch (IllegalStateException e) {
assertEquals("Non client credential scope found in client request", e.getMessage());
}
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
response = serviceDelegator.viewFunding(ORCID, 10L);
assertNotNull(response);
Funding f = (Funding) response.getEntity();
assertNotNull(f);
try {
SecurityContextTestUtils.setUpSecurityContextForClientOnly();
serviceDelegator.updateFunding(ORCID, f.getPutCode(), f);
fail();
} catch (IllegalStateException e) {
assertEquals("Non client credential scope found in client request", e.getMessage());
}
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
response = serviceDelegator.viewKeyword(ORCID, 9L);
assertNotNull(response);
Keyword k = (Keyword) response.getEntity();
assertNotNull(k);
try {
SecurityContextTestUtils.setUpSecurityContextForClientOnly();
serviceDelegator.updateKeyword(ORCID, k.getPutCode(), k);
fail();
} catch (IllegalStateException e) {
assertEquals("Non client credential scope found in client request", e.getMessage());
}
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
response = serviceDelegator.viewOtherName(ORCID, 13L);
assertNotNull(response);
OtherName o = (OtherName) response.getEntity();
assertNotNull(o);
try {
SecurityContextTestUtils.setUpSecurityContextForClientOnly();
serviceDelegator.updateOtherName(ORCID, o.getPutCode(), o);
fail();
} catch (IllegalStateException e) {
assertEquals("Non client credential scope found in client request", e.getMessage());
}
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
response = serviceDelegator.viewPeerReview(ORCID, 9L);
assertNotNull(response);
PeerReview p = (PeerReview) response.getEntity();
assertNotNull(p);
try {
SecurityContextTestUtils.setUpSecurityContextForClientOnly();
serviceDelegator.updatePeerReview(ORCID, p.getPutCode(), p);
fail();
} catch (IllegalStateException e) {
assertEquals("Non client credential scope found in client request", e.getMessage());
}
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
response = serviceDelegator.viewResearcherUrl(ORCID, 13L);
assertNotNull(response);
ResearcherUrl r = (ResearcherUrl) response.getEntity();
assertNotNull(r);
try {
SecurityContextTestUtils.setUpSecurityContextForClientOnly();
serviceDelegator.updateResearcherUrl(ORCID, r.getPutCode(), r);
fail();
} catch (IllegalStateException e) {
assertEquals("Non client credential scope found in client request", e.getMessage());
}
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
response = serviceDelegator.viewWork(ORCID, 11L);
assertNotNull(response);
Work w = (Work) response.getEntity();
assertNotNull(w);
try {
SecurityContextTestUtils.setUpSecurityContextForClientOnly();
serviceDelegator.updateWork(ORCID, w.getPutCode(), w);
fail();
} catch (IllegalStateException e) {
assertEquals("Non client credential scope found in client request", e.getMessage());
}
}
use of org.orcid.jaxb.model.v3.dev1.record.OtherName in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_OtherNamesTest method testViewPublicOtherName.
@Test
public void testViewPublicOtherName() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewOtherName("4444-4444-4444-4446", 5L);
assertNotNull(response);
OtherName otherName = (OtherName) response.getEntity();
assertNotNull(otherName);
assertEquals("/4444-4444-4444-4446/other-names/5", otherName.getPath());
Utils.verifyLastModified(otherName.getLastModifiedDate());
assertEquals("Other Name # 1", otherName.getContent());
assertEquals(Visibility.PUBLIC, otherName.getVisibility());
assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.v3.dev1.record.OtherName in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_OtherNamesTest method testViewPrivateOtherName.
@Test
public void testViewPrivateOtherName() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewOtherName("4444-4444-4444-4446", 8L);
assertNotNull(response);
OtherName otherName = (OtherName) response.getEntity();
assertNotNull(otherName);
assertEquals("/4444-4444-4444-4446/other-names/8", otherName.getPath());
Utils.verifyLastModified(otherName.getLastModifiedDate());
assertEquals("Other Name # 4", otherName.getContent());
assertEquals(Visibility.PRIVATE, otherName.getVisibility());
assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.v3.dev1.record.OtherName in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_OtherNamesTest method testViewLimitedOtherName.
@Test
public void testViewLimitedOtherName() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.PERSON_READ_LIMITED);
Response response = serviceDelegator.viewOtherName("4444-4444-4444-4446", 6L);
assertNotNull(response);
OtherName otherName = (OtherName) response.getEntity();
assertNotNull(otherName);
assertEquals("/4444-4444-4444-4446/other-names/6", otherName.getPath());
Utils.verifyLastModified(otherName.getLastModifiedDate());
assertEquals("Other Name # 2", otherName.getContent());
assertEquals(Visibility.LIMITED, otherName.getVisibility());
assertEquals("4444-4444-4444-4446", otherName.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.v3.dev1.record.OtherName in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_OtherNamesTest method testReadPublicScope_OtherNames.
@Test
public void testReadPublicScope_OtherNames() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
// Public works
Response r = serviceDelegator.viewOtherNames(ORCID);
assertNotNull(r);
assertEquals(OtherNames.class.getName(), r.getEntity().getClass().getName());
OtherNames o = (OtherNames) r.getEntity();
assertNotNull(o);
Utils.verifyLastModified(o.getLastModifiedDate());
assertEquals(3, o.getOtherNames().size());
boolean found1 = false, found2 = false, found3 = false;
for (OtherName element : o.getOtherNames()) {
Utils.verifyLastModified(element.getLastModifiedDate());
if (element.getPutCode() == 13) {
found1 = true;
} else if (element.getPutCode() == 14) {
found2 = true;
} else if (element.getPutCode() == 15) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
r = serviceDelegator.viewOtherName(ORCID, 13L);
assertNotNull(r);
assertEquals(OtherName.class.getName(), r.getEntity().getClass().getName());
// Limited where am the source should work
serviceDelegator.viewOtherName(ORCID, 14L);
// Limited where am not the source of should fail
try {
serviceDelegator.viewOtherName(ORCID, 16L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
// Private where am the source should work
serviceDelegator.viewOtherName(ORCID, 15L);
// Private where am not the source should work
try {
serviceDelegator.viewOtherName(ORCID, 17L);
fail();
} catch (OrcidAccessControlException e) {
} catch (Exception e) {
fail();
}
}
Aggregations