Search in sources :

Example 6 with IdmIncompatibleRoleDto

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

the class IncompatibleRoleBySuperiorRoleEvaluatorIntegrationTest method canReadCompositionByRole.

@Test
public void canReadCompositionByRole() {
    IdmIdentityDto identity = getHelper().createIdentity();
    List<IdmIncompatibleRoleDto> results = null;
    IdmRoleDto role = getHelper().createRole();
    IdmRoleDto subRole = getHelper().createRole();
    IdmRoleDto superiorRole = getHelper().createRole();
    IdmIncompatibleRoleDto incompatibleRole = getHelper().createIncompatibleRole(role, subRole);
    // other - without access
    getHelper().createRoleComposition(superiorRole, role);
    getHelper().createIdentityRole(identity, role);
    getHelper().createUuidPolicy(role.getId(), role.getId(), IdmBasePermission.READ);
    // check created identity doesn't have compositions
    try {
        getHelper().login(identity.getUsername(), identity.getPassword());
        Assert.assertEquals(role.getId(), roleService.get(role.getId(), IdmBasePermission.READ).getId());
        results = service.find(null, IdmBasePermission.READ).getContent();
        Assert.assertTrue(results.isEmpty());
    } finally {
        logout();
    }
    // 
    // create authorization policy - assign to role
    getHelper().createAuthorizationPolicy(role.getId(), CoreGroupPermission.INCOMPATIBLEROLE, IdmIncompatibleRole.class, IncompatibleRoleBySuperiorRoleEvaluator.class);
    // 
    try {
        getHelper().login(identity);
        // 
        // evaluate	access
        getHelper().login(identity.getUsername(), identity.getPassword());
        results = service.find(null, IdmBasePermission.READ).getContent();
        Assert.assertEquals(1, results.size());
        Assert.assertEquals(incompatibleRole.getId(), results.get(0).getId());
        // 
        Set<String> permissions = service.getPermissions(incompatibleRole);
        Assert.assertEquals(1, permissions.size());
        Assert.assertEquals(IdmBasePermission.READ.name(), permissions.iterator().next());
    } finally {
        logout();
    }
    // 
    getHelper().createUuidPolicy(role.getId(), role.getId(), IdmBasePermission.UPDATE);
    // 
    try {
        getHelper().login(identity.getUsername(), identity.getPassword());
        // 
        Set<String> permissions = service.getPermissions(incompatibleRole);
        Assert.assertEquals(4, permissions.size());
        Assert.assertTrue(permissions.stream().anyMatch(p -> p.equals(IdmBasePermission.READ.name())));
        Assert.assertTrue(permissions.stream().anyMatch(p -> p.equals(IdmBasePermission.UPDATE.name())));
        Assert.assertTrue(permissions.stream().anyMatch(p -> p.equals(IdmBasePermission.CREATE.name())));
        Assert.assertTrue(permissions.stream().anyMatch(p -> p.equals(IdmBasePermission.DELETE.name())));
    } finally {
        logout();
    }
}
Also used : IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) IdmIncompatibleRole(eu.bcvsolutions.idm.core.model.entity.IdmIncompatibleRole) IdmIncompatibleRoleService(eu.bcvsolutions.idm.core.api.service.IdmIncompatibleRoleService) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) List(java.util.List) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AbstractEvaluatorIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractEvaluatorIntegrationTest) Assert(org.junit.Assert) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto) Transactional(org.springframework.transaction.annotation.Transactional) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto) Test(org.junit.Test) AbstractEvaluatorIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractEvaluatorIntegrationTest)

Example 7 with IdmIncompatibleRoleDto

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

the class IncompatibleRoleBySubRoleEvaluatorIntegrationTest method canReadCompositionByRole.

