-
Notifications
You must be signed in to change notification settings - Fork 153
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
82a2a66
commit 2f55433
Showing
6 changed files
with
52 additions
and
30 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; | ||
|
@@ -69,13 +70,51 @@ public void testViewEmailsWrongToken() { | |
} | ||
|
||
@Test | ||
public void testViewEmailsReadPublic() { | ||
public void testViewEmailsReadPublic_withSourceClient() { | ||
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC); | ||
Response r = serviceDelegator.viewEmails(ORCID); | ||
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_withOtherClient() { | ||
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
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
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