-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3224dc4
commit 36550bd
Showing
6 changed files
with
200 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
@@ -84,7 +85,22 @@ public void testViewPersonReadPublic() { | |
assertNotNull(element); | ||
assertEquals("/0000-0000-0000-0003/person", element.getPath()); | ||
Utils.assertIsPublicOrSource(element, "APP-5555555555555555"); | ||
fail("TEST EMAILS"); | ||
assertNotNull(element.getEmails()); | ||
assertEquals(4, element.getEmails().getEmails().size()); | ||
List<String> emails = new ArrayList<>(); | ||
emails.add("[email protected]"); | ||
emails.add("[email protected]"); | ||
emails.add("[email protected]"); | ||
emails.add("[email protected]"); | ||
|
||
for(Email e : element.getEmails().getEmails()) { | ||
if(!emails.contains(e.getEmail())) { | ||
fail(e.getEmail() + " is not in the email list"); | ||
} | ||
emails.remove(e.getEmail()); | ||
} | ||
|
||
assertTrue(emails.isEmpty()); | ||
} | ||
|
||
@Test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
@@ -102,7 +103,6 @@ public void testViewRecordWrongScope() { | |
Utils.assertIsPublicOrSource(record.getActivitiesSummary(), SecurityContextTestUtils.DEFAULT_CLIENT_ID); | ||
assertEquals("/0000-0000-0000-0003/person", record.getPerson().getPath()); | ||
Utils.assertIsPublicOrSource(record.getPerson(), SecurityContextTestUtils.DEFAULT_CLIENT_ID); | ||
|
||
} | ||
|
||
@Test | ||
|
@@ -116,7 +116,51 @@ public void testViewRecordReadPublic() { | |
Utils.assertIsPublicOrSource(record.getActivitiesSummary(), "APP-5555555555555555"); | ||
assertEquals("/0000-0000-0000-0003/person", record.getPerson().getPath()); | ||
Utils.assertIsPublicOrSource(record.getPerson(), "APP-5555555555555555"); | ||
fail("TEST EMAILS"); | ||
assertNotNull(record.getPerson()); | ||
assertNotNull(record.getPerson().getEmails()); | ||
assertEquals(4, record.getPerson().getEmails().getEmails().size()); | ||
List<String> emails = new ArrayList<>(); | ||
emails.add("[email protected]"); | ||
emails.add("[email protected]"); | ||
emails.add("[email protected]"); | ||
emails.add("[email protected]"); | ||
|
||
for(Email e : record.getPerson().getEmails().getEmails()) { | ||
if(!emails.contains(e.getEmail())) { | ||
fail(e.getEmail() + " is not in the email list"); | ||
} | ||
emails.remove(e.getEmail()); | ||
} | ||
|
||
assertTrue(emails.isEmpty()); | ||
} | ||
|
||
@Test | ||
public void testViewRecordReadPublic_clientThatIsNotTheSourceOfEmails() { | ||
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555556", ScopePathType.READ_PUBLIC); | ||
Response r = serviceDelegator.viewRecord(ORCID); | ||
Record record = (Record) r.getEntity(); | ||
assertNotNull(record); | ||
assertEquals("/0000-0000-0000-0003", record.getPath()); | ||
assertEquals("/0000-0000-0000-0003/activities", record.getActivitiesSummary().getPath()); | ||
Utils.assertIsPublicOrSource(record.getActivitiesSummary(), "APP-5555555555555556"); | ||
assertEquals("/0000-0000-0000-0003/person", record.getPerson().getPath()); | ||
Utils.assertIsPublicOrSource(record.getPerson(), "APP-5555555555555556"); | ||
assertNotNull(record.getPerson()); | ||
assertNotNull(record.getPerson().getEmails()); | ||
assertEquals(2, record.getPerson().getEmails().getEmails().size()); | ||
List<String> emails = new ArrayList<>(); | ||
emails.add("[email protected]"); | ||
emails.add("[email protected]"); | ||
|
||
for(Email e : record.getPerson().getEmails().getEmails()) { | ||
if(!emails.contains(e.getEmail())) { | ||
fail(e.getEmail() + " is not in the email list"); | ||
} | ||
emails.remove(e.getEmail()); | ||
} | ||
|
||
assertTrue(emails.isEmpty()); | ||
} | ||
|
||
@Test(expected = OrcidUnauthorizedException.class) | ||
|
@@ -229,28 +273,23 @@ public void testViewRecord() { | |
for (Email email : person.getEmails().getEmails()) { | ||
Utils.verifyLastModified(email.getLastModifiedDate()); | ||
if (email.getEmail().equals("[email protected]")) { | ||
assertEquals("APP-5555555555555555", email.getSource().retrieveSourcePath()); | ||
assertNull(email.getSource().getSourceOrcid()); | ||
assertEquals("0000-0000-0000-0000", email.getSource().retrieveSourcePath()); | ||
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC.value(), email.getVisibility().value()); | ||
assertEquals("Source Client 1", email.getSource().getSourceName().getContent()); | ||
assertEquals("ORCID email validation", email.getSource().getSourceName().getContent()); | ||
} else if (email.getEmail().equals("[email protected]")) { | ||
assertEquals("APP-5555555555555555", email.getSource().retrieveSourcePath()); | ||
assertNull(email.getSource().getSourceOrcid()); | ||
assertEquals("0000-0000-0000-0000", email.getSource().retrieveSourcePath()); | ||
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.LIMITED.value(), email.getVisibility().value()); | ||
assertEquals("Source Client 1", email.getSource().getSourceName().getContent()); | ||
assertEquals("ORCID email validation", email.getSource().getSourceName().getContent()); | ||
} else if (email.getEmail().equals("[email protected]")) { | ||
assertEquals("APP-5555555555555555", email.getSource().retrieveSourcePath()); | ||
assertNull(email.getSource().getSourceOrcid()); | ||
assertEquals("0000-0000-0000-0000", email.getSource().retrieveSourcePath()); | ||
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE.value(), email.getVisibility().value()); | ||
assertEquals("Source Client 1", email.getSource().getSourceName().getContent()); | ||
assertEquals("ORCID email validation", email.getSource().getSourceName().getContent()); | ||
} else if (email.getEmail().equals("[email protected]")) { | ||
assertEquals("0000-0000-0000-0003", email.getSource().retrieveSourcePath()); | ||
assertNotNull(email.getSource().getSourceOrcid()); | ||
assertEquals("0000-0000-0000-0000", email.getSource().retrieveSourcePath()); | ||
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.LIMITED.value(), email.getVisibility().value()); | ||
assertEquals("Credit Name", email.getSource().getSourceName().getContent()); | ||
assertEquals("ORCID email validation", email.getSource().getSourceName().getContent()); | ||
} else if (email.getEmail().equals("[email protected]")) { | ||
assertEquals("0000-0000-0000-0000", email.getSource().retrieveSourcePath()); | ||
assertNull(email.getSource().getSourceOrcid()); | ||
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC.value(), email.getVisibility().value()); | ||
assertEquals("ORCID email validation", email.getSource().getSourceName().getContent()); | ||
} else { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
@@ -86,7 +87,41 @@ public void testViewEmailsReadPublic() { | |
Emails element = (Emails) r.getEntity(); | ||
assertNotNull(element); | ||
assertEquals("/0000-0000-0000-0003/email", element.getPath()); | ||
Utils.assertIsPublicOrSource(element, "APP-5555555555555555"); | ||
assertEquals(4, element.getEmails().size()); | ||
List<String> emails = new ArrayList<>(); | ||
emails.add("[email protected]"); | ||
emails.add("[email protected]"); | ||
emails.add("[email protected]"); | ||
emails.add("[email protected]"); | ||
|
||
for(Email e : element.getEmails()) { | ||
if(!emails.contains(e.getEmail())) { | ||
fail(e.getEmail() + " is not in the email list"); | ||
} | ||
emails.remove(e.getEmail()); | ||
} | ||
assertTrue(emails.isEmpty()); | ||
} | ||
|
||
@Test | ||
public void testViewEmailsReadPublic_ClientNotSourceOfAnyEmail() { | ||
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555556", ScopePathType.READ_PUBLIC); | ||
Response r = serviceDelegator.viewEmails(ORCID); | ||
Emails element = (Emails) r.getEntity(); | ||
assertNotNull(element); | ||
assertEquals("/0000-0000-0000-0003/email", element.getPath()); | ||
assertEquals(2, element.getEmails().size()); | ||
List<String> emails = new ArrayList<>(); | ||
emails.add("[email protected]"); | ||
emails.add("[email protected]"); | ||
|
||
for(Email e : element.getEmails()) { | ||
if(!emails.contains(e.getEmail())) { | ||
fail(e.getEmail() + " is not in the email list"); | ||
} | ||
emails.remove(e.getEmail()); | ||
} | ||
assertTrue(emails.isEmpty()); | ||
} | ||
|
||
@Test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
@@ -90,7 +91,46 @@ public void testViewPersonReadPublic() { | |
assertNotNull(element); | ||
assertEquals("/0000-0000-0000-0003/person", element.getPath()); | ||
Utils.assertIsPublicOrSource(element, "APP-5555555555555555"); | ||
fail("Process emails"); | ||
assertNotNull(element.getEmails()); | ||
assertNotNull(element.getEmails().getEmails()); | ||
assertEquals(4, element.getEmails().getEmails().size()); | ||
List<String> emails = new ArrayList<>(); | ||
emails.add("[email protected]"); | ||
emails.add("[email protected]"); | ||
emails.add("[email protected]"); | ||
emails.add("[email protected]"); | ||
|
||
for(Email e : element.getEmails().getEmails()) { | ||
if(!emails.contains(e.getEmail())) { | ||
fail(e.getEmail() + " is not in the email list"); | ||
} | ||
emails.remove(e.getEmail()); | ||
} | ||
assertTrue(emails.isEmpty()); | ||
} | ||
|
||
@Test | ||
public void testViewPersonReadPublic_ClientNotSourceOfAnyEmail() { | ||
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555556", ScopePathType.READ_PUBLIC); | ||
Response r = serviceDelegator.viewPerson(ORCID); | ||
Person element = (Person) r.getEntity(); | ||
assertNotNull(element); | ||
assertEquals("/0000-0000-0000-0003/person", element.getPath()); | ||
Utils.assertIsPublicOrSource(element, "APP-5555555555555556"); | ||
assertNotNull(element.getEmails()); | ||
assertNotNull(element.getEmails().getEmails()); | ||
assertEquals(2, element.getEmails().getEmails().size()); | ||
List<String> emails = new ArrayList<>(); | ||
emails.add("[email protected]"); | ||
emails.add("[email protected]"); | ||
|
||
for(Email e : element.getEmails().getEmails()) { | ||
if(!emails.contains(e.getEmail())) { | ||
fail(e.getEmail() + " is not in the email list"); | ||
} | ||
emails.remove(e.getEmail()); | ||
} | ||
assertTrue(emails.isEmpty()); | ||
} | ||
|
||
@Test | ||
|
Oops, something went wrong.