@Test
public void canReadCompositionByRole() {
    IdmIdentityDto identity = getHelper().createIdentity();
    List<IdmIncompatibleRoleDto> results = null;
    IdmRoleDto role = getHelper().createRole();
    IdmRoleDto subRole = getHelper().createRole();
    IdmRoleDto superiorRole = getHelper().createRole();
    // other - without access
    getHelper().createRoleComposition(role, subRole);
    IdmIncompatibleRoleDto incompatibleRole = getHelper().createIncompatibleRole(superiorRole, role);
    getHelper().createIdentityRole(identity, role);
    getHelper().createUuidPolicy(role.getId(), role.getId(), IdmBasePermission.READ);
    // check created identity doesn't have compositions
    try {
        getHelper().login(identity.getUsername(), identity.getPassword());
        Assert.assertEquals(role.getId(), roleService.get(role.getId(), IdmBasePermission.READ).getId());
        results = service.find(null, IdmBasePermission.READ).getContent();
        Assert.assertTrue(results.isEmpty());
    } finally {
        logout();
    }
    // 
    // create authorization policy - assign to role
    getHelper().createAuthorizationPolicy(role.getId(), CoreGroupPermission.INCOMPATIBLEROLE, IdmIncompatibleRole.class, IncompatibleRoleBySubRoleEvaluator.class);
    // 
    try {
        getHelper().login(identity.getUsername(), identity.getPassword());
        // 
        // evaluate	access
        getHelper().login(identity.getUsername(), identity.getPassword());
        results = service.find(null, IdmBasePermission.READ).getContent();
        Assert.assertEquals(1, results.size());
        Assert.assertEquals(incompatibleRole.getId(), results.get(0).getId());
    } finally {
        logout();
    }
    // 
    getHelper().createUuidPolicy(role.getId(), role.getId(), IdmBasePermission.UPDATE);
    // 
    try {
        getHelper().login(identity.getUsername(), identity.getPassword());
        // 
        Set<String> permissions = service.getPermissions(incompatibleRole);
        Assert.assertEquals(4, permissions.size());
        Assert.assertTrue(permissions.stream().anyMatch(p -> p.equals(IdmBasePermission.READ.name())));
        Assert.assertTrue(permissions.stream().anyMatch(p -> p.equals(IdmBasePermission.UPDATE.name())));
        Assert.assertTrue(permissions.stream().anyMatch(p -> p.equals(IdmBasePermission.CREATE.name())));
        Assert.assertTrue(permissions.stream().anyMatch(p -> p.equals(IdmBasePermission.DELETE.name())));
    } finally {
        logout();
    }
}
Also used : IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) IdmIncompatibleRole(eu.bcvsolutions.idm.core.model.entity.IdmIncompatibleRole) IdmIncompatibleRoleService(eu.bcvsolutions.idm.core.api.service.IdmIncompatibleRoleService) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) List(java.util.List) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AbstractEvaluatorIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractEvaluatorIntegrationTest) Assert(org.junit.Assert) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto) Transactional(org.springframework.transaction.annotation.Transactional) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto) Test(org.junit.Test) AbstractEvaluatorIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractEvaluatorIntegrationTest)

Example 8 with IdmIncompatibleRoleDto

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

the class IdmIdentityControllerRestTest method testGetIncompatibleRolesWithoutRemovedInConcept.

