use of org.orcid.pojo.ManageDelegate in project ORCID-Source by ORCID.
the class ManageProfileControllerTest method testAddDelegateWithInvalidPassword.
@Test
public void testAddDelegateWithInvalidPassword() {
ManageDelegate manageDelegate = new ManageDelegate();
manageDelegate.setDelegateToManage(USER_ORCID);
manageDelegate.setPassword("invalid password");
controller.addDelegate(manageDelegate);
assertEquals(1, manageDelegate.getErrors().size());
assertEquals("check_password_modal.incorrect_password", manageDelegate.getErrors().get(0));
verify(mockGivenPermissionToManager, times(0)).create(Mockito.anyString(), Mockito.anyString());
}
use of org.orcid.pojo.ManageDelegate in project ORCID-Source by ORCID.
the class ManageProfileControllerTest method testRevokeDelegateWithInvalidPassword.
@Test
public void testRevokeDelegateWithInvalidPassword() {
ManageDelegate manageDelegate = new ManageDelegate();
manageDelegate.setDelegateToManage(USER_ORCID);
manageDelegate.setPassword("invalid password");
controller.revokeDelegate(manageDelegate);
assertEquals(1, manageDelegate.getErrors().size());
assertEquals("check_password_modal.incorrect_password", manageDelegate.getErrors().get(0));
verify(mockGivenPermissionToManager, times(0)).remove(Mockito.anyString(), Mockito.anyString());
}
use of org.orcid.pojo.ManageDelegate in project ORCID-Source by ORCID.
the class ManageProfileControllerTest method testRevokeDelegate.
@Test
public void testRevokeDelegate() {
SecurityContextHolder.getContext().setAuthentication(getAuthentication(USER_ORCID));
ManageDelegate manageDelegate = new ManageDelegate();
manageDelegate.setDelegateToManage("0000-0000-0000-0000");
manageDelegate.setPassword("password");
controller.revokeDelegate(manageDelegate);
assertEquals(0, manageDelegate.getErrors().size());
verify(mockGivenPermissionToManager, times(1)).remove(Mockito.eq(USER_ORCID), Mockito.eq("0000-0000-0000-0000"));
}
use of org.orcid.pojo.ManageDelegate in project ORCID-Source by ORCID.
the class ManageProfileControllerTest method testAddDelegate.
@Test
public void testAddDelegate() throws Exception {
SecurityContextHolder.getContext().setAuthentication(getAuthentication(USER_ORCID));
when(mockProfileEntityCacheManager.retrieve(Mockito.anyString())).then(new Answer<ProfileEntity>() {
@Override
public ProfileEntity answer(InvocationOnMock invocation) throws Throwable {
ProfileEntity entity = new ProfileEntity();
entity.setId(invocation.getArgument(0));
EmailEntity email1 = new EmailEntity();
email1.setId(invocation.getArgument(0) + "_1@test.orcid.org");
email1.setVerified(true);
email1.setCurrent(true);
email1.setDateCreated(new Date());
email1.setLastModified(new Date());
email1.setPrimary(true);
email1.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
Set<EmailEntity> emails = new HashSet<EmailEntity>();
emails.add(email1);
entity.setEmails(emails);
entity.setRecordNameEntity(getRecordName(invocation.getArgument(0)));
// Mark it as deactivated
entity.setDeactivationDate(new Date());
entity.setEncryptedPassword("password");
return entity;
}
});
ManageDelegate addDelegate = new ManageDelegate();
addDelegate.setDelegateToManage("0000-0000-0000-0000");
addDelegate.setPassword("password");
controller.addDelegate(addDelegate);
verify(mockGivenPermissionToManager, times(1)).create(USER_ORCID, "0000-0000-0000-0000");
}
Aggregations