-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
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; | ||
|
@@ -40,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 { | ||
|
@@ -195,15 +192,30 @@ public void testViewEmails() { | |
} | ||
|
||
@Test | ||
public void viewNonProfessionalEmailsOnEmail() { | ||
public void checkSourceOnEmail_EmailEndpointTest() { | ||
String orcid = "0000-0000-0000-0001"; | ||
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED); | ||
Response r = serviceDelegator.viewEmails(orcid); | ||
Emails p = (Emails) r.getEntity(); | ||
assertEquals(1, p.getEmails().size()); | ||
Email e = p.getEmails().get(0); | ||
assertTrue(e.isVerified()); | ||
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); | ||
assertEquals("Source Client 1", e.getSource().getSourceName().getContent()); | ||
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]")) { | ||
assertFalse(e.isVerified()); | ||
// The source and name on non verified professional email addresses should not change | ||
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); | ||
assertEquals("Source Client 1", 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()); | ||
Check failure on line 217 in orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_EmailsTest.java GitHub Actions / Unit test report for orcid-api-weborg.orcid.api.memberV2.server.delegator.MemberV2ApiServiceDelegator_EmailsTest ► checkSourceOnEmail_EmailEndpointTest
Raw output
|
||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
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; | ||
|
@@ -47,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 { | ||
|
@@ -636,17 +633,31 @@ private void assertAllPublicButEmails(Person p) { | |
} | ||
|
||
@Test | ||
public void viewNonProfessionalEmailsOnPerson() { | ||
public void checkSourceOnEmail_EmailEndpointTest() { | ||
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); | ||
assertNotNull(p.getEmails()); | ||
assertEquals(1, p.getEmails().getEmails().size()); | ||
Email e = p.getEmails().getEmails().get(0); | ||
assertTrue(e.isVerified()); | ||
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); | ||
assertEquals("Source Client 1", e.getSource().getSourceName().getContent()); | ||
checkEmails(p.getEmails()); | ||
} | ||
|
||
private void checkEmails(Emails emails) { | ||
assertEquals(2, emails.getEmails().size()); | ||
for(Email e : emails.getEmails()) { | ||
if(e.getEmail().equals("[email protected]")) { | ||
assertFalse(e.isVerified()); | ||
// The source and name on non verified professional email addresses should not change | ||
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); | ||
assertEquals("Source Client 1", 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()); | ||
Check failure on line 659 in orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_ReadPersonTest.java GitHub Actions / Unit test report for orcid-api-weborg.orcid.api.memberV2.server.delegator.MemberV2ApiServiceDelegator_ReadPersonTest ► checkSourceOnEmail_EmailEndpointTest
Raw output
|
||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
package org.orcid.api.memberV2.server.delegator; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertNull; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
|
@@ -66,6 +60,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_ReadRecordTest extends DBUnitTest { | ||
|
@@ -1161,18 +1157,32 @@ private void assertAllPublicButEmails(Person p) { | |
} | ||
|
||
@Test | ||
public void viewNonProfessionalEmailsOnRecord() { | ||
public void checkSourceOnEmail_EmailEndpointTest() { | ||
String orcid = "0000-0000-0000-0001"; | ||
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED); | ||
Response r = serviceDelegator.viewRecord(orcid); | ||
Record record = (Record) r.getEntity(); | ||
assertNotNull(record); | ||
assertNotNull(record.getPerson()); | ||
assertNotNull(record.getPerson().getEmails()); | ||
assertEquals(1, record.getPerson().getEmails().getEmails().size()); | ||
Email e = record.getPerson().getEmails().getEmails().get(0); | ||
assertTrue(e.isVerified()); | ||
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); | ||
assertEquals("Source Client 1", e.getSource().getSourceName().getContent()); | ||
checkEmails(record.getPerson().getEmails()); | ||
} | ||
|
||
private void checkEmails(Emails emails) { | ||
assertEquals(2, emails.getEmails().size()); | ||
for(Email e : emails.getEmails()) { | ||
if(e.getEmail().equals("[email protected]")) { | ||
assertFalse(e.isVerified()); | ||
// The source and name on non verified professional email addresses should not change | ||
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); | ||
assertEquals("Source Client 1", 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()); | ||
Check failure on line 1184 in orcid-api-web/src/test/java/org/orcid/api/memberV2/server/delegator/MemberV2ApiServiceDelegator_ReadRecordTest.java GitHub Actions / Unit test report for orcid-api-weborg.orcid.api.memberV2.server.delegator.MemberV2ApiServiceDelegator_ReadRecordTest ► checkSourceOnEmail_EmailEndpointTest
Raw output
|
||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,7 @@ | |
|
||
import static org.hamcrest.core.AnyOf.anyOf; | ||
import static org.hamcrest.core.Is.is; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertThat; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
import static org.junit.Assert.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
@@ -199,15 +195,30 @@ public void testViewEmails() { | |
} | ||
|
||
@Test | ||
public void viewNonProfessionalEmailsOnEmail() { | ||
public void checkSourceOnEmail_EmailEndpointTest() { | ||
String orcid = "0000-0000-0000-0001"; | ||
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED); | ||
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.EMAIL_READ_PRIVATE); | ||
Response r = serviceDelegator.viewEmails(orcid); | ||
Emails p = (Emails) r.getEntity(); | ||
assertEquals(1, p.getEmails().size()); | ||
Email e = p.getEmails().get(0); | ||
assertTrue(e.isVerified()); | ||
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); | ||
assertEquals("Source Client 1", e.getSource().getSourceName().getContent()); | ||
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 non verified professional email addresses should not 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()); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
package org.orcid.api.memberV3.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; | ||
|
@@ -28,6 +23,8 @@ | |
import org.orcid.test.helper.v3.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 MemberV3ApiServiceDelegator_ReadPersonTest extends DBUnitTest { | ||
|
@@ -643,17 +640,31 @@ private void assertAllPublicButEmails(Person p) { | |
} | ||
|
||
@Test | ||
public void viewNonProfessionalEmailsOnPerson() { | ||
public void checkSourceOnEmail_PersonEndpointTest() { | ||
String orcid = "0000-0000-0000-0001"; | ||
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED); | ||
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.EMAIL_READ_PRIVATE); | ||
Response r = serviceDelegator.viewPerson(orcid); | ||
Person p = (Person) r.getEntity(); | ||
assertNotNull(p); | ||
assertNotNull(p.getEmails()); | ||
assertEquals(1, p.getEmails().getEmails().size()); | ||
Email e = p.getEmails().getEmails().get(0); | ||
assertTrue(e.isVerified()); | ||
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); | ||
assertEquals("Source Client 1", e.getSource().getSourceName().getContent()); | ||
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 non verified professional email addresses should not change | ||
assertEquals("0000-0000-0000-0000", e.getSource().retrieveSourcePath()); | ||
Check failure on line 658 in orcid-api-web/src/test/java/org/orcid/api/memberV3/server/delegator/MemberV3ApiServiceDelegator_ReadPersonTest.java GitHub Actions / Unit test report for orcid-api-weborg.orcid.api.memberV3.server.delegator.MemberV3ApiServiceDelegator_ReadPersonTest ► checkSourceOnEmail_PersonEndpointTest
Raw output
|
||
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()); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1348,18 +1348,32 @@ private void assertAllPublicButEmails(Person p) { | |
} | ||
|
||
@Test | ||
public void viewNonProfessionalEmailsOnRecord() { | ||
public void checkSourceOnEmail_RecordEndpointTest() { | ||
String orcid = "0000-0000-0000-0001"; | ||
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_LIMITED); | ||
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.EMAIL_READ_PRIVATE); | ||
Response r = serviceDelegator.viewRecord(orcid); | ||
Record record = (Record) r.getEntity(); | ||
assertNotNull(record); | ||
assertNotNull(record.getPerson()); | ||
assertNotNull(record.getPerson().getEmails()); | ||
assertEquals(1, record.getPerson().getEmails().getEmails().size()); | ||
Email e = record.getPerson().getEmails().getEmails().get(0); | ||
assertTrue(e.isVerified()); | ||
assertEquals("APP-5555555555555555", e.getSource().retrieveSourcePath()); | ||
assertEquals("Source Client 1", e.getSource().getSourceName().getContent()); | ||
checkEmails(record.getPerson().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 non verified professional email addresses should not 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()); | ||
} | ||
} | ||
} | ||
} |