@Test
public void testGetIncompatibleRolesWithoutRemovedInConcept() throws Exception {
    IdmIdentityDto applicant = getHelper().createIdentity((GuardedString) null);
    IdmRoleDto roleOne = getHelper().createRole();
    IdmRoleDto roleTwo = getHelper().createRole();
    IdmRoleDto roleThree = getHelper().createRole();
    IdmRoleDto roleFour = getHelper().createRole();
    IdmRoleDto roleFive = getHelper().createRole();
    IdmRoleDto roleSix = getHelper().createRole();
    // assign roles
    getHelper().createIdentityRole(applicant, roleOne);
    getHelper().createIdentityRole(applicant, roleTwo);
    getHelper().createIdentityRole(applicant, roleThree);
    getHelper().createIdentityRole(applicant, roleFour);
    getHelper().createIdentityRole(applicant, roleFive);
    // create incompatible roles definition
    getHelper().createIncompatibleRole(roleOne, roleTwo);
    getHelper().createIncompatibleRole(roleThree, roleFour);
    getHelper().createIncompatibleRole(roleFive, roleSix);
    // 
    String response = getMockMvc().perform(get(String.format("%s/incompatible-roles", getDetailUrl(applicant.getId()))).with(authentication(getAdminAuthentication())).contentType(TestHelper.HAL_CONTENT_TYPE)).andExpect(status().isOk()).andExpect(content().contentType(TestHelper.HAL_CONTENT_TYPE)).andReturn().getResponse().getContentAsString();
    // 
    Set<IdmIncompatibleRoleDto> incompatibleRoles = toDtos(response, ResolvedIncompatibleRoleDto.class).stream().map(ResolvedIncompatibleRoleDto::getIncompatibleRole).collect(Collectors.toSet());
    Assert.assertEquals(2, incompatibleRoles.size());
    Assert.assertTrue(incompatibleRoles.stream().anyMatch(ir -> {
        return ir.getSuperior().equals(roleOne.getId()) && ir.getSub().equals(roleTwo.getId());
    }));
    Assert.assertTrue(incompatibleRoles.stream().anyMatch(ir -> {
        return ir.getSuperior().equals(roleThree.getId()) && ir.getSub().equals(roleFour.getId());
    }));
}
Also used : MockMvcResultMatchers.jsonPath(org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath) ZonedDateTime(java.time.ZonedDateTime) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) StringUtils(org.apache.commons.lang3.StringUtils) IdmPasswordDto(eu.bcvsolutions.idm.core.api.dto.IdmPasswordDto) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) SecurityMockMvcRequestPostProcessors.authentication(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.authentication) IdmIdentityFormValue(eu.bcvsolutions.idm.core.model.entity.eav.IdmIdentityFormValue) TypeReference(com.fasterxml.jackson.core.type.TypeReference) IdmProfileService(eu.bcvsolutions.idm.core.api.service.IdmProfileService) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) IdmIdentityContractService(eu.bcvsolutions.idm.core.api.service.IdmIdentityContractService) Set(java.util.Set) IdmFormProjectionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormProjectionDto) UUID(java.util.UUID) IdmFormAttributeFilter(eu.bcvsolutions.idm.core.eav.api.dto.filter.IdmFormAttributeFilter) Collectors(java.util.stream.Collectors) IdentityState(eu.bcvsolutions.idm.core.api.domain.IdentityState) MockMultipartFile(org.springframework.mock.web.MockMultipartFile) MockMvcRequestBuilders.patch(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) Matchers.equalTo(org.hamcrest.Matchers.equalTo) PanelDto(eu.bcvsolutions.idm.core.api.dto.PanelDto) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IdmAttachmentDto(eu.bcvsolutions.idm.core.ecm.api.dto.IdmAttachmentDto) MockMvcResultMatchers.content(org.springframework.test.web.servlet.result.MockMvcResultMatchers.content) FilterManager(eu.bcvsolutions.idm.core.api.repository.filter.FilterManager) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) IdmPasswordService(eu.bcvsolutions.idm.core.api.service.IdmPasswordService) IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) DataFilter(eu.bcvsolutions.idm.core.api.dto.filter.DataFilter) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) Lists(com.google.common.collect.Lists) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) LookupService(eu.bcvsolutions.idm.core.api.service.LookupService) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmFormProjectionService(eu.bcvsolutions.idm.core.eav.api.service.IdmFormProjectionService) TestHelper(eu.bcvsolutions.idm.test.api.TestHelper) IdmFormInstanceDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormInstanceDto) IdentityFormValueEvaluator(eu.bcvsolutions.idm.core.security.evaluator.eav.IdentityFormValueEvaluator) AttachmentManager(eu.bcvsolutions.idm.core.ecm.api.service.AttachmentManager) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmProfileDto(eu.bcvsolutions.idm.core.api.dto.IdmProfileDto) Matchers(org.hamcrest.Matchers) MultiValueMap(org.springframework.util.MultiValueMap) IOException(java.io.IOException) Test(org.junit.Test) MockMvcRequestBuilders(org.springframework.test.web.servlet.request.MockMvcRequestBuilders) ConfigurationMap(eu.bcvsolutions.idm.core.api.domain.ConfigurationMap) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) URLEncoder(java.net.URLEncoder) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) SelfIdentityEvaluator(eu.bcvsolutions.idm.core.security.evaluator.identity.SelfIdentityEvaluator) Ignore(org.junit.Ignore) PrivateIdentityConfiguration(eu.bcvsolutions.idm.core.api.config.domain.PrivateIdentityConfiguration) ResolvedIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.ResolvedIncompatibleRoleDto) IdentityDisableBulkAction(eu.bcvsolutions.idm.core.bulk.action.impl.IdentityDisableBulkAction) MockMvcRequestBuilders.get(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get) Assert(org.junit.Assert) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto) LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) InputStream(java.io.InputStream) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) ResolvedIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.ResolvedIncompatibleRoleDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) Test(org.junit.Test)

Example 9 with IdmIncompatibleRoleDto

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

the class IdmRoleControllerRestTest method testGetIncompatibleRoles.

