Search in sources :

Example 46 with IdmRoleFilter

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

the class RoleDeleteBulkActionIntegrationTest method processBulkActionByFilterWithRemove.

@Test
public void processBulkActionByFilterWithRemove() {
    String testDescription = "bulkActionName" + System.currentTimeMillis();
    List<IdmRoleDto> roles = this.createRoles(5);
    IdmRoleDto removedRole = roles.get(0);
    IdmRoleDto removedRole2 = roles.get(1);
    for (IdmRoleDto role : roles) {
        role.setDescription(testDescription);
        role = roleService.save(role);
    }
    IdmRoleFilter filter = new IdmRoleFilter();
    filter.setValue(testDescription);
    filter.setProperty(IdmRole_.description.getName());
    IdmBulkActionDto bulkAction = this.findBulkAction(IdmRole.class, RoleDeleteBulkAction.NAME);
    bulkAction.setTransformedFilter(filter);
    bulkAction.setFilter(toMap(filter));
    bulkAction.setRemoveIdentifiers(Sets.newHashSet(removedRole.getId(), removedRole2.getId()));
    IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
    checkResultLrt(processAction, 3l, null, null);
    Set<UUID> ids = getIdFromList(roles);
    for (UUID id : ids) {
        IdmRoleDto dto = roleService.get(id);
        if (id.equals(removedRole.getId()) || id.equals(removedRole2.getId())) {
            assertNotNull(dto);
            continue;
        }
        assertNull(dto);
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) UUID(java.util.UUID) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Example 47 with IdmRoleFilter

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

the class DefaultIdmRoleServiceIntegrationTest method testCorrelableFilter.

/**
 * Test find role by all string fields
 */
@Test
public void testCorrelableFilter() {
    IdmRoleDto role = getHelper().createRole();
    role.setExternalId(getHelper().createName());
    role.setCode(getHelper().createName());
    role.setDescription(getHelper().createName());
    IdmRoleDto roleFull = roleService.save(role);
    ArrayList<Field> fields = Lists.newArrayList(IdmRole_.class.getFields());
    IdmRoleFilter filter = new IdmRoleFilter();
    fields.forEach(field -> {
        if (Modifier.isStatic(field.getModifiers())) {
        // static filter properties cannot be used by simple correlable filter
        } else {
            filter.setProperty(field.getName());
            try {
                Object value = EntityUtils.getEntityValue(roleFull, field.getName());
                if (value == null || !(value instanceof String)) {
                    return;
                }
                filter.setValue(value.toString());
                List<IdmRoleDto> identities = roleService.find(filter, null).getContent();
                Assert.assertTrue(identities.contains(roleFull));
            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | IntrospectionException e) {
                e.printStackTrace();
            }
        }
    });
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IntrospectionException(java.beans.IntrospectionException) IdmRole_(eu.bcvsolutions.idm.core.model.entity.IdmRole_) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) InvocationTargetException(java.lang.reflect.InvocationTargetException) Field(java.lang.reflect.Field) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) AbstractRestTest(eu.bcvsolutions.idm.test.api.AbstractRestTest) Test(org.junit.Test)

Example 48 with IdmRoleFilter

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

the class DefaultIdmRoleServiceIntegrationTest method guaranteeRoleFilterTest.

@Test
public void guaranteeRoleFilterTest() {
    IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto identityOther = getHelper().createIdentity((GuardedString) null);
    IdmRoleDto role = getHelper().createRole();
    IdmRoleDto guaranteeRole = getHelper().createRole();
    IdmRoleGuaranteeRoleDto roleGuaranteeRole = new IdmRoleGuaranteeRoleDto();
    roleGuaranteeRole.setRole(role.getId());
    roleGuaranteeRole.setGuaranteeRole(guaranteeRole.getId());
    roleGuaranteeRoleService.save(roleGuaranteeRole);
    getHelper().createIdentityRole(identity, guaranteeRole);
    // 
    IdmRoleFilter filter = new IdmRoleFilter();
    filter.setGuaranteeId(identity.getId());
    Page<IdmRoleDto> result = roleService.find(filter, null);
    Assert.assertEquals("Wrong guarantee", 1, result.getTotalElements());
    Assert.assertEquals("Wrong guarantee id", role.getId(), result.getContent().get(0).getId());
    // 
    filter.setGuaranteeId(identityOther.getId());
    result = roleService.find(filter, null);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) IdmRoleGuaranteeRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeRoleDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractRestTest(eu.bcvsolutions.idm.test.api.AbstractRestTest) Test(org.junit.Test)

Example 49 with IdmRoleFilter

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

the class DefaultRoleSynchronizationServiceTest 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));
    // 
    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.CREATE_ENTITY == action.getSyncAction();
    }).findFirst().get();
    SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
    itemLogFilter.setSyncActionLogId(createEntityActionLog.getId());
    List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
    Assert.assertEquals(5, items.size());
    IdmRoleFilter roleFilter = new IdmRoleFilter();
    roleFilter.setProperty(IdmRole_.code.getName());
    roleFilter.setValue("1");
    Assert.assertEquals(1, roleService.find(roleFilter, null).getTotalElements());
    roleFilter.setValue("2");
    Assert.assertEquals(1, roleService.find(roleFilter, null).getTotalElements());
    roleFilter.setValue("3");
    Assert.assertEquals(1, roleService.find(roleFilter, null).getTotalElements());
    roleFilter.setValue("4");
    Assert.assertEquals(1, roleService.find(roleFilter, null).getTotalElements());
    roleFilter.setValue("5");
    Assert.assertEquals(1, roleService.find(roleFilter, null).getTotalElements());
    // Delete log
    syncLogService.delete(log);
}
Also used : 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) 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 50 with IdmRoleFilter

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

the class DefaultRoleSynchronizationServiceTest method provisioningD_UpdateAccount.

@Test
public void provisioningD_UpdateAccount() {
    // 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);
    // Check state before provisioning
    TestRoleResource ten = entityManager.find(TestRoleResource.class, ROLE_NAME_TEN);
    Assert.assertNotNull(ten);
    Assert.assertEquals(2, ten.getPriority());
    roleTen.setPriority(10);
    // 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(10, ten.getPriority());
    // 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)

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