use of eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto in project CzechIdMng by bcvsolutions.
the class DefaultRoleSynchronizationServiceTest method createProvisionigMapping.
private void createProvisionigMapping() {
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setName(SYNC_CONFIG_NAME);
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
Assert.assertEquals(1, syncConfigs.size());
AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
SysSystemMappingDto systemMappingSync = systemMappingService.get(syncConfigCustom.getSystemMapping());
// Create provisioning mapping
SysSystemMappingDto systemMapping = new SysSystemMappingDto();
systemMapping.setName("default_" + System.currentTimeMillis());
systemMapping.setEntityType(SystemEntityType.ROLE);
systemMapping.setOperationType(SystemOperationType.PROVISIONING);
systemMapping.setObjectClass(systemMappingSync.getObjectClass());
final SysSystemMappingDto syncMapping = systemMappingService.save(systemMapping);
createMapping(systemService.get(schemaObjectClassService.get(systemMappingSync.getObjectClass()).getSystem()), syncMapping);
}
use of eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationServiceTest method escape0x00FromStringTest.
@Test
@Transactional
public /**
* Testing problem on Postgres, where cannot be save 0x00 to TEXT column.
* Problem solving converter between entity and DTO (StringToStringConverter)
*/
void escape0x00FromStringTest() {
String errorString0x00 = "\0x00";
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setName(SYNC_CONFIG_NAME);
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
Assert.assertEquals(1, syncConfigs.size());
AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
SysSyncLogDto log = new SysSyncLogDto();
log.setSynchronizationConfig(syncConfigCustom.getId());
log.setLog(errorString0x00);
log.setToken(errorString0x00);
syncLogService.save(log);
syncConfigCustom.setName(errorString0x00);
syncConfigCustom.setToken(errorString0x00);
syncConfigService.save(syncConfigCustom);
}
use of eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationServiceTest method doStartSyncB_Linked_doUnLinked.
@Test
public void doStartSyncB_Linked_doUnLinked() {
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setName(SYNC_CONFIG_NAME);
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
Assert.assertEquals(1, syncConfigs.size());
AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
// Set sync config
syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UNLINK);
syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigCustom.setReconciliation(true);
syncConfigService.save(syncConfigCustom);
// Check state before sync
AccIdentityAccountFilter identityAccountFilterOne = new AccIdentityAccountFilter();
identityAccountFilterOne.setIdentityId(identityService.getByUsername("x" + IDENTITY_USERNAME_ONE).getId());
Assert.assertEquals(1, identityAccoutnService.find(identityAccountFilterOne, null).getTotalElements());
AccIdentityAccountFilter identityAccountFilterTwo = new AccIdentityAccountFilter();
identityAccountFilterTwo.setIdentityId(identityService.getByUsername("x" + IDENTITY_USERNAME_ONE).getId());
Assert.assertEquals(1, identityAccoutnService.find(identityAccountFilterTwo, null).getTotalElements());
// Start synchronization
synchornizationService.setSynchronizationConfigId(syncConfigCustom.getId());
synchornizationService.process();
//
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.UNLINK == action.getSyncAction();
}).findFirst().get();
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(actionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(2, items.size());
// Check state after sync
Assert.assertEquals(0, identityAccoutnService.find(identityAccountFilterOne, null).getTotalElements());
Assert.assertEquals(0, identityAccoutnService.find(identityAccountFilterTwo, null).getTotalElements());
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationServiceTest method doStartSyncA_MissingEntity.
@Test
public void doStartSyncA_MissingEntity() {
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setName(SYNC_CONFIG_NAME);
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
Assert.assertEquals(1, syncConfigs.size());
AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
//
synchornizationService.setSynchronizationConfigId(syncConfigCustom.getId());
synchornizationService.process();
//
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 createEntityActionLog = actions.stream().filter(action -> {
return SynchronizationActionType.CREATE_ENTITY == action.getSyncAction();
}).findFirst().get();
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(createEntityActionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(2, items.size());
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationServiceTest method doStartSyncC_Unlinked_doLinkAndUpdateAccount.
@Test
public void doStartSyncC_Unlinked_doLinkAndUpdateAccount() {
// We have to do unlink first
this.doStartSyncB_Linked_doUnLinked();
SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
configFilter.setName(SYNC_CONFIG_NAME);
List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
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.LINK_AND_UPDATE_ACCOUNT);
syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
syncConfigCustom.setReconciliation(true);
syncConfigService.save(syncConfigCustom);
IdmIdentityDto identityOne = identityService.getByUsername("x" + IDENTITY_USERNAME_ONE);
IdmIdentityDto identityTwo = identityService.getByUsername("x" + IDENTITY_USERNAME_TWO);
identityOne.setFirstName(IDENTITY_USERNAME_ONE);
identityTwo.setLastName(IDENTITY_USERNAME_TWO);
identityService.save(identityOne);
identityService.save(identityTwo);
// Change account on resource
getBean().changeResourceData();
// Check state before sync
AccIdentityAccountFilter identityAccountFilterOne = new AccIdentityAccountFilter();
identityAccountFilterOne.setIdentityId(identityOne.getId());
Assert.assertEquals(0, identityAccoutnService.find(identityAccountFilterOne, null).getTotalElements());
AccIdentityAccountFilter identityAccountFilterTwo = new AccIdentityAccountFilter();
identityAccountFilterTwo.setIdentityId(identityTwo.getId());
Assert.assertEquals(0, identityAccoutnService.find(identityAccountFilterTwo, null).getTotalElements());
Assert.assertEquals(IDENTITY_USERNAME_ONE, identityOne.getFirstName());
Assert.assertEquals(IDENTITY_USERNAME_TWO, identityTwo.getLastName());
Assert.assertNotEquals(IDENTITY_USERNAME_ONE, entityManager.find(TestResource.class, "x" + IDENTITY_USERNAME_ONE).getFirstname());
Assert.assertNotEquals(IDENTITY_USERNAME_TWO, entityManager.find(TestResource.class, "x" + IDENTITY_USERNAME_TWO).getLastname());
// Start synchronization
synchornizationService.setSynchronizationConfigId(syncConfigCustom.getId());
synchornizationService.process();
//
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.LINK_AND_UPDATE_ACCOUNT == action.getSyncAction();
}).findFirst().get();
SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
itemLogFilter.setSyncActionLogId(actionLog.getId());
List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
Assert.assertEquals(2, items.size());
// Check state after sync
Assert.assertEquals(IDENTITY_USERNAME_ONE, entityManager.find(TestResource.class, "x" + IDENTITY_USERNAME_ONE).getFirstname());
Assert.assertEquals(IDENTITY_USERNAME_TWO, entityManager.find(TestResource.class, "x" + IDENTITY_USERNAME_TWO).getLastname());
// Delete log
syncLogService.delete(log);
}
Aggregations