@Test
public void testGetIncompatibleRoles() throws Exception {
    IdmRoleDto roleOne = getHelper().createRole();
    IdmRoleDto roleTwo = getHelper().createRole();
    IdmRoleDto roleThree = getHelper().createRole();
    IdmRoleDto roleFour = getHelper().createRole();
    IdmRoleDto roleFive = getHelper().createRole();
    IdmRoleDto roleSix = getHelper().createRole();
    // create incompatible roles definition
    getHelper().createIncompatibleRole(roleTwo, roleFive);
    getHelper().createIncompatibleRole(roleFive, roleSix);
    // 
    // create role composition
    getHelper().createRoleComposition(roleOne, roleTwo);
    getHelper().createRoleComposition(roleOne, roleThree);
    getHelper().createRoleComposition(roleTwo, roleFour);
    getHelper().createRoleComposition(roleThree, roleFive);
    // 
    String response = getMockMvc().perform(get(String.format("%s/incompatible-roles", getDetailUrl(roleOne.getId()))).with(authentication(getAdminAuthentication())).contentType(TestHelper.HAL_CONTENT_TYPE)).andExpect(status().isOk()).andExpect(content().contentType(TestHelper.HAL_CONTENT_TYPE)).andReturn().getResponse().getContentAsString();
    // 
    Set<IdmIncompatibleRoleDto> incompatibleRoles = toDtos(response, ResolvedIncompatibleRoleDto.class).stream().map(ResolvedIncompatibleRoleDto::getIncompatibleRole).collect(Collectors.toSet());
    Assert.assertEquals(1, incompatibleRoles.size());
    Assert.assertTrue(incompatibleRoles.stream().anyMatch(ir -> {
        return ir.getSuperior().equals(roleTwo.getId()) && ir.getSub().equals(roleFive.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) ResolvedIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.ResolvedIncompatibleRoleDto) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto) Test(org.junit.Test) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)

Example 10 with IdmIncompatibleRoleDto

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

the class IdmIncompatibleRoleControllerRestTest method testFindBySub.

@Test
public void testFindBySub() {
    IdmRoleDto roleOne = getHelper().createRole();
    IdmRoleDto roleTwo = getHelper().createRole();
    IdmRoleDto roleThree = getHelper().createRole();
    // 
    IdmIncompatibleRoleDto incompatibleRoleOne = getHelper().createIncompatibleRole(roleOne, roleTwo);
    IdmIncompatibleRoleDto incompatibleRoleTwo = getHelper().createIncompatibleRole(roleThree, roleOne);
    IdmIncompatibleRoleDto incompatibleRoleThree = getHelper().createIncompatibleRole(roleThree, roleTwo);
    // 
    IdmIncompatibleRoleFilter filter = new IdmIncompatibleRoleFilter();
    filter.setSubId(roleOne.getId());
    List<IdmIncompatibleRoleDto> incompatibleRoles = find(filter);
    Assert.assertEquals(1, incompatibleRoles.size());
    Assert.assertEquals(incompatibleRoleTwo.getId(), incompatibleRoles.get(0).getId());
    // 
    filter.setSubId(roleTwo.getId());
    incompatibleRoles = find(filter);
    Assert.assertEquals(2, incompatibleRoles.size());
    Assert.assertTrue(incompatibleRoles.stream().anyMatch(ir -> ir.getId().equals(incompatibleRoleOne.getId())));
    Assert.assertTrue(incompatibleRoles.stream().anyMatch(ir -> ir.getId().equals(incompatibleRoleThree.getId())));
    // 
    filter.setSubId(roleThree.getId());
    incompatibleRoles = find(filter);
    Assert.assertTrue(incompatibleRoles.isEmpty());
}
Also used : List(java.util.List) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AbstractReadWriteDtoController(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController) Autowired(org.springframework.beans.factory.annotation.Autowired) IdmIncompatibleRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIncompatibleRoleFilter) Test(org.junit.Test) Assert(org.junit.Assert) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIncompatibleRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIncompatibleRoleFilter) IdmIncompatibleRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto) Test(org.junit.Test) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)

Aggregations

IdmIncompatibleRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIncompatibleRoleDto)21 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)16 Test (org.junit.Test)15 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)11 List (java.util.List)11 Autowired (org.springframework.beans.factory.annotation.Autowired)11 ResolvedIncompatibleRoleDto (eu.bcvsolutions.idm.core.api.dto.ResolvedIncompatibleRoleDto)10 Assert (org.junit.Assert)10 Set (java.util.Set)9 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)7 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)7 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)7 Collectors (java.util.stream.Collectors)7 AbstractReadWriteDtoControllerRestTest (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)6 IdmRoleService (eu.bcvsolutions.idm.core.api.service.IdmRoleService)6 Lists (com.google.common.collect.Lists)5 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)5 AbstractReadWriteDtoController (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoController)5 Transactional (org.springframework.transaction.annotation.Transactional)5 ConceptRoleRequestOperation (eu.bcvsolutions.idm.core.api.domain.ConceptRoleRequestOperation)4