Search in sources :

Example 11 with SysSyncIdentityConfigDto

use of eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto in project CzechIdMng by bcvsolutions.

the class IdentitySyncTest method updateIdentityWithInvalidContractTest.

@Test
public void updateIdentityWithInvalidContractTest() {
    SysSystemDto system = initData();
    Assert.assertNotNull(system);
    SysSyncIdentityConfigDto config = doCreateSyncConfig(system);
    IdmRoleDto defaultRole = helper.createRole();
    // Set default role to sync configuration
    config.setDefaultRole(defaultRole.getId());
    config = (SysSyncIdentityConfigDto) syncConfigService.save(config);
    IdmIdentityDto identityOne = helper.createIdentity(IDENTITY_ONE);
    IdmIdentityContractDto primeContract = contractService.getPrimeContract(identityOne.getId());
    Assert.assertNotNull(primeContract);
    primeContract.setValidTill(LocalDate.now().minusDays(10));
    primeContract = contractService.save(primeContract);
    IdmIdentityFilter identityFilter = new IdmIdentityFilter();
    identityFilter.setUsername(IDENTITY_ONE);
    synchornizationService.setSynchronizationConfigId(config.getId());
    synchornizationService.process();
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.LINK, 1, OperationResultType.WARNING);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    List<IdmIdentityRoleDto> roles = identityRoleService.findAllByIdentity(identityOne.getId());
    Assert.assertEquals(0, roles.size());
    // Delete log
    syncLogService.delete(log);
}
Also used : SysSyncIdentityConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) DefaultSynchronizationServiceTest(eu.bcvsolutions.idm.acc.service.impl.DefaultSynchronizationServiceTest)

Example 12 with SysSyncIdentityConfigDto

use of eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto in project CzechIdMng by bcvsolutions.

the class IdentitySyncTest method testDisableAutomaticRoleDuringSynchronization.

@Test
public void testDisableAutomaticRoleDuringSynchronization() {
    // default initialization of system and all necessary things
    SysSystemDto system = initData();
    SysSyncIdentityConfigDto config = doCreateSyncConfig(system);
    IdmRoleDto defaultRole = helper.createRole();
    // Set default role to sync configuration
    config.setDefaultRole(defaultRole.getId());
    // we want start recalculation after synchronization
    config.setStartAutoRoleRec(false);
    config = (SysSyncIdentityConfigDto) syncConfigService.save(config);
    this.getBean().deleteAllResourceData();
    String testLastName = "test-last-name-same-" + System.currentTimeMillis();
    String testFirstName = "test-first-name";
    String user1 = "test-1-" + System.currentTimeMillis();
    this.getBean().setTestData(user1, testFirstName, testLastName);
    String user2 = "test-2-" + System.currentTimeMillis();
    this.getBean().setTestData(user2, testFirstName, testLastName);
    String user3 = "test-3-" + System.currentTimeMillis();
    this.getBean().setTestData(user3, testFirstName, testLastName);
    IdmRoleDto role1 = helper.createRole();
    IdmAutomaticRoleAttributeDto automaticRole = helper.createAutomaticRole(role1.getId());
    helper.createAutomaticRoleRule(automaticRole.getId(), AutomaticRoleAttributeRuleComparison.EQUALS, AutomaticRoleAttributeRuleType.IDENTITY, IdmIdentity_.username.getName(), null, user1);
    synchornizationService.setSynchronizationConfigId(config.getId());
    synchornizationService.process();
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 3, OperationResultType.WARNING);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    IdmIdentityDto identity1 = identityService.getByUsername(user1);
    IdmIdentityDto identity2 = identityService.getByUsername(user2);
    IdmIdentityDto identity3 = identityService.getByUsername(user3);
    // we must change username, after create contract is also save identity (change state)
    identity1.setUsername(user1 + System.currentTimeMillis());
    identity1 = identityService.save(identity1);
    helper.createIdentityContact(identity1);
    helper.createIdentityContact(identity2);
    helper.createIdentityContact(identity3);
    List<IdmIdentityRoleDto> identityRoles1 = identityRoleService.findAllByIdentity(identity1.getId());
    List<IdmIdentityRoleDto> identityRoles2 = identityRoleService.findAllByIdentity(identity2.getId());
    List<IdmIdentityRoleDto> identityRoles3 = identityRoleService.findAllByIdentity(identity3.getId());
    assertEquals(0, identityRoles1.size());
    assertEquals(0, identityRoles2.size());
    assertEquals(0, identityRoles3.size());
    // enable test processor
    testIdentityProcessor.enable();
    synchornizationService.setSynchronizationConfigId(config.getId());
    synchornizationService.process();
    identityRoles1 = identityRoleService.findAllByIdentity(identity1.getId());
    identityRoles2 = identityRoleService.findAllByIdentity(identity2.getId());
    identityRoles3 = identityRoleService.findAllByIdentity(identity3.getId());
    assertEquals(0, identityRoles1.size());
    assertEquals(0, identityRoles2.size());
    assertEquals(0, identityRoles3.size());
    // synchronization immediately recalculate is disabled
    int size = testIdentityProcessor.getRolesByUsername(user1).size();
    assertEquals(0, size);
    size = testIdentityProcessor.getRolesByUsername(user2).size();
    assertEquals(0, size);
    size = testIdentityProcessor.getRolesByUsername(user3).size();
    assertEquals(0, size);
}
Also used : SysSyncIdentityConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) IdmAutomaticRoleAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) DefaultSynchronizationServiceTest(eu.bcvsolutions.idm.acc.service.impl.DefaultSynchronizationServiceTest)

