use of org.orcid.pojo.DeprecateProfile in project ORCID-Source by ORCID.
the class ManageProfileControllerTest method testConfirmDeprecateProfileWithInvalidDataMatchingAccounts.
@Test
public void testConfirmDeprecateProfileWithInvalidDataMatchingAccounts() {
SecurityContextHolder.getContext().setAuthentication(getAuthentication(DEPRECATED_USER_ORCID));
DeprecateProfile deprecateProfile = new DeprecateProfile();
deprecateProfile.setDeprecatingOrcidOrEmail(DEPRECATED_USER_ORCID);
deprecateProfile.setPrimaryOrcid(DEPRECATED_USER_ORCID);
deprecateProfile.setDeprecatingPassword("password");
deprecateProfile = controller.confirmDeprecateProfile(deprecateProfile);
assertNull(deprecateProfile.getDeprecatingAccountName());
assertNotNull(deprecateProfile.getErrors());
assertEquals(1, deprecateProfile.getErrors().size());
assertEquals("deprecate_orcid.profile_matches_current", deprecateProfile.getErrors().get(0));
}
use of org.orcid.pojo.DeprecateProfile in project ORCID-Source by ORCID.
the class ManageProfileControllerTest method testValidateDeprecateProfileWithValidData.
@Test
public void testValidateDeprecateProfileWithValidData() {
SecurityContextHolder.getContext().setAuthentication(getAuthentication(USER_ORCID));
// Using email
DeprecateProfile deprecateProfile = new DeprecateProfile();
deprecateProfile.setPrimaryOrcid(USER_ORCID);
deprecateProfile.setDeprecatingOrcidOrEmail("0000-0000-0000-0002_1@test.orcid.org");
deprecateProfile.setDeprecatingPassword("password");
deprecateProfile = controller.validateDeprecateProfile(deprecateProfile);
assertNotNull(deprecateProfile.getDeprecatingAccountName());
assertNotNull(deprecateProfile.getDeprecatingEmails());
assertEquals("0000-0000-0000-0002", deprecateProfile.getDeprecatingOrcid());
assertEquals("0000-0000-0000-0002 Given Names 0000-0000-0000-0002 Family Name", deprecateProfile.getDeprecatingAccountName());
assertEquals(2, deprecateProfile.getDeprecatingEmails().size());
assertTrue(deprecateProfile.getDeprecatingEmails().contains("0000-0000-0000-0002_1@test.orcid.org"));
assertTrue(deprecateProfile.getDeprecatingEmails().contains("0000-0000-0000-0002_2@test.orcid.org"));
assertEquals("0000-0000-0000-0001", deprecateProfile.getPrimaryOrcid());
assertEquals("0000-0000-0000-0001 Given Names 0000-0000-0000-0001 Family Name", deprecateProfile.getPrimaryAccountName());
assertNotNull(deprecateProfile.getPrimaryEmails());
assertEquals(2, deprecateProfile.getPrimaryEmails().size());
assertTrue(deprecateProfile.getPrimaryEmails().contains("0000-0000-0000-0001_1@test.orcid.org"));
assertTrue(deprecateProfile.getPrimaryEmails().contains("0000-0000-0000-0001_2@test.orcid.org"));
assertTrue(deprecateProfile.getErrors().isEmpty());
// Using orcid
deprecateProfile = new DeprecateProfile();
deprecateProfile.setDeprecatingOrcidOrEmail(DEPRECATED_USER_ORCID);
deprecateProfile.setDeprecatingPassword("password");
deprecateProfile = controller.validateDeprecateProfile(deprecateProfile);
assertNotNull(deprecateProfile.getDeprecatingAccountName());
assertNotNull(deprecateProfile.getDeprecatingEmails());
assertEquals("0000-0000-0000-0002", deprecateProfile.getDeprecatingOrcid());
assertEquals("0000-0000-0000-0002 Given Names 0000-0000-0000-0002 Family Name", deprecateProfile.getDeprecatingAccountName());
assertEquals(2, deprecateProfile.getDeprecatingEmails().size());
assertTrue(deprecateProfile.getDeprecatingEmails().contains("0000-0000-0000-0002_1@test.orcid.org"));
assertTrue(deprecateProfile.getDeprecatingEmails().contains("0000-0000-0000-0002_2@test.orcid.org"));
assertEquals("0000-0000-0000-0001", deprecateProfile.getPrimaryOrcid());
assertEquals("0000-0000-0000-0001 Given Names 0000-0000-0000-0001 Family Name", deprecateProfile.getPrimaryAccountName());
assertNotNull(deprecateProfile.getPrimaryEmails());
assertEquals(2, deprecateProfile.getPrimaryEmails().size());
assertTrue(deprecateProfile.getPrimaryEmails().contains("0000-0000-0000-0001_1@test.orcid.org"));
assertTrue(deprecateProfile.getPrimaryEmails().contains("0000-0000-0000-0001_2@test.orcid.org"));
assertTrue(deprecateProfile.getErrors().isEmpty());
}
use of org.orcid.pojo.DeprecateProfile in project ORCID-Source by ORCID.
the class ManageProfileControllerTest method testValidateDeprecateProfileWithInvalidDataMatchingAccounts.
@Test
public void testValidateDeprecateProfileWithInvalidDataMatchingAccounts() {
SecurityContextHolder.getContext().setAuthentication(getAuthentication(DEPRECATED_USER_ORCID));
DeprecateProfile deprecateProfile = new DeprecateProfile();
deprecateProfile.setDeprecatingOrcidOrEmail(DEPRECATED_USER_ORCID);
deprecateProfile.setPrimaryOrcid(DEPRECATED_USER_ORCID);
deprecateProfile.setDeprecatingPassword("password");
deprecateProfile = controller.validateDeprecateProfile(deprecateProfile);
assertNull(deprecateProfile.getDeprecatingAccountName());
assertNotNull(deprecateProfile.getErrors());
assertEquals(1, deprecateProfile.getErrors().size());
assertEquals("deprecate_orcid.profile_matches_current", deprecateProfile.getErrors().get(0));
}
use of org.orcid.pojo.DeprecateProfile in project ORCID-Source by ORCID.
the class ManageProfileControllerTest method testConfirmDeprecateProfileWithInvalidDataBadCredentials.
@Test
public void testConfirmDeprecateProfileWithInvalidDataBadCredentials() {
SecurityContextHolder.getContext().setAuthentication(getAuthentication(USER_ORCID));
// Using email
DeprecateProfile deprecateProfile = new DeprecateProfile();
deprecateProfile.setPrimaryOrcid(USER_ORCID);
deprecateProfile.setDeprecatingOrcidOrEmail("0000-0000-0000-0002_1@test.orcid.org");
deprecateProfile.setDeprecatingPassword("invalid password");
deprecateProfile = controller.confirmDeprecateProfile(deprecateProfile);
assertNull(deprecateProfile.getDeprecatingAccountName());
assertNotNull(deprecateProfile.getErrors());
assertEquals(1, deprecateProfile.getErrors().size());
assertEquals("check_password_modal.incorrect_password", deprecateProfile.getErrors().get(0));
// Using orcid
deprecateProfile = new DeprecateProfile();
deprecateProfile.setDeprecatingOrcidOrEmail(DEPRECATED_USER_ORCID);
deprecateProfile.setDeprecatingPassword("invalid password");
deprecateProfile = controller.confirmDeprecateProfile(deprecateProfile);
assertNull(deprecateProfile.getDeprecatingAccountName());
assertNotNull(deprecateProfile.getErrors());
assertEquals(1, deprecateProfile.getErrors().size());
assertEquals("check_password_modal.incorrect_password", deprecateProfile.getErrors().get(0));
}
use of org.orcid.pojo.DeprecateProfile in project ORCID-Source by ORCID.
the class ManageProfileControllerTest method testValidateDeprecateProfileWithInvalidDataDeactivatedProfile.
@Test
public void testValidateDeprecateProfileWithInvalidDataDeactivatedProfile() {
SecurityContextHolder.getContext().setAuthentication(getAuthentication(USER_ORCID));
// Apply mocks
mocksForDeactivatedAccounts();
// Using orcid
DeprecateProfile deprecateProfile = new DeprecateProfile();
deprecateProfile.setPrimaryOrcid(USER_ORCID);
deprecateProfile.setDeprecatingOrcidOrEmail(DEPRECATED_USER_ORCID);
deprecateProfile.setDeprecatingPassword("password");
deprecateProfile = controller.validateDeprecateProfile(deprecateProfile);
assertNull(deprecateProfile.getDeprecatingAccountName());
assertNotNull(deprecateProfile.getErrors());
assertEquals(1, deprecateProfile.getErrors().size());
assertEquals("deprecate_orcid.already_deactivated", deprecateProfile.getErrors().get(0));
// Using email
deprecateProfile = new DeprecateProfile();
deprecateProfile.setDeprecatingOrcidOrEmail("0000-0000-0000-0002_1@test.orcid.org");
deprecateProfile.setDeprecatingPassword("password");
deprecateProfile = controller.validateDeprecateProfile(deprecateProfile);
assertNull(deprecateProfile.getDeprecatingAccountName());
assertNotNull(deprecateProfile.getErrors());
assertEquals(1, deprecateProfile.getErrors().size());
assertEquals("deprecate_orcid.already_deactivated", deprecateProfile.getErrors().get(0));
}
Aggregations