Search in sources :

Example 51 with IdmRoleFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.

the class DefaultRoleSynchronizationServiceTest method provisioningF_DeleteAccount.

@Test
public void provisioningF_DeleteAccount() {
    // 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);
    TestRoleResource ten = entityManager.find(TestRoleResource.class, ROLE_NAME_TEN);
    Assert.assertNotNull(ten);
    // Delete IDM role (must invoke provisioning)
    roleService.delete(roleTen);
    ten = entityManager.find(TestRoleResource.class, ROLE_NAME_TEN);
    Assert.assertNull(ten);
    // Delete role mapping
    systemMappingService.delete(mapping);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) TestRoleResource(eu.bcvsolutions.idm.acc.entity.TestRoleResource) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 52 with IdmRoleFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.

the class DefaultRoleSynchronizationServiceTest method doStartSyncC_filterByToken.

@Test
public void doStartSyncC_filterByToken() {
    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));
    IdmRoleFilter roleFilter = new IdmRoleFilter();
    roleFilter.setProperty(IdmRole_.code.getName());
    roleFilter.setValue("3");
    IdmRoleDto roleThree = roleService.find(roleFilter, null).getContent().get(0);
    Assert.assertNotNull(roleThree);
    IdmFormValueDto changedRole = (IdmFormValueDto) formService.getValues(roleThree.getId(), IdmRole.class, "changed").get(0);
    Assert.assertNotNull(changedRole);
    // Set sync config
    syncConfigCustom.setReconciliation(false);
    syncConfigCustom.setCustomFilter(true);
    syncConfigCustom.setFilterOperation(IcFilterOperationType.GREATER_THAN);
    syncConfigCustom.setFilterAttribute(syncConfigCustom.getTokenAttribute());
    syncConfigCustom.setToken((String) changedRole.getValue());
    syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
    syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
    syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
    syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
    syncConfigService.save(syncConfigCustom);
    // 
    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 createEntityActionLog = actions.stream().filter(action -> {
        return SynchronizationActionType.UPDATE_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());
    SysSyncItemLogDto item = items.stream().filter(logitem -> {
        return "4".equals(logitem.getIdentification());
    }).findFirst().orElse(null);
    Assert.assertNotNull("Log for role 4 must exist!", item);
    item = items.stream().filter(logitem -> {
        return "5".equals(logitem.getIdentification());
    }).findFirst().orElse(null);
    Assert.assertNotNull("Log for role 5 must exist!", item);
    // Delete log
    syncLogService.delete(log);
}
Also used : MethodSorters(org.junit.runners.MethodSorters) RoleType(eu.bcvsolutions.idm.core.api.domain.RoleType) SysSchemaAttributeDto(eu.bcvsolutions.idm.acc.dto.SysSchemaAttributeDto) ZonedDateTime(java.time.ZonedDateTime) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) Autowired(org.springframework.beans.factory.annotation.Autowired) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) After(org.junit.After) SynchronizationMissingEntityActionType(eu.bcvsolutions.idm.acc.domain.SynchronizationMissingEntityActionType) SysSyncConfigService(eu.bcvsolutions.idm.acc.service.api.SysSyncConfigService) ZoneOffset(java.time.ZoneOffset) SynchronizationUnlinkedActionType(eu.bcvsolutions.idm.acc.domain.SynchronizationUnlinkedActionType) SysSyncLogService(eu.bcvsolutions.idm.acc.service.api.SysSyncLogService) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSchemaAttributeFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSchemaAttributeFilter) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) Page(org.springframework.data.domain.Page) ReconciliationMissingAccountActionType(eu.bcvsolutions.idm.acc.domain.ReconciliationMissingAccountActionType) List(java.util.List) Query(javax.persistence.Query) SysSchemaObjectClassService(eu.bcvsolutions.idm.acc.service.api.SysSchemaObjectClassService) FixMethodOrder(org.junit.FixMethodOrder) IdmRole(eu.bcvsolutions.idm.core.model.entity.IdmRole) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) ImmutableList(com.google.common.collect.ImmutableList) SynchronizationActionType(eu.bcvsolutions.idm.acc.domain.SynchronizationActionType) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) SynchronizationLinkedActionType(eu.bcvsolutions.idm.acc.domain.SynchronizationLinkedActionType) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Before(org.junit.Before) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) IdmRole_(eu.bcvsolutions.idm.core.model.entity.IdmRole_) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) Test(org.junit.Test) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) EntityManager(javax.persistence.EntityManager) ApplicationContext(org.springframework.context.ApplicationContext) SysSyncItemLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncItemLogFilter) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) SysSystemAttributeMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemAttributeMappingFilter) SysSyncRoleConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncRoleConfigDto) SysSyncActionLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncActionLogFilter) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) DateTimeFormatter(java.time.format.DateTimeFormatter) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) TestRoleResource(eu.bcvsolutions.idm.acc.entity.TestRoleResource) IcFilterOperationType(eu.bcvsolutions.idm.ic.domain.IcFilterOperationType) SysSyncLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter) SysSyncItemLogService(eu.bcvsolutions.idm.acc.service.api.SysSyncItemLogService) TestHelper(eu.bcvsolutions.idm.acc.TestHelper) Assert(org.junit.Assert) SysSyncActionLogService(eu.bcvsolutions.idm.acc.service.api.SysSyncActionLogService) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) SysSyncLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SysSyncItemLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncItemLogFilter) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) SysSyncActionLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncActionLogFilter) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 53 with IdmRoleFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.