Example 13 with SysSyncIdentityConfigDto

use of eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto in project CzechIdMng by bcvsolutions.

the class IdentitySyncTest method testLinkAndUpdateIdentity.

@Test
public void testLinkAndUpdateIdentity() {
    SysSystemDto system = initData();
    Assert.assertNotNull(system);
    SysSyncIdentityConfigDto config = doCreateSyncConfig(system);
    config.setUnlinkedAction(SynchronizationUnlinkedActionType.LINK_AND_UPDATE_ENTITY);
    config = (SysSyncIdentityConfigDto) syncConfigService.save(config);
    this.getBean().deleteAllResourceData();
    String testLastName = "test-last-name-same-" + System.currentTimeMillis();
    String testFirstName = "test-first-name-";
    String user1 = "test-1-" + System.currentTimeMillis();
    IdmIdentityDto identity1 = helper.createIdentity(user1);
    this.getBean().setTestData(user1, testFirstName + 1, testLastName);
    String user2 = "test-2-" + System.currentTimeMillis();
    IdmIdentityDto identity2 = helper.createIdentity(user2);
    this.getBean().setTestData(user2, testFirstName + 2, testLastName);
    String user3 = "test-3-" + System.currentTimeMillis();
    IdmIdentityDto identity3 = helper.createIdentity(user3);
    this.getBean().setTestData(user3, testFirstName + 3, testLastName);
    assertNotEquals(testFirstName + 1, identity1.getFirstName());
    assertNotEquals(testFirstName + 2, identity2.getFirstName());
    assertNotEquals(testFirstName + 3, identity3.getFirstName());
    assertNotEquals(testLastName, identity1.getLastName());
    assertNotEquals(testLastName, identity2.getLastName());
    assertNotEquals(testLastName, identity3.getLastName());
    testIdentityProcessor.enable();
    synchornizationService.setSynchronizationConfigId(config.getId());
    synchornizationService.process();
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.LINK_AND_UPDATE_ENTITY, 3, OperationResultType.SUCCESS);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    IdmIdentityDto updatedIdentity1 = identityService.getByUsername(user1);
    IdmIdentityDto updatedIdentity2 = identityService.getByUsername(user2);
    IdmIdentityDto updatedIdentity3 = identityService.getByUsername(user3);
    assertNotEquals(updatedIdentity1.getFirstName(), identity1.getFirstName());
    assertNotEquals(updatedIdentity2.getFirstName(), identity2.getFirstName());
    assertNotEquals(updatedIdentity3.getFirstName(), identity3.getFirstName());
    assertNotEquals(updatedIdentity1.getLastName(), identity1.getLastName());
    assertNotEquals(updatedIdentity2.getLastName(), identity2.getLastName());
    assertNotEquals(updatedIdentity3.getLastName(), identity3.getLastName());
    assertNotEquals(updatedIdentity1.getModified(), identity1.getModified());
    assertNotEquals(updatedIdentity2.getModified(), identity2.getModified());
    assertNotEquals(updatedIdentity3.getModified(), identity3.getModified());
    assertEquals(testFirstName + 1, updatedIdentity1.getFirstName());
    assertEquals(testFirstName + 2, updatedIdentity2.getFirstName());
    assertEquals(testFirstName + 3, updatedIdentity3.getFirstName());
    assertEquals(testLastName, updatedIdentity1.getLastName());
    assertEquals(testLastName, updatedIdentity2.getLastName());
    assertEquals(testLastName, updatedIdentity3.getLastName());
}
Also used : SysSyncIdentityConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) DefaultSynchronizationServiceTest(eu.bcvsolutions.idm.acc.service.impl.DefaultSynchronizationServiceTest)

Aggregations

SysSyncIdentityConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto)13 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)11 Test (org.junit.Test)11 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)10 DefaultSynchronizationServiceTest (eu.bcvsolutions.idm.acc.service.impl.DefaultSynchronizationServiceTest)9 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)9 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)8 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)8 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)6 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)5 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)4 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)4 SysSystemAttributeMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter)4 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)3 SysSystemMappingFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter)3 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)3 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)2 IdmAutomaticRoleAttributeDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto)2 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)1 EntityAccountDto (eu.bcvsolutions.idm.acc.dto.EntityAccountDto)1