use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class RoleWorkflowAdSyncTest method createRolesInSystem.
private void createRolesInSystem() {
SysSystemDto system = initData();
IdmRoleFilter roleFilter = new IdmRoleFilter();
roleFilter.setText(ROLE_NAME);
List<IdmRoleDto> roles = roleService.find(roleFilter, null).getContent();
Assert.assertEquals(0, roles.size());
Assert.assertNotNull(system);
SysSyncRoleConfigDto config = doCreateSyncConfig(system);
config.setLinkedActionWfKey(wfExampleKey);
config.setMissingAccountActionWfKey(wfExampleKey);
config.setMissingEntityActionWfKey(wfExampleKey);
config.setUnlinkedActionWfKey(wfExampleKey);
config = (SysSyncRoleConfigDto) syncConfigService.save(config);
// Start sync
helper.startSynchronization(config);
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.MISSING_ENTITY, 1, OperationResultType.WF);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
roles = roleService.find(roleFilter, null).getContent();
Assert.assertEquals(1, roles.size());
IdmRoleDto role = roles.get(0);
List<IdmFormValueDto> dnValues = formService.getValues(role, ATTRIBUTE_DN);
Assert.assertEquals(1, dnValues.size());
Assert.assertEquals(ATTRIBUTE_DN_VALUE, dnValues.get(0).getValue());
IdmRoleCatalogueDto catalogueFirst = getCatalogueByCode(CATALOGUE_CODE_FIRST);
IdmRoleCatalogueDto catalogueSecond = getCatalogueByCode(CATALOGUE_CODE_SECOND);
Assert.assertNotNull(catalogueFirst);
Assert.assertNotNull(catalogueSecond);
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class IdmRoleControllerRestTest method testFindWithoutCatalogue.
@Test
public void testFindWithoutCatalogue() {
// prepare role catalogue
IdmRoleCatalogueDto roleCatalogue = getHelper().createRoleCatalogue();
// create roles
String environment = getHelper().createName();
IdmRoleDto roleOne = getHelper().createRole(null, null, environment);
IdmRoleDto roleTwo = getHelper().createRole(null, null, environment);
// assign role into catalogue
getHelper().createRoleCatalogueRole(roleOne, roleCatalogue);
//
// test
IdmRoleFilter filter = new IdmRoleFilter();
filter.setEnvironment(environment);
filter.setWithoutCatalogue(Boolean.TRUE);
List<IdmRoleDto> roles = find(filter);
Assert.assertEquals(1, roles.size());
Assert.assertTrue(roles.stream().anyMatch(r -> r.getId().equals(roleTwo.getId())));
//
filter.setWithoutCatalogue(Boolean.FALSE);
roles = find(filter);
Assert.assertEquals(1, roles.size());
Assert.assertTrue(roles.stream().anyMatch(r -> r.getId().equals(roleOne.getId())));
//
filter.setWithoutCatalogue(null);
roles = find(filter);
Assert.assertEquals(2, roles.size());
Assert.assertTrue(roles.stream().anyMatch(r -> r.getId().equals(roleOne.getId())));
Assert.assertTrue(roles.stream().anyMatch(r -> r.getId().equals(roleTwo.getId())));
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultRoleSynchronizationServiceTest method doStartSyncB_Linked_doEntityUpdate.
@Test
public void doStartSyncB_Linked_doEntityUpdate() {
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setName(SYNC_CONFIG_NAME);
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
// Change node code to changed
this.getBean().changeOne();
Assert.assertEquals(1, syncConfigs.size());
AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
// Set sync config
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigService.save(syncConfigCustom);
// Check state before sync
IdmRoleFilter roleFilter = new IdmRoleFilter();
roleFilter.setProperty(IdmRole_.code.getName());
roleFilter.setValue("1");
Assert.assertEquals("1", roleService.find(roleFilter, null).getContent().get(0).getDescription());
helper.startSynchronization(syncConfigCustom);
//
SysSyncLogFilter logFilter = new SysSyncLogFilter();
logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
Assert.assertEquals(1, logs.size());
SysSyncLogDto log = logs.get(0);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
SysSyncActionLogFilter actionLogFilter = new SysSyncActionLogFilter();
actionLogFilter.setSynchronizationLogId(log.getId());
List<SysSyncActionLogDto> actions = syncActionLogService.find(actionLogFilter, null).getContent();
Assert.assertEquals(1, actions.size());
SysSyncActionLogDto actionLog = actions.stream().filter(action -> {
return SynchronizationActionType.UPDATE_ENTITY == action.getSyncAction();
}).findFirst().get();
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(actionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(5, items.size());
// Check state after sync
Assert.assertEquals(CHANGED, roleService.find(roleFilter, null).getContent().get(0).getDescription());
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultRoleSynchronizationServiceTest method doStartSyncB_MissingAccount_DeleteEntity.
@Test
public void doStartSyncB_MissingAccount_DeleteEntity() {
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setName(SYNC_CONFIG_NAME);
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
// Remove node code to changed
this.getBean().removeOne();
Assert.assertEquals(1, syncConfigs.size());
AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
// Set sync config
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.IGNORE);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.DELETE_ENTITY);
syncConfigCustom.setReconciliation(true);
syncConfigService.save(syncConfigCustom);
// Check state before sync
IdmRoleFilter roleFilter = new IdmRoleFilter();
roleFilter.setProperty(IdmRole_.code.getName());
roleFilter.setValue("1");
IdmRoleDto roleOne = roleService.find(roleFilter, null).getContent().get(0);
Assert.assertNotNull(roleOne);
helper.startSynchronization(syncConfigCustom);
//
SysSyncLogFilter logFilter = new SysSyncLogFilter();
logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
Assert.assertEquals(1, logs.size());
SysSyncLogDto log = logs.get(0);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
SysSyncActionLogFilter actionLogFilter = new SysSyncActionLogFilter();
actionLogFilter.setSynchronizationLogId(log.getId());
List<SysSyncActionLogDto> actions = syncActionLogService.find(actionLogFilter, null).getContent();
Assert.assertEquals(2, actions.size());
SysSyncActionLogDto actionLog = actions.stream().filter(action -> {
return SynchronizationActionType.DELETE_ENTITY == action.getSyncAction();
}).findFirst().get();
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(actionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(1, items.size());
// Check state after sync
roleOne = roleService.get(roleOne.getId());
Assert.assertNull(roleOne);
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.
the class DefaultRoleSynchronizationServiceTest method provisioningD_UpdateAccount_Extended_Attribute.
@Test
public void provisioningD_UpdateAccount_Extended_Attribute() {
// Create mapping for provisioning
SysSystemMappingDto mapping = this.createProvisionigMapping();
IdmRoleFilter filter = new IdmRoleFilter();
filter.setProperty(IdmRole_.code.getName());
filter.setValue(ROLE_NAME_TEN);
IdmRoleDto roleTen = roleService.find(filter, null).getContent().get(0);
Assert.assertNotNull(roleTen);
Assert.assertTrue(formService.getValues(roleTen.getId(), IdmRole.class, "changed").isEmpty());
// Check state before provisioning
TestRoleResource ten = entityManager.find(TestRoleResource.class, ROLE_NAME_TEN);
Assert.assertNotNull(ten);
Assert.assertEquals(null, ten.getModified());
// Create extended attribute
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_TABLE_CONNECTOR_FORMAT);
ZonedDateTime now = ZonedDateTime.now();
formService.saveValues(roleTen.getId(), IdmRole.class, "changed", ImmutableList.of(now.withZoneSameInstant(ZoneOffset.UTC).format(formatter)));
// Save IDM changed node (must invoke provisioning)
roleService.save(roleTen);
// Check state after provisioning
ten = entityManager.find(TestRoleResource.class, ROLE_NAME_TEN);
Assert.assertNotNull(ten);
Assert.assertEquals(now.format(formatter), ten.getModified().format(formatter));
// Delete role mapping
systemMappingService.delete(mapping);
}
Aggregations