use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class MappingContextTest method testMappingContextConnectorObject.
@Test
public void testMappingContextConnectorObject() {
SysSystemDto system = helper.createTestResourceSystem(true);
Assert.assertNotNull(system);
SysSystemMappingDto mapping = systemMappingService.findProvisioningMapping(system.getId(), SystemEntityType.IDENTITY);
Assert.assertNotNull(mapping);
// Create the description attribute (print context as string).
createDescriptionAttribute(system, mapping);
// Set context transformation to the mapping
// Add connector object to the context.
mapping.setAddContextConnectorObject(true);
mapping = initContextForMapping(mapping);
IdmRoleDto roleWithSystem = helper.createRole();
helper.createRoleSystem(roleWithSystem, system);
IdmIdentityDto identity = helper.createIdentity();
helper.createContract(identity, null, LocalDate.now(), null);
List<IdmIdentityContractDto> contracts = identityContractService.findAllByIdentity(identity.getId());
Assert.assertEquals(2, contracts.size());
helper.createIdentityRole(identity, roleWithSystem, null, null);
TestResource resource = helper.findResource(identity.getUsername());
assertNotNull(resource);
assertEquals(identity.getFirstName(), resource.getFirstname());
MappingContext context = new MappingContext();
context.put("test", "TestValueOne");
assertEquals(context.toString(), resource.getDescrip());
SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
IcConnectorObject connectorObject = systemEntityService.getConnectorObject(systemEntity);
Assert.assertNotNull(connectorObject);
// Invoke provisioning
identityService.save(identity);
resource = helper.findResource(identity.getUsername());
assertNotNull(resource);
assertEquals(identity.getFirstName(), resource.getFirstname());
context = new MappingContext();
context.put("test", "TestValueOne");
context.setConnectorObject(connectorObject);
assertEquals(context.toString(), resource.getDescrip());
// Delete role mapping
systemMappingService.delete(mapping);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class ProvisioningBreakProcessorTest method testClearCache.
@Test
public void testClearCache() {
SysSystemDto system = getHelper().createTestResourceSystem(true);
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
createProvisioningBreak(20l, 3, null, ProvisioningEventType.UPDATE, system.getId());
//
this.createAccount(system, identity);
//
// create
provisioningService.doProvisioning(identity);
//
SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
SysProvisioningBatchDto batch = batchService.findBatch(systemEntity.getId());
List<SysProvisioningOperationDto> content = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
//
provisioningService.doProvisioning(identity);
//
content = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
//
provisioningService.doProvisioning(identity);
//
content = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
//
assertTrue(content.isEmpty());
//
SysBlockedOperationDto blockedOperation = new SysBlockedOperationDto();
blockedOperation.blockUpdate();
system.setBlockedOperation(blockedOperation);
// block system
system = systemService.save(system);
//
blockedOperation = new SysBlockedOperationDto();
blockedOperation.setUpdateOperation(Boolean.FALSE);
system.setBlockedOperation(blockedOperation);
// unblock system, clear cache
system = systemService.save(system);
//
provisioningService.doProvisioning(identity);
provisioningService.doProvisioning(identity);
//
systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
batch = batchService.findBatch(systemEntity.getId());
//
assertEquals(0, provisioningOperationService.findByBatchId(batch.getId(), null).getTotalElements());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class ProvisioningBreakProcessorTest method testBlockSystemUpdateCombination.
@Test
public void testBlockSystemUpdateCombination() {
SysSystemDto system = getHelper().createTestResourceSystem(true);
//
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
createProvisioningBreak(20l, 1, null, ProvisioningEventType.UPDATE, system.getId());
//
this.createAccount(system, identity);
//
//
// create
provisioningService.doProvisioning(identity);
//
SysSystemEntityDto systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
SysProvisioningBatchDto batch = batchService.findBatch(systemEntity.getId());
List<SysProvisioningOperationDto> content = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
//
assertTrue(content.isEmpty());
//
provisioningService.doProvisioning(identity);
// block
provisioningService.doProvisioning(identity);
//
systemEntity = systemEntityService.getBySystemAndEntityTypeAndUid(system, SystemEntityType.IDENTITY, identity.getUsername());
batch = batchService.findBatch(systemEntity.getId());
content = provisioningOperationService.findByBatchId(batch.getId(), null).getContent();
assertEquals(1, content.size());
//
SysProvisioningOperationDto sysProvisioningOperationDto = content.get(0);
//
assertEquals(ProvisioningEventType.UPDATE, sysProvisioningOperationDto.getOperationType());
assertEquals(OperationState.BLOCKED, sysProvisioningOperationDto.getResult().getState());
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemServiceIntegrationTest method testReferentialIntegrityProvisioningOperationExists.
@Test(expected = ResultCodeException.class)
public void testReferentialIntegrityProvisioningOperationExists() {
SysSystemDto system = new SysSystemDto();
String systemName = "t_s_" + System.currentTimeMillis();
system.setName(systemName);
system = systemService.save(system);
// system entity
SysSystemEntityDto systemEntity = new SysSystemEntityDto();
systemEntity.setUid("test");
systemEntity.setSystem(system.getId());
systemEntity.setEntityType(SystemEntityType.IDENTITY);
systemEntity = systemEntityService.save(systemEntity);
SysProvisioningOperationDto provisioningOperation = new SysProvisioningOperationDto();
provisioningOperation.setSystem(system.getId());
provisioningOperation.setEntityType(SystemEntityType.IDENTITY);
provisioningOperation.setOperationType(ProvisioningEventType.CREATE);
provisioningOperation.setSystemEntity(systemEntity.getId());
provisioningOperation.setEntityIdentifier(UUID.randomUUID());
provisioningOperation.setProvisioningContext(new ProvisioningContext());
provisioningOperation.setResult(new OperationResult());
provisioningOperationService.save(provisioningOperation);
//
systemService.delete(system);
}
use of eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method testUpdateWishIfSystemEntityExists.
@Test
public void testUpdateWishIfSystemEntityExists() {
String username = getHelper().createName();
SysSystemDto system = getHelper().createTestResourceSystem(true);
//
// prepare resource
IdmIdentityDto identity = getHelper().createIdentity(username, (GuardedString) null);
TestResource resource = new TestResource();
resource.setName(username);
resource.setFirstname(identity.getFirstName());
resource.setLastname(identity.getLastName());
// TODO: test constant
resource.setStatus("enabled");
resource = getHelper().saveResource(resource);
//
// prepare identity with account on target system with the same system entity as prepared
IdmRoleDto role = getHelper().createRole();
getHelper().createRoleSystem(role, system);
getHelper().createIdentityRole(identity, role);
//
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
AccIdentityAccountDto accountIdentityOne = identityAccountService.find(filter, null).getContent().get(0);
AccAccountDto account = accountService.get(accountIdentityOne.getAccount());
//
SysSystemEntityDto systemEntity = DtoUtils.getEmbedded(account, AccAccount_.systemEntity);
//
resource = helper.findResource(account.getRealUid());
//
Assert.assertFalse(systemEntity.isWish());
}
Aggregations