Search in sources :

Example 31 with IdmRoleFilter

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

the class DefaultRoleSynchronizationServiceTest method provisioningB_CreateAccounts.

@Test
public void provisioningB_CreateAccounts() {
    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.assertNull(ten);
    // Create mapping for provisioning
    SysSystemMappingDto mapping = this.createProvisionigMapping();
    // Save IDM role (must invoke provisioning)
    roleService.save(roleTen);
    // Check state before provisioning
    ten = entityManager.find(TestRoleResource.class, ROLE_NAME_TEN);
    Assert.assertNotNull(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 32 with IdmRoleFilter

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

the class IdmRoleControllerRestTest method testFindByBaseCode.

@Test
public void testFindByBaseCode() {
    IdmRoleDto roleOne = prepareDto();
    roleOne.setCode(null);
    roleOne.setBaseCode(getHelper().createName());
    IdmRoleDto roleOneCreated = createDto(roleOne);
    IdmRoleDto roleTwo = prepareDto();
    roleTwo.setCode(null);
    roleTwo.setBaseCode(getHelper().createName());
    roleTwo = createDto(roleTwo);
    // 
    IdmRoleFilter filter = new IdmRoleFilter();
    filter.setBaseCode(roleOne.getBaseCode());
    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 33 with IdmRoleFilter

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

the class RoleSynchronizationExecutor method findByAttribute.

@Override
protected IdmRoleDto findByAttribute(String idmAttributeName, String value) {
    CorrelationFilter filter = getEntityFilter();
    filter.setProperty(idmAttributeName);
    filter.setValue(value);
    List<IdmRoleDto> entities = roleService.find((IdmRoleFilter) filter, null).getContent();
    if (CollectionUtils.isEmpty(entities)) {
        return null;
    }
    if (entities.size() > 1) {
        throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_CORRELATION_TO_MANY_RESULTS, ImmutableMap.of("correlationAttribute", idmAttributeName, "value", value));
    }
    if (entities.size() == 1) {
        return entities.get(0);
    }
    return null;
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CorrelationFilter(eu.bcvsolutions.idm.core.api.dto.filter.CorrelationFilter) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException)

Example 34 with IdmRoleFilter

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

the class DefaultAuthorizationManagerIntegrationTest method testPredicate.

@Test
public void testPredicate() {
    loginAsAdmin();
    // prepare role
    IdmRoleDto role = getHelper().createRole();
    getHelper().createUuidPolicy(role.getId(), role.getId(), IdmBasePermission.READ);
    getHelper().createBasePolicy(role.getId(), IdmBasePermission.AUTOCOMPLETE);
    // prepare identity
    IdmIdentityDto identity = getHelper().createIdentity();
    identity.setPassword(new GuardedString("heslo"));
    identityService.save(identity);
    // assign role
    getHelper().createIdentityRole(identity, role);
    logout();
    // 
    // empty without login
    IdmRoleFilter filter = new IdmRoleFilter();
    assertEquals(0, roleService.find(filter, null, IdmBasePermission.READ).getTotalElements());
    assertEquals(0, roleService.find(filter, null, IdmBasePermission.AUTOCOMPLETE).getTotalElements());
    // 
    try {
        getHelper().login(identity);
        // 
        // evaluate	access
        assertEquals(1, roleService.find(filter, null, IdmBasePermission.READ).getTotalElements());
        assertEquals(roleService.find(null).getTotalElements(), roleService.find(filter, null, IdmBasePermission.AUTOCOMPLETE).getTotalElements());
    } finally {
        logout();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Test(org.junit.Test) AbstractEvaluatorIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractEvaluatorIntegrationTest)

Example 35 with IdmRoleFilter

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

the class RoleForRequestEvaluatorIntegrationTest method getRoleAsUser.

private Page<IdmRoleDto> getRoleAsUser(IdmIdentityDto user, IdmRoleDto role) {
    try {
        loginService.login(new LoginDto(user.getUsername(), new GuardedString(TEST_PWD)));
        // 
        IdmRoleFilter rf = getRoleFilter("code", role.getCode());
        Page<IdmRoleDto> readRole = roleService.find(rf, null, IdmBasePermission.READ);
        return readRole;
    } finally {
        logout();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto)

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