use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.
the class PasswordResetControllerTest method testPasswordResetLinkValidLinkDirectsToConsolidatedScreenDirectlyWhenNoSecurityQuestion.
@Test
public void testPasswordResetLinkValidLinkDirectsToConsolidatedScreenDirectlyWhenNoSecurityQuestion() throws Exception {
HttpServletRequest servletRequest = mock(HttpServletRequest.class);
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
when(encryptionManager.decryptForExternalUse(any(String.class))).thenReturn("email=any@orcid.org&issueDate=2070-05-29T17:04:27");
when(orcidProfileManager.retrieveOrcidProfileByEmail(eq("any@orcid.org"), Matchers.<LoadOptions>any())).thenReturn(new OrcidProfile());
ModelAndView modelAndView = passwordResetController.resetPasswordEmail(servletRequest, "randomString", redirectAttributes);
assertEquals("password_one_time_reset_optional_security_questions", modelAndView.getViewName());
verify(redirectAttributes, never()).addFlashAttribute("passwordResetLinkExpired", true);
}
use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testUpdateExistingNonPrivateWork.
@Test
public void testUpdateExistingNonPrivateWork() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.ORCID_WORKS_UPDATE);
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion("1.2_rc6");
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4446"));
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
OrcidWorks orcidWorks = new OrcidWorks();
orcidActivities.setOrcidWorks(orcidWorks);
OrcidWork orcidWork = new OrcidWork();
orcidWorks.getOrcidWork().add(orcidWork);
orcidWork.setPutCode("5");
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title("Updated by works update"));
orcidWork.setWorkTitle(workTitle);
orcidWork.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
WorkExternalIdentifiers workExternalIdentifiers = new WorkExternalIdentifiers();
WorkExternalIdentifier wei = new WorkExternalIdentifier();
wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("abc123"));
workExternalIdentifiers.getWorkExternalIdentifier().add(wei);
orcidWork.setWorkExternalIdentifiers(workExternalIdentifiers);
Response response = t2OrcidApiServiceDelegator.updateWorks(mockedUriInfo, "4444-4444-4444-4446", orcidMessage);
assertNotNull(response);
OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile("4444-4444-4444-4446");
List<OrcidWork> retreivedWorksList = retrievedProfile.getOrcidActivities().getOrcidWorks().getOrcidWork();
assertEquals(4, retreivedWorksList.size());
boolean foundWorkFromAnotherSource = false;
boolean foundUpdated = false;
boolean foundExisting = false;
boolean foundExistingPrivate = false;
for (OrcidWork retrievedWork : retreivedWorksList) {
if ("5".equals(retrievedWork.getPutCode())) {
// The updated work
assertEquals("Updated by works update", retrievedWork.getWorkTitle().getTitle().getContent());
assertEquals(Visibility.PUBLIC, retrievedWork.getVisibility());
assertEquals("APP-5555555555555555", retrievedWork.getSource().retrieveSourcePath());
foundUpdated = true;
} else if ("6".equals(retrievedWork.getPutCode())) {
assertEquals("Journal article B", retrievedWork.getWorkTitle().getTitle().getContent());
assertEquals(Visibility.LIMITED, retrievedWork.getVisibility());
assertEquals("4444-4444-4444-4446", retrievedWork.getSource().retrieveSourcePath());
foundWorkFromAnotherSource = true;
} else if ("7".equals(retrievedWork.getPutCode())) {
// Existing private work
assertEquals("Journal article C", retrievedWork.getWorkTitle().getTitle().getContent());
assertEquals(Visibility.PRIVATE, retrievedWork.getVisibility());
assertEquals("APP-5555555555555555", retrievedWork.getSource().retrieveSourcePath());
foundExisting = true;
} else if ("8".equals(retrievedWork.getPutCode())) {
// Existing private work added by the user
assertEquals("Journal article D", retrievedWork.getWorkTitle().getTitle().getContent());
assertEquals(Visibility.PRIVATE, retrievedWork.getVisibility());
assertEquals("4444-4444-4444-4446", retrievedWork.getSource().retrieveSourcePath());
foundExistingPrivate = true;
}
}
assertTrue("Work from other source should be there", foundWorkFromAnotherSource);
assertTrue("Updated work should be there", foundUpdated);
assertTrue("Existing private work should be there", foundExisting);
assertTrue("Existing private work added by the user should be there", foundExistingPrivate);
}
use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testReadPrivacyOnBio2.
@Test
public void testReadPrivacyOnBio2() {
/*Example B List:
Item 1 Limited
Item 2 Public
*/
// read the profile with LIMITED
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4441", ScopePathType.READ_LIMITED);
OrcidProfile p = ((OrcidMessage) t2OrcidApiServiceDelegator.findBioDetails("4444-4444-4444-4441").getEntity()).getOrcidProfile();
assertEquals(2, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("A-0001", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getVisibility());
assertEquals("A-0002", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(1).getExternalIdCommonName().getContent());
assertEquals(Visibility.LIMITED, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(1).getVisibility());
assertEquals(Visibility.LIMITED, p.getOrcidBio().getExternalIdentifiers().getVisibility());
// read the profile with PUBLIC
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4441", ScopePathType.READ_PUBLIC);
p = ((OrcidMessage) t2OrcidApiServiceDelegator.findBioDetails("4444-4444-4444-4441").getEntity()).getOrcidProfile();
assertEquals(1, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("A-0001", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getVisibility());
assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getVisibility());
}
use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testAddDuplicatedExtIdsWhenThereIsNonPublicCountry.
@Test
public void testAddDuplicatedExtIdsWhenThereIsNonPublicCountry() {
String userOrcid = "0000-0000-0000-0003";
OrcidMessage message = new OrcidMessage();
message.setMessageVersion("1.2_rc6");
message.setOrcidProfile(new OrcidProfile());
message.getOrcidProfile().setOrcidBio(new OrcidBio());
ExternalIdentifiers extIds = new ExternalIdentifiers();
ExternalIdentifier extId1 = new ExternalIdentifier();
String commonName = "common-name-1-" + System.currentTimeMillis();
extId1.setExternalIdCommonName(new ExternalIdCommonName(commonName));
extId1.setExternalIdReference(new ExternalIdReference("ext-id-reference-1"));
extId1.setExternalIdUrl(new ExternalIdUrl("http://test.orcid.org/" + System.currentTimeMillis()));
extIds.getExternalIdentifier().add(extId1);
message.getOrcidProfile().getOrcidBio().setExternalIdentifiers(extIds);
// Add for client 1
SecurityContextTestUtils.setUpSecurityContext(userOrcid, "APP-5555555555555555", ScopePathType.PERSON_UPDATE, ScopePathType.PERSON_READ_LIMITED);
Response r = t2OrcidApiServiceDelegator.addExternalIdentifiers(null, userOrcid, message);
assertNotNull(r);
OrcidMessage newMessage1 = (OrcidMessage) r.getEntity();
assertNotNull(newMessage1);
assertNotNull(newMessage1.getOrcidProfile());
assertNotNull(newMessage1.getOrcidProfile().getOrcidBio());
assertNotNull(newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers());
assertNotNull(newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier());
assertEquals(4, newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
assertEquals(commonName, newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(3).getExternalIdCommonName().getContent());
assertEquals("APP-5555555555555555", newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(3).getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.message.OrcidProfile in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testAddDuplicatedExtIdsWithDifferentClientWorks.
@Test
public void testAddDuplicatedExtIdsWithDifferentClientWorks() {
String orcid = "0000-0000-0000-0002";
OrcidMessage message = new OrcidMessage();
message.setMessageVersion("1.2_rc6");
message.setOrcidProfile(new OrcidProfile());
message.getOrcidProfile().setOrcidBio(new OrcidBio());
ExternalIdentifiers extIds = new ExternalIdentifiers();
ExternalIdentifier extId1 = new ExternalIdentifier();
String commonName = "common-name-1-" + System.currentTimeMillis();
extId1.setExternalIdCommonName(new ExternalIdCommonName(commonName));
extId1.setExternalIdReference(new ExternalIdReference("ext-id-reference-1"));
extId1.setExternalIdUrl(new ExternalIdUrl("http://test.orcid.org/" + System.currentTimeMillis()));
extIds.getExternalIdentifier().add(extId1);
message.getOrcidProfile().getOrcidBio().setExternalIdentifiers(extIds);
// Add for client 1
SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0002", "APP-5555555555555555", ScopePathType.PERSON_UPDATE, ScopePathType.PERSON_READ_LIMITED);
Response r = t2OrcidApiServiceDelegator.addExternalIdentifiers(null, orcid, message);
assertNotNull(r);
OrcidMessage newMessage1 = (OrcidMessage) r.getEntity();
assertNotNull(newMessage1);
assertNotNull(newMessage1.getOrcidProfile());
assertNotNull(newMessage1.getOrcidProfile().getOrcidBio());
assertNotNull(newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers());
assertNotNull(newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier());
assertEquals(1, newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
assertEquals(commonName, newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
assertEquals("APP-5555555555555555", newMessage1.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getSource().retrieveSourcePath());
// Reset message for source # 2
message = new OrcidMessage();
message.setMessageVersion("1.2_rc6");
message.setOrcidProfile(new OrcidProfile());
message.getOrcidProfile().setOrcidBio(new OrcidBio());
extId1.setSource(null);
message.getOrcidProfile().getOrcidBio().setExternalIdentifiers(extIds);
SecurityContextTestUtils.setUpSecurityContext("0000-0000-0000-0002", "APP-5555555555555556", ScopePathType.PERSON_UPDATE, ScopePathType.PERSON_READ_LIMITED);
r = t2OrcidApiServiceDelegator.addExternalIdentifiers(null, orcid, message);
OrcidMessage newMessage2 = (OrcidMessage) r.getEntity();
assertNotNull(newMessage2);
assertNotNull(newMessage2.getOrcidProfile());
assertNotNull(newMessage2.getOrcidProfile().getOrcidBio());
assertNotNull(newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers());
assertNotNull(newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier());
assertEquals(2, newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
assertEquals(commonName, newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
assertEquals("APP-5555555555555555", newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getSource().retrieveSourcePath());
assertEquals(commonName, newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(1).getExternalIdCommonName().getContent());
assertEquals("APP-5555555555555556", newMessage2.getOrcidProfile().getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(1).getSource().retrieveSourcePath());
}
Aggregations