Search in sources :

Example 66 with IdmRoleDto

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

the class DefaultIdmRoleGuaranteeServiceIntegrationTest method testFindRoleGuaranteeByRole.

@Test
public void testFindRoleGuaranteeByRole() {
    IdmIdentityDto guarantee1 = testHelper.createIdentity();
    IdmIdentityDto guarantee2 = testHelper.createIdentity();
    IdmIdentityDto guarantee3 = testHelper.createIdentity();
    // 
    IdmRoleDto role = testHelper.createRole();
    // 
    IdmRoleGuaranteeDto roleGuarantee = new IdmRoleGuaranteeDto();
    roleGuarantee.setRole(role.getId());
    roleGuarantee.setGuarantee(guarantee1.getId());
    roleGuaranteeService.save(roleGuarantee);
    // 
    roleGuarantee = new IdmRoleGuaranteeDto();
    roleGuarantee.setRole(role.getId());
    roleGuarantee.setGuarantee(guarantee2.getId());
    roleGuaranteeService.save(roleGuarantee);
    // 
    roleGuarantee = new IdmRoleGuaranteeDto();
    roleGuarantee.setRole(role.getId());
    roleGuarantee.setGuarantee(guarantee3.getId());
    roleGuaranteeService.save(roleGuarantee);
    // 
    IdmRoleGuaranteeFilter filter = new IdmRoleGuaranteeFilter();
    filter.setRole(role.getId());
    List<IdmRoleGuaranteeDto> list = roleGuaranteeService.find(filter, null).getContent();
    assertEquals(3, list.size());
    // 
    List<UUID> guarantees = list.stream().map(IdmRoleGuaranteeDto::getGuarantee).collect(Collectors.toList());
    roleGuarantee = list.get(0);
    assertEquals(role.getId(), roleGuarantee.getRole());
    assertTrue(guarantees.contains(guarantee3.getId()));
    assertTrue(guarantees.contains(guarantee2.getId()));
    assertTrue(guarantees.contains(guarantee1.getId()));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto) IdmRoleGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 67 with IdmRoleDto

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

the class DefaultIdmRoleGuaranteeServiceIntegrationTest method testFindRoleGuaranteeByGuarantee.

@Test
public void testFindRoleGuaranteeByGuarantee() {
    IdmIdentityDto guarantee = testHelper.createIdentity();
    // 
    IdmRoleDto role1 = testHelper.createRole();
    IdmRoleDto role2 = testHelper.createRole();
    IdmRoleDto role3 = testHelper.createRole();
    // 
    IdmRoleGuaranteeDto roleGuarantee = new IdmRoleGuaranteeDto();
    roleGuarantee.setRole(role1.getId());
    roleGuarantee.setGuarantee(guarantee.getId());
    roleGuaranteeService.save(roleGuarantee);
    // 
    roleGuarantee = new IdmRoleGuaranteeDto();
    roleGuarantee.setRole(role2.getId());
    roleGuarantee.setGuarantee(guarantee.getId());
    roleGuaranteeService.save(roleGuarantee);
    // 
    roleGuarantee = new IdmRoleGuaranteeDto();
    roleGuarantee.setRole(role3.getId());
    roleGuarantee.setGuarantee(guarantee.getId());
    roleGuaranteeService.save(roleGuarantee);
    // 
    IdmRoleGuaranteeFilter filter = new IdmRoleGuaranteeFilter();
    filter.setGuarantee(guarantee.getId());
    List<IdmRoleGuaranteeDto> list = roleGuaranteeService.find(filter, null).getContent();
    assertEquals(3, list.size());
    // 
    List<UUID> roles = list.stream().map(IdmRoleGuaranteeDto::getRole).collect(Collectors.toList());
    roleGuarantee = list.get(0);
    assertEquals(guarantee.getId(), roleGuarantee.getGuarantee());
    assertTrue(roles.contains(role1.getId()));
    assertTrue(roles.contains(role2.getId()));
    assertTrue(roles.contains(role3.getId()));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto) IdmRoleGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 68 with IdmRoleDto

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

the class DefaultIdmRoleServiceIntegrationTest method catalogueFilterTest.