the class IdmRoleControllerRestTest method testFindByEnvironment.

@Test
public void testFindByEnvironment() {
    IdmRoleDto roleOne = prepareDto();
    roleOne.setCode(null);
    roleOne.setBaseCode(getHelper().createName());
    roleOne.setEnvironment(getHelper().createName());
    IdmRoleDto roleOneCreated = createDto(roleOne);
    IdmRoleDto roleTwo = prepareDto();
    roleTwo.setCode(null);
    roleTwo.setBaseCode(getHelper().createName());
    roleTwo.setEnvironment(getHelper().createName());
    roleTwo = createDto(roleTwo);
    // 
    IdmRoleFilter filter = new IdmRoleFilter();
    filter.setEnvironment(roleOne.getEnvironment());
    List<IdmRoleDto> roles = find(filter);
    Assert.assertEquals(1, roles.size());
    Assert.assertTrue(roles.stream().anyMatch(r -> r.getId().equals(roleOneCreated.getId())));
}
Also used : IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) MockMvcResultMatchers.content(org.springframework.test.web.servlet.result.MockMvcResultMatchers.content) Collectors(java.util.stream.Collectors) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) List(java.util.List) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) SecurityMockMvcRequestPostProcessors.authentication(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) RoleBasePermission(eu.bcvsolutions.idm.core.security.api.domain.RoleBasePermission) ResolvedIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.ResolvedIncompatibleRoleDto) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) MockMvcRequestBuilders.get(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) Assert(org.junit.Assert) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) RoleCanBeRequestedEvaluator(eu.bcvsolutions.idm.core.security.evaluator.role.RoleCanBeRequestedEvaluator) IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) IdmRole(eu.bcvsolutions.idm.core.model.entity.IdmRole) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) Test(org.junit.Test) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)

Example 54 with IdmRoleFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter in project CzechIdMng by bcvsolutions.

the class IdmRoleControllerRestTest method testFindByRoleComposition.

@Test
public void testFindByRoleComposition() {
    IdmRoleDto roleRoot = createDto();
    IdmRoleDto roleOne = createDto();
    IdmRoleDto roleOneSub = createDto();
    IdmRoleDto roleTwo = createDto();
    getHelper().createRoleComposition(roleRoot, roleOne);
    getHelper().createRoleComposition(roleRoot, roleTwo);
    getHelper().createRoleComposition(roleOne, roleOneSub);
    // 
    Assert.assertEquals(2, getDto(roleRoot.getId()).getChildrenCount());
    // 
    IdmRoleFilter filter = new IdmRoleFilter();
    filter.setParent(roleRoot.getId());
    List<IdmRoleDto> 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())));
    // 
    filter.setParent(roleOne.getId());
    roles = find(filter);
    Assert.assertEquals(1, roles.size());
    Assert.assertTrue(roles.stream().anyMatch(r -> r.getId().equals(roleOneSub.getId())));
    // 
    filter.setParent(roleTwo.getId());
    roles = find(filter);
    Assert.assertTrue(roles.isEmpty());
}
Also used : IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) MockMvcResultMatchers.content(org.springframework.test.web.servlet.result.MockMvcResultMatchers.content) Collectors(java.util.stream.Collectors) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) List(java.util.List) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) SecurityMockMvcRequestPostProcessors.authentication(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) RoleBasePermission(eu.bcvsolutions.idm.core.security.api.domain.RoleBasePermission) ResolvedIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.ResolvedIncompatibleRoleDto) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) MockMvcRequestBuilders.get(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) Assert(org.junit.Assert) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) RoleCanBeRequestedEvaluator(eu.bcvsolutions.idm.core.security.evaluator.role.RoleCanBeRequestedEvaluator) IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) IdmRole(eu.bcvsolutions.idm.core.model.entity.IdmRole) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) Test(org.junit.Test) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)

Aggregations

IdmRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter)54 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)46 Test (org.junit.Test)41 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)22 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)17 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)17 IdmRoleCatalogueDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto)16 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)14 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)14 IdmRole (eu.bcvsolutions.idm.core.model.entity.IdmRole)10 IdmFormValueDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto)9 List (java.util.List)9 Assert (org.junit.Assert)9 Autowired (org.springframework.beans.factory.annotation.Autowired)9 SysSyncRoleConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncRoleConfigDto)8 UUID (java.util.UUID)8 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)7 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)7 CoreGroupPermission (eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission)7 TestHelper (eu.bcvsolutions.idm.test.api.TestHelper)7