use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto in project CzechIdMng by bcvsolutions.
the class IdentityAccountManagementTest method defaultAccountChange.
@Test
public void defaultAccountChange() {
IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
identity.setFirstName(IDENTITY_CHANGED_FIRST_NAME);
// This evokes Identity SAVE event. On this event will be start account
// management and provisioning
identityService.save(identity);
TestResource createdAccount = helper.findResource("x" + IDENTITY_USERNAME);
Assert.assertNotNull("Idenitity have to exists on target system (after account management)", createdAccount);
Assert.assertEquals("Account on target system, must have changed first name!", IDENTITY_CHANGED_FIRST_NAME, createdAccount.getFirstname());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto in project CzechIdMng by bcvsolutions.
the class IdentityAccountManagementTest method defaultAccountRemove.
@Test
public void defaultAccountRemove() {
TestResource createdAccount = helper.findResource("x" + IDENTITY_USERNAME);
Assert.assertNotNull("Idenitity have to exists on target system (before account will be delete)", createdAccount);
AccAccountFilter accountFilter = new AccAccountFilter();
accountFilter.setUid("x" + IDENTITY_USERNAME);
Assert.assertEquals("Account needs to exist befor will be delete", 1, accountService.find(accountFilter, null).getContent().size());
IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
IdmIdentityRoleFilter irfilter = new IdmIdentityRoleFilter();
irfilter.setIdentityId(identity.getId());
IdmIdentityRoleDto identityRoleToDelete = identityRoleService.find(irfilter, null).getContent().get(0);
// This evokes IdentityRole DELETE event. On this event will be start
// account management and provisioning
identityRoleService.deleteById(identityRoleToDelete.getId());
Assert.assertEquals("Account must not be after was deleted", 0, accountService.find(accountFilter, null).getContent().size());
AccIdentityAccountFilter iaccFilter = new AccIdentityAccountFilter();
iaccFilter.setIdentityId(identity.getId());
Assert.assertEquals("Idenitity account have to not exists after account was deleted!", 0, identityAccountService.find(iaccFilter, null).getContent().size());
createdAccount = helper.findResource("x" + IDENTITY_USERNAME);
Assert.assertNull("Idenitity have to no exists on target system (after account was deleted)", createdAccount);
// Reset value
identity.setFirstName(IDENTITY_USERNAME);
identityService.save(identity);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto in project CzechIdMng by bcvsolutions.
the class IdentityAccountManagementTest method overloadedAttributeAdd_A_LastNameRole.
@Test
public void overloadedAttributeAdd_A_LastNameRole() {
IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
IdmRoleDto roleLastName = roleService.getByCode(ROLE_OVERLOADING_LAST_NAME);
Assert.assertNull("No account for this identity can be found, before account management start!", helper.findResource("x" + IDENTITY_USERNAME));
IdmIdentityRoleDto irdto = new IdmIdentityRoleDto();
irdto.setIdentityContract(identityContractService.findAllByIdentity(identity.getId()).get(0).getId());
irdto.setRole(roleLastName.getId());
// This evokes IdentityRole SAVE event. On this event will be start
// account management and provisioning
IdmIdentityRoleDto irCreated = identityRoleService.save(irdto);
AccIdentityAccountFilter iaccFilter = new AccIdentityAccountFilter();
iaccFilter.setIdentityId(identity.getId());
iaccFilter.setIdentityRoleId(irCreated.getId());
AccIdentityAccountDto identityAccount = identityAccountService.find(iaccFilter, null).getContent().get(0);
Assert.assertNotNull("Idenitity account have to exists after account management was started!", identityAccount);
Assert.assertNotNull("Account have to exists after account management was started!", identityAccount.getAccount());
Assert.assertEquals(accountService.get(identityAccount.getAccount()).getUid(), "x" + IDENTITY_USERNAME);
TestResource createdAccount = helper.findResource("x" + IDENTITY_USERNAME);
Assert.assertNotNull("Idenitity have to exists on target system (after account management)", createdAccount);
Assert.assertEquals("Last name on target system must be equals with email on identity (we use overloded attribute)", identity.getEmail(), createdAccount.getLastname());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto in project CzechIdMng by bcvsolutions.
the class AccountProtectionExpirationTaskExecutorIntegrationTest method testRemoveExpiredAccount.
@Test
public void testRemoveExpiredAccount() {
IdmIdentityDto identity = helper.createIdentity();
IdmRoleDto role = helper.createRole();
SysSystemDto system = helper.createTestResourceSystem(true);
SysSystemMappingDto mapping = helper.getDefaultMapping(system);
mapping.setProtectionInterval(1);
mapping.setProtectionEnabled(true);
systemMappingService.save(mapping);
helper.createRoleSystem(role, system);
IdmIdentityRoleDto identityRole = helper.createIdentityRole(identity, role);
//
AccAccountDto account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNotNull(account);
Assert.assertFalse(account.isInProtection());
TestResource createdAccount = helper.findResource(account.getUid());
Assert.assertNotNull(createdAccount);
Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
//
// remove role
identityRoleService.deleteById(identityRole.getId());
//
account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNotNull(account);
Assert.assertTrue(account.isInProtection());
Assert.assertNotNull(account.getEndOfProtection());
createdAccount = helper.findResource(account.getUid());
Assert.assertNotNull(createdAccount);
Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
//
// test LRT - nothing to remove
AccountProtectionExpirationTaskExecutor taskExecutor = new AccountProtectionExpirationTaskExecutor();
longRunningTaskManager.execute(taskExecutor);
//
account = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNotNull(account);
Assert.assertTrue(account.isInProtection());
Assert.assertNotNull(account.getEndOfProtection());
createdAccount = helper.findResource(account.getUid());
Assert.assertNotNull(createdAccount);
Assert.assertEquals(identity.getFirstName(), createdAccount.getFirstname());
// change account expiration
account.setEndOfProtection(new DateTime().minusDays(1));
account = accountService.save(account);
taskExecutor = new AccountProtectionExpirationTaskExecutor();
longRunningTaskManager.execute(taskExecutor);
AccAccountDto removedAccount = accountService.getAccount(identity.getUsername(), system.getId());
Assert.assertNull(removedAccount);
createdAccount = helper.findResource(account.getUid());
Assert.assertNull(createdAccount);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto in project CzechIdMng by bcvsolutions.
the class CleanProvisioningQueueTaskExecutorIntegrationTest method createIdentity.
private IdmIdentityDto createIdentity(String firstName, String lastName, String email, String phone, boolean disabled) {
IdmIdentityDto identity2 = helper.createIdentity();
identity2.setFirstName(firstName);
identity2.setLastName(lastName);
identity2.setEmail(email);
identity2.setPhone(phone);
return idmIdentityService.save(identity2);
}
Aggregations