use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.
the class DefaultProvisioningExecutorIntegrationTest method testClearProvisioningBatchOnReadonlySystem.
@Test
public void testClearProvisioningBatchOnReadonlySystem() {
SysSystemDto system = helper.createTestResourceSystem(true);
system.setReadonly(true);
system = systemService.save(system);
String firstname = "firstname";
SysProvisioningOperationDto provisioningOperation = createProvisioningOperation(system, firstname);
Map<ProvisioningAttributeDto, Object> accoutObject = provisioningOperation.getProvisioningContext().getAccountObject();
String uid = (String) accoutObject.get(getProvisioningAttribute(TestHelper.ATTRIBUTE_MAPPING_NAME));
//
// publish event
// 1 - create
provisioningExecutor.execute(provisioningOperation);
// is necessary to get again operation from service
SysProvisioningOperationFilter filter = new SysProvisioningOperationFilter();
filter.setSystemEntity(provisioningOperation.getSystemEntity());
filter.setSystemId(system.getId());
SysProvisioningOperationDto readOnlyOperation = provisioningOperationService.find(filter, null).getContent().get(0);
assertEquals(OperationState.NOT_EXECUTED, readOnlyOperation.getResultState());
assertEquals(AccResultCode.PROVISIONING_SYSTEM_READONLY.name(), readOnlyOperation.getResult().getModel().getStatusEnum());
SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
// 2 - update
provisioningExecutor.execute(updateProvisioningOperation(systemEntity, firstname + 2));
// 3 - update
provisioningExecutor.execute(updateProvisioningOperation(systemEntity, firstname + 3));
//
systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
assertTrue(systemEntity.isWish());
assertNull(helper.findResource(uid));
//
// check batch
SysProvisioningBatchDto batch = provisioningBatchService.findBatch(system.getId(), readOnlyOperation.getEntityIdentifier(), systemEntity.getId());
Assert.assertNotNull(batch);
//
// check provisioning operation requests
List<SysProvisioningOperationDto> requests = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
Assert.assertEquals(3, requests.size());
//
// execute first operation - create
system.setReadonly(false);
system = systemService.save(system);
provisioningExecutor.execute(readOnlyOperation);
Assert.assertNull(provisioningOperationService.get(readOnlyOperation.getId()));
//
systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, uid);
assertFalse(systemEntity.isWish());
TestResource resource = helper.findResource(uid);
assertNotNull(resource);
Assert.assertEquals(firstname, resource.getFirstname());
Assert.assertEquals(2, provisioningOperationService.findByBatchId(batch.getId(), null).getContent().size());
//
// execute whole batch
provisioningExecutor.execute(batch);
//
resource = helper.findResource(uid);
Assert.assertEquals(firstname + 3, resource.getFirstname());
Assert.assertEquals(0, provisioningOperationService.findByBatchId(batch.getId(), null).getTotalElements());
Assert.assertNull(provisioningOperationService.get(readOnlyOperation.getId()));
Assert.assertNull(provisioningBatchService.get(batch.getId()));
}
use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.
the class IdentitySyncTest method initIdentityData.
@Transactional
public void initIdentityData() {
deleteAllResourceData();
TestResource resourceUserOne = new TestResource();
resourceUserOne.setName(IDENTITY_ONE);
resourceUserOne.setFirstname(IDENTITY_ONE);
resourceUserOne.setLastname(IDENTITY_ONE);
resourceUserOne.setEavAttribute("1");
entityManager.persist(resourceUserOne);
}
use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.
the class IdentityAccountManagementTest method defaultAccountAddValid.
@Test
public void defaultAccountAddValid() {
IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
IdmRoleDto roleDefault = roleService.getByCode(ROLE_DEFAULT);
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(roleDefault.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(identity.getFirstName(), createdAccount.getFirstname());
}
use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.
the class IdentityAccountManagementTest method overloadedAttributeAdd_B_DisableFirstNameRole.
@Test
public void overloadedAttributeAdd_B_DisableFirstNameRole() {
IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
IdmRoleDto roleLastName = roleService.getByCode(ROLE_OVERLOADING_FIRST_NAME);
Assert.assertNotNull("Account for this identity have to be found!", 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
identityRoleService.save(irdto);
AccIdentityAccountFilter iaccFilter = new AccIdentityAccountFilter();
iaccFilter.setIdentityId(identity.getId());
// Now we have to identity roles (role_overloading_first_name and
// role_overloading_last_name) and identity accounts
Assert.assertEquals("Idenitity accounts have to exists (two items) after account management was started!", 2, identityAccountService.find(iaccFilter, null).getContent().size());
TestResource createdAccount = helper.findResource("x" + IDENTITY_USERNAME);
Assert.assertNotNull("Idenitity have to exists on target system (after account management)", createdAccount);
Assert.assertEquals("First name on target system must be equals with first name on identity", identity.getFirstName(), createdAccount.getFirstname());
identity.setFirstName(IDENTITY_CHANGED_FIRST_NAME);
identity.setEmail(IDENTITY_EMAIL_CHANGED);
// This evokes Identity SAVE event. On this event will be start
// account management and provisioning
identityService.save(identity);
createdAccount = helper.findResource("x" + IDENTITY_USERNAME);
// Because first name attribute was disabled, we now expect change only
// on email attribute
Assert.assertEquals("Last name on target system must be equals with email on identity (we use overloded attribute)", IDENTITY_EMAIL_CHANGED, createdAccount.getLastname());
Assert.assertNotEquals("First name on target system must be not equals with first name on identity (we use overloded disabled attribute)", identity.getFirstName(), createdAccount.getFirstname());
}
use of eu.bcvsolutions.idm.acc.entity.TestResource in project CzechIdMng by bcvsolutions.
the class IdentityAccountManagementTest method defaultAccountDisable.
@Test
public void defaultAccountDisable() {
IdmIdentityDto identity = identityService.getByUsername(IDENTITY_USERNAME);
Assert.assertEquals("Identity must be enabled!", Boolean.FALSE, identity.isDisabled());
TestResource resourceAccount = helper.findResource("x" + IDENTITY_USERNAME);
Assert.assertNotNull("Idenitity have to exists on target system (after account management)", resourceAccount);
Assert.assertEquals("Account on target system, must be enabled", "enabled", resourceAccount.getStatus());
identity.setState(IdentityState.DISABLED);
// This evokes Identity SAVE event. On this event will be start account
// management and provisioning
identityService.save(identity);
resourceAccount = helper.findResource("x" + IDENTITY_USERNAME);
Assert.assertNotNull("Idenitity have to exists on target system (after account management)", resourceAccount);
Assert.assertEquals("Account on target system, must be disabled!", "disabled", resourceAccount.getStatus());
}
Aggregations