Search in sources :

Example 61 with SysSystemDto

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

the class IdentityContractSyncTest method defaultWorkPositionTest.

@Test
public void defaultWorkPositionTest() {
    SysSystemDto system = initData();
    Assert.assertNotNull(system);
    AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
    Assert.assertTrue(config instanceof SysSyncContractConfigDto);
    helper.createIdentity(CONTRACT_OWNER_ONE);
    helper.createIdentity(CONTRACT_OWNER_TWO);
    helper.createIdentity(CONTRACT_LEADER_ONE);
    helper.createIdentity(CONTRACT_LEADER_TWO);
    // Set default tree type to sync configuration
    IdmTreeTypeDto treeType = treeTypeService.getByCode(InitApplicationData.DEFAULT_TREE_TYPE);
    Assert.assertNotNull(treeType);
    SysSyncContractConfigDto configContract = (SysSyncContractConfigDto) config;
    configContract.setDefaultTreeType(treeType.getId());
    // Set default tree node to sync configuration
    IdmTreeNodeFilter nodeFilter = new IdmTreeNodeFilter();
    nodeFilter.setCode("one");
    nodeFilter.setTreeTypeId(treeType.getId());
    List<IdmTreeNodeDto> nodes = treeNodeService.find(nodeFilter, null).getContent();
    Assert.assertEquals(1, nodes.size());
    IdmTreeNodeDto defaultNode = nodes.get(0);
    configContract.setDefaultTreeNode(defaultNode.getId());
    config = syncConfigService.save(configContract);
    IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
    contractFilter.setProperty(IdmIdentityContract_.position.getName());
    // Start sync
    synchornizationService.setSynchronizationConfigId(config.getId());
    synchornizationService.process();
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 3);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    // Default work positions must be set
    contractFilter.setValue("1");
    List<IdmIdentityContractDto> contractsOne = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsOne.size());
    Assert.assertEquals(defaultNode.getId(), contractsOne.get(0).getWorkPosition());
    contractFilter.setValue("2");
    List<IdmIdentityContractDto> contractsTwo = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsTwo.size());
    Assert.assertEquals(defaultNode.getId(), contractsTwo.get(0).getWorkPosition());
    contractFilter.setValue("3");
    List<IdmIdentityContractDto> contractsThree = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsThree.size());
    Assert.assertEquals(defaultNode.getId(), contractsThree.get(0).getWorkPosition());
    // Delete log
    syncLogService.delete(log);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) 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)

Example 62 with SysSystemDto

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

the class IdentitySyncTest method updateIdentityPropagateValidityTest.

@Test
public void updateIdentityPropagateValidityTest() {
    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);
    LocalDate validTill = LocalDate.now().plusDays(10);
    LocalDate validFrom = LocalDate.now().plusDays(-10);
    primeContract.setValidFrom(validFrom);
    primeContract.setValidTill(validTill);
    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.SUCCESS);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    List<IdmIdentityRoleDto> roles = identityRoleService.findAllByIdentity(identityOne.getId());
    Assert.assertEquals(1, roles.size());
    IdmIdentityRoleDto identityRole = roles.get(0);
    Assert.assertEquals(defaultRole.getId(), identityRole.getRole());
    Assert.assertEquals(identityRole.getValidFrom(), validFrom);
    Assert.assertEquals(identityRole.getValidTill(), validTill);
    AccIdentityAccountFilter identityAccountFilter = new AccIdentityAccountFilter();
    identityAccountFilter.setIdentityRoleId(identityRole.getId());
    Assert.assertEquals(1, identityAccountService.find(identityAccountFilter, null).getContent().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) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) LocalDate(org.joda.time.LocalDate) 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 63 with SysSystemDto

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

the class IdentitySyncTest method updateIdentityWithDefaultRoleTest.

@Test
public void updateIdentityWithDefaultRoleTest() {
    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);
    IdmIdentityFilter identityFilter = new IdmIdentityFilter();
    identityFilter.setUsername(IDENTITY_ONE);
    synchornizationService.setSynchronizationConfigId(config.getId());
    synchornizationService.process();
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.LINK, 1, OperationResultType.SUCCESS);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    List<IdmIdentityRoleDto> roles = identityRoleService.findAllByIdentity(identityOne.getId());
    Assert.assertEquals(1, roles.size());
    Assert.assertEquals(defaultRole.getId(), roles.get(0).getRole());
    // 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) 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 64 with SysSystemDto

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

the class IdentitySyncTest method createIdentityWithDefaultRoleTest.

@Test
public void createIdentityWithDefaultRoleTest() {
    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);
    IdmIdentityFilter identityFilter = new IdmIdentityFilter();
    identityFilter.setUsername(IDENTITY_ONE);
    List<IdmIdentityDto> identities = identityService.find(identityFilter, null).getContent();
    Assert.assertEquals(0, identities.size());
    synchornizationService.setSynchronizationConfigId(config.getId());
    synchornizationService.process();
    // Have to be in the warning state, because default role cannot be assigned for
    // new identity, because sync do not creates the default contract. See
    // IdmIdentityContractService.SKIP_CREATION_OF_DEFAULT_POSITION.
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 1, OperationResultType.WARNING);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    identities = identityService.find(identityFilter, null).getContent();
    Assert.assertEquals(1, identities.size());
    List<IdmIdentityRoleDto> roles = identityRoleService.findAllByIdentity(identities.get(0).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) 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 65 with SysSystemDto

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

the class IdentitySyncTest method testEnableAutomaticRoleDuringSynchronization.

@Test
public void testEnableAutomaticRoleDuringSynchronization() {
    // 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(true);
    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(1, identityRoles1.size());
    assertEquals(0, identityRoles2.size());
    assertEquals(0, identityRoles3.size());
    IdmIdentityRoleDto foundIdentityRole = identityRoles1.get(0);
    assertEquals(automaticRole.getId(), foundIdentityRole.getRoleTreeNode());
    // 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)

Aggregations

SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)256 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)167 Test (org.junit.Test)167 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)98 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)82 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)56 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)52 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)50 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)45 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)42 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)42 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)32 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)32 IcConnectorObject (eu.bcvsolutions.idm.ic.api.IcConnectorObject)30 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)29 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)29 SysProvisioningOperationFilter (eu.bcvsolutions.idm.acc.dto.filter.SysProvisioningOperationFilter)29 SysSchemaAttributeDto (eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto)28 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)27 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)27