use of org.orcid.jaxb.model.record_rc3.Name in project ORCID-Source by ORCID.
the class OrcidSecurityManager_generalTest method testPersonalDetails_When_AllPublic_NoSource_ReadLimitedToken.
@Test
public void testPersonalDetails_When_AllPublic_NoSource_ReadLimitedToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_READ_LIMITED);
Name name = createName(Visibility.PUBLIC);
Biography bio = createBiography(Visibility.PUBLIC);
OtherName o1 = createOtherName(Visibility.PUBLIC, CLIENT_2);
OtherName o2 = createOtherName(Visibility.PUBLIC, CLIENT_2);
OtherName o3 = createOtherName(Visibility.PUBLIC, CLIENT_2);
OtherNames otherNames = new OtherNames();
otherNames.setOtherNames(new ArrayList<OtherName>(Arrays.asList(o1, o2, o3)));
PersonalDetails p = new PersonalDetails();
p.setBiography(bio);
p.setName(name);
p.setOtherNames(otherNames);
orcidSecurityManager.checkAndFilter(ORCID_1, p);
assertNotNull(p);
assertEquals(name, p.getName());
assertEquals(bio, p.getBiography());
assertNotNull(p.getOtherNames());
assertNotNull(p.getOtherNames().getOtherNames());
assertEquals(3, p.getOtherNames().getOtherNames().size());
assertTrue(p.getOtherNames().getOtherNames().contains(o1));
assertTrue(p.getOtherNames().getOtherNames().contains(o2));
assertTrue(p.getOtherNames().getOtherNames().contains(o3));
}
use of org.orcid.jaxb.model.record_rc3.Name in project ORCID-Source by ORCID.
the class OrcidSecurityManager_generalTest method testPersonalDetails_When_AllPrivate_NoSource_ReadPublicToken.
@Test
public void testPersonalDetails_When_AllPrivate_NoSource_ReadPublicToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_PUBLIC);
Name name = createName(Visibility.PRIVATE);
Biography bio = createBiography(Visibility.PRIVATE);
OtherName o1 = createOtherName(Visibility.PRIVATE, CLIENT_2);
OtherName o2 = createOtherName(Visibility.PRIVATE, CLIENT_2);
OtherName o3 = createOtherName(Visibility.PRIVATE, CLIENT_2);
OtherNames otherNames = new OtherNames();
otherNames.setOtherNames(new ArrayList<OtherName>(Arrays.asList(o1, o2, o3)));
PersonalDetails p = new PersonalDetails();
p.setBiography(bio);
p.setName(name);
p.setOtherNames(otherNames);
orcidSecurityManager.checkAndFilter(ORCID_1, p);
assertNotNull(p);
assertNull(p.getName());
assertNull(p.getBiography());
assertNotNull(p.getOtherNames());
assertNotNull(p.getOtherNames().getOtherNames());
assertTrue(p.getOtherNames().getOtherNames().isEmpty());
}
use of org.orcid.jaxb.model.record_rc3.Name in project ORCID-Source by ORCID.
the class OrcidSecurityManager_generalTest method testPersonalDetails_When_SomePrivate_NoSource_ReadLimitedToken.
@Test
public void testPersonalDetails_When_SomePrivate_NoSource_ReadLimitedToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ORCID_BIO_READ_LIMITED);
Name name = createName(Visibility.PRIVATE);
Biography bio = createBiography(Visibility.PUBLIC);
OtherName o1 = createOtherName(Visibility.PRIVATE, CLIENT_2);
OtherName o2 = createOtherName(Visibility.PUBLIC, CLIENT_2);
OtherName o3 = createOtherName(Visibility.PUBLIC, CLIENT_2);
OtherNames otherNames = new OtherNames();
otherNames.setOtherNames(new ArrayList<OtherName>(Arrays.asList(o1, o2, o3)));
PersonalDetails p = new PersonalDetails();
p.setBiography(bio);
p.setName(name);
p.setOtherNames(otherNames);
orcidSecurityManager.checkAndFilter(ORCID_1, p);
assertNotNull(p);
assertNull(p.getName());
assertEquals(bio, p.getBiography());
assertNotNull(p.getOtherNames());
assertNotNull(p.getOtherNames().getOtherNames());
assertEquals(2, p.getOtherNames().getOtherNames().size());
assertFalse(p.getOtherNames().getOtherNames().contains(o1));
assertTrue(p.getOtherNames().getOtherNames().contains(o2));
assertTrue(p.getOtherNames().getOtherNames().contains(o3));
}
use of org.orcid.jaxb.model.record_rc3.Name in project ORCID-Source by ORCID.
the class OrcidSecurityManager_generalTest method testPersonalDetails_When_AllPrivate_Source_ReadPublicToken.
@Test
public void testPersonalDetails_When_AllPrivate_Source_ReadPublicToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_PUBLIC);
Name name = createName(Visibility.PRIVATE);
Biography bio = createBiography(Visibility.PRIVATE);
OtherName o1 = createOtherName(Visibility.PRIVATE, CLIENT_1);
OtherName o2 = createOtherName(Visibility.PRIVATE, CLIENT_1);
OtherName o3 = createOtherName(Visibility.PRIVATE, CLIENT_1);
OtherNames otherNames = new OtherNames();
otherNames.setOtherNames(new ArrayList<OtherName>(Arrays.asList(o1, o2, o3)));
PersonalDetails p = new PersonalDetails();
p.setBiography(bio);
p.setName(name);
p.setOtherNames(otherNames);
orcidSecurityManager.checkAndFilter(ORCID_1, p);
assertNotNull(p);
assertNull(p.getName());
assertNull(p.getBiography());
assertNotNull(p.getOtherNames());
assertNotNull(p.getOtherNames().getOtherNames());
assertEquals(3, p.getOtherNames().getOtherNames().size());
assertTrue(p.getOtherNames().getOtherNames().contains(o1));
assertTrue(p.getOtherNames().getOtherNames().contains(o2));
assertTrue(p.getOtherNames().getOtherNames().contains(o3));
}
use of org.orcid.jaxb.model.record_rc3.Name in project ORCID-Source by ORCID.
the class MemberV2Test method createViewUpdateAndDeleteEducation.
@Test
public void createViewUpdateAndDeleteEducation() throws JSONException, InterruptedException, URISyntaxException {
Education education = (Education) unmarshallFromPath("/record_2.0_rc3/samples/education-2.0_rc3.xml", Education.class);
education.setPutCode(null);
education.setVisibility(Visibility.PUBLIC);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV2ApiClient.createEducationXml(this.getUser1OrcidId(), education, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
String locationPath = postResponse.getLocation().getPath();
assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v2.0_rc3/" + this.getUser1OrcidId() + "/education/\\d+"));
ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
Education gotEducation = getResponse.getEntity(Education.class);
assertEquals("education:department-name", gotEducation.getDepartmentName());
assertEquals("education:role-title", gotEducation.getRoleTitle());
//Save the original visibility
Visibility originalVisibility = gotEducation.getVisibility();
Visibility updatedVisibility = Visibility.PRIVATE.equals(originalVisibility) ? Visibility.LIMITED : Visibility.PRIVATE;
//Verify you cant update the visibility
gotEducation.setVisibility(updatedVisibility);
ClientResponse putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotEducation);
assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
OrcidError error = putResponse.getEntity(OrcidError.class);
assertNotNull(error);
assertEquals(Integer.valueOf(9035), error.getErrorCode());
//Set the visibility again to the initial one
gotEducation.setVisibility(originalVisibility);
gotEducation.setDepartmentName("updated dept. name");
gotEducation.setRoleTitle("updated role title");
putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotEducation);
assertEquals(Response.Status.OK.getStatusCode(), putResponse.getStatus());
ClientResponse getAfterUpdateResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
Education gotAfterUpdateEducation = getAfterUpdateResponse.getEntity(Education.class);
assertEquals("updated dept. name", gotAfterUpdateEducation.getDepartmentName());
assertEquals("updated role title", gotAfterUpdateEducation.getRoleTitle());
ClientResponse deleteResponse = memberV2ApiClient.deleteEducationXml(this.getUser1OrcidId(), gotEducation.getPutCode(), accessToken);
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Aggregations