@Test
public void catalogueFilterTest() {
    IdmRoleDto role = new IdmRoleDto();
    role.setName("PetrSadloRole");
    role = roleService.save(role);
    IdmRoleCatalogueDto catalogue = helper.createRoleCatalogue();
    IdmRoleCatalogueRoleDto catalogueRole = new IdmRoleCatalogueRoleDto();
    catalogueRole.setRole(role.getId());
    catalogueRole.setRoleCatalogue(catalogue.getId());
    catalogueRole = idmRoleCatalogueRoleService.save(catalogueRole);
    IdmRoleFilter filter = new IdmRoleFilter();
    filter.setRoleCatalogueId(catalogue.getId());
    Page<IdmRoleDto> result = roleService.find(filter, null);
    assertEquals("Wrong catalogue", 1, result.getTotalElements());
    assertTrue("Wrong catalogue id #1", result.getContent().contains(role));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleCatalogueRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) IdmRoleCatalogueDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCatalogueDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 69 with IdmRoleDto

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

the class DefaultIdmRoleServiceIntegrationTest method testReferentialIntegrity.

@Test
public void testReferentialIntegrity() {
    IdmIdentityDto identity = new IdmIdentityDto();
    String username = "delete_test_" + System.currentTimeMillis();
    identity.setUsername(username);
    // confidential storage
    identity.setPassword(new GuardedString("heslo"));
    identity.setFirstName("Test");
    identity.setLastName("Identity");
    identity = identityService.save(identity);
    // role
    IdmRoleDto role = new IdmRoleDto();
    String roleName = "test_r_" + System.currentTimeMillis();
    role.setName(roleName);
    IdmRoleGuaranteeDto roleGuarantee = new IdmRoleGuaranteeDto();
    roleGuarantee.setRole(role.getId());
    roleGuarantee.setGuarantee(identity.getId());
    role.setGuarantees(Lists.newArrayList(roleGuarantee));
    role = roleService.save(role);
    assertNotNull(roleService.getByCode(roleName));
    assertEquals(1, roleGuaranteeRepository.findAllByRole_Id(role.getId()).size());
    roleService.delete(role);
    assertNull(roleService.getByCode(roleName));
    assertEquals(0, roleGuaranteeRepository.findAllByRole_Id(role.getId()).size());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 70 with IdmRoleDto

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

the class DefaultIdmRoleServiceIntegrationTest method typeFilterTest.

@Test
public void typeFilterTest() {
    IdmRoleDto role = helper.createRole();
    IdmRoleDto role2 = helper.createRole();
    IdmRoleDto role3 = helper.createRole();
    RoleType type = RoleType.LOGIN;
    RoleType type2 = RoleType.BUSINESS;
    role = roleService.get(role.getId());
    role.setRoleType(type);
    role = roleService.save(role);
    role2 = roleService.get(role2.getId());
    role2.setRoleType(type);
    role2 = roleService.save(role2);
    role3 = roleService.get(role3.getId());
    role3.setRoleType(type2);
    role3 = roleService.save(role3);
    IdmRoleFilter filter = new IdmRoleFilter();
    filter.setRoleType(type);
    Page<IdmRoleDto> result = roleService.find(filter, null);
    assertEquals("Wrong type #1", 2, result.getTotalElements());
    assertTrue("Wrong type #1 contains", result.getContent().contains(role));
    filter.setRoleType(type2);
    result = roleService.find(filter, null);
    assertEquals("Wrong type #2", 1, result.getTotalElements());
    assertTrue("Wrong type #2 contains", result.getContent().contains(role3));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) RoleType(eu.bcvsolutions.idm.core.api.domain.RoleType) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)288 Test (org.junit.Test)227 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)209 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)159 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)99 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)74 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)59 AbstractCoreWorkflowIntegrationTest (eu.bcvsolutions.idm.core.AbstractCoreWorkflowIntegrationTest)51 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)50 ArrayList (java.util.ArrayList)50 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)45 IdmAutomaticRoleAttributeDto (eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto)44 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)44 List (java.util.List)40 WorkflowFilterDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowFilterDto)37 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)36 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)35 UUID (java.util.UUID)35 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)32 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)32