-
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.
* Subdomain changes * formatting changes * Fix unit tests * Fix more unit tests * Process the email domains in a single file * Fix more unit tests * More tests * Testing verified non professional addresses * More unit tests * Fix unit tests one more time! * Fix one test more --------- Co-authored-by: amontenegro <[email protected]>
- Loading branch information
1 parent
d3ccb64
commit 6459c14
Showing
28 changed files
with
905 additions
and
335 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
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 |
---|---|---|
@@ -1,10 +1,6 @@ | ||
package org.orcid.api.memberV2.server.delegator; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
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; | ||
|
@@ -39,6 +35,8 @@ | |
import org.orcid.test.helper.Utils; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
@RunWith(OrcidJUnit4ClassRunner.class) | ||
@ContextConfiguration(locations = { "classpath:test-orcid-api-web-context.xml" }) | ||
public class MemberV2ApiServiceDelegator_EmailsTest extends DBUnitTest { | ||
|
@@ -69,13 +67,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 | ||
|
@@ -154,4 +190,32 @@ public void testViewEmails() { | |
assertEquals(true, email.isVerified()); | ||
assertEquals(false, email.isPrimary()); | ||
} | ||
|
||
@Test | ||
public void checkSourceOnEmail_EmailEndpointTest() { | ||
String orcid = "0000-0000-0000-0001"; | ||
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED); | ||
Response r = serviceDelegator.viewEmails(orcid); | ||
Emails emails = (Emails) r.getEntity(); | ||
checkEmails(emails); | ||
} | ||
|
||
private void checkEmails(Emails emails) { | ||
assertEquals(2, emails.getEmails().size()); | ||
for(Email e : emails.getEmails()) { | ||
if(e.getEmail().equals("[email protected]")) { | ||
assertTrue(e.isVerified()); | ||
// The source and name on verified professional email addresses should change | ||
assertEquals("0000-0000-0000-0000", e.getSource().retrieveSourcePath()); | ||
assertEquals("ORCID email validation", e.getSource().getSourceName().getContent()); | ||
} else if(e.getEmail().equals("[email protected]")) { | ||
assertTrue(e.isVerified()); | ||
// The source and name on non professional email addresses should not change | ||
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); | ||
assertEquals("Source Client 1", e.getSource().getSourceName().getContent()); | ||
} else { | ||
fail("Unexpected email " + e.getEmail()); | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,10 +1,6 @@ | ||
package org.orcid.api.memberV2.server.delegator; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
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; | ||
|
@@ -46,6 +42,8 @@ | |
import org.orcid.test.helper.Utils; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
@RunWith(OrcidJUnit4ClassRunner.class) | ||
@ContextConfiguration(locations = { "classpath:test-orcid-api-web-context.xml" }) | ||
public class MemberV2ApiServiceDelegator_ReadPersonTest extends DBUnitTest { | ||
|
@@ -84,6 +82,22 @@ public void testViewPersonReadPublic() { | |
assertNotNull(element); | ||
assertEquals("/0000-0000-0000-0003/person", element.getPath()); | ||
Utils.assertIsPublicOrSource(element, "APP-5555555555555555"); | ||
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 | ||
|
@@ -617,4 +631,33 @@ private void assertAllPublicButEmails(Person p) { | |
assertEquals(Long.valueOf(13), ru.getResearcherUrls().get(0).getPutCode()); | ||
assertEquals(Visibility.PUBLIC, ru.getResearcherUrls().get(0).getVisibility()); | ||
} | ||
|
||
@Test | ||
public void checkSourceOnEmail_PersonEndpointTest() { | ||
String orcid = "0000-0000-0000-0001"; | ||
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED); | ||
Response r = serviceDelegator.viewPerson(orcid); | ||
Person p = (Person) r.getEntity(); | ||
assertNotNull(p.getEmails()); | ||
checkEmails(p.getEmails()); | ||
} | ||
|
||
private void checkEmails(Emails emails) { | ||
assertEquals(2, emails.getEmails().size()); | ||
for(Email e : emails.getEmails()) { | ||
if(e.getEmail().equals("[email protected]")) { | ||
assertTrue(e.isVerified()); | ||
// The source and name on verified professional email addresses should change | ||
assertEquals("0000-0000-0000-0000", e.getSource().retrieveSourcePath()); | ||
assertEquals("ORCID email validation", e.getSource().getSourceName().getContent()); | ||
} else if(e.getEmail().equals("[email protected]")) { | ||
assertTrue(e.isVerified()); | ||
// The source and name on non professional email addresses should not change | ||
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); | ||
assertEquals("Source Client 1", e.getSource().getSourceName().getContent()); | ||
} else { | ||
fail("Unexpected email " + e.getEmail()); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.