Search in sources :

Example 86 with IdmRoleDto

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

the class RoleTransitiveEvaluatorsIntegrationTest method testCreateAutomaticRole.

@Test(expected = ForbiddenEntityException.class)
public void testCreateAutomaticRole() {
    IdmIdentityDto identity = createIdentityWithRole(true);
    // 
    try {
        loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
        // 
        IdmRoleDto role = roleService.get(TEST_ROLE_ID, IdmBasePermission.READ);
        IdmRoleTreeNodeDto roleTreeNode = new IdmRoleTreeNodeDto();
        roleTreeNode.setRole(role.getId());
        roleTreeNode.setTreeNode(helper.createTreeNode().getId());
        roleTreeNodeService.save(roleTreeNode, IdmBasePermission.UPDATE);
    } finally {
        logout();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 87 with IdmRoleDto

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

the class RoleTransitiveEvaluatorsIntegrationTest method testReadRoleWithoutTransitiveEvaluators.

@Test
public void testReadRoleWithoutTransitiveEvaluators() {
    IdmIdentityDto identity = createIdentityWithRole(false);
    // 
    try {
        loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
        // 
        IdmRoleDto readRole = roleService.get(TEST_ROLE_ID, IdmBasePermission.READ);
        assertEquals(TEST_ROLE_ID, readRole.getId());
        assertEquals(1, roleService.find(null, IdmBasePermission.READ).getTotalElements());
        assertEquals(0, roleTreeNodeService.find(null, IdmBasePermission.READ).getTotalElements());
        assertEquals(0, authorizationPolicyService.find(null, IdmBasePermission.READ).getTotalElements());
    } finally {
        logout();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 88 with IdmRoleDto

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

the class RoleTransitiveEvaluatorsIntegrationTest method testDisabledEvaluator.

@Test
public void testDisabledEvaluator() {
    IdmIdentityDto identity = createIdentityWithRole(true);
    IdmRoleDto role = null;
    // before disbale
    try {
        loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
        // 
        role = roleService.get(TEST_ROLE_ID, IdmBasePermission.READ);
        assertEquals(TEST_ROLE_ID, role.getId());
        assertEquals(1, roleService.find(null, IdmBasePermission.READ).getTotalElements());
        assertEquals(1, roleTreeNodeService.find(null, IdmBasePermission.READ).getTotalElements());
        assertEquals(3, authorizationPolicyService.find(null, IdmBasePermission.READ).getTotalElements());
    } finally {
        logout();
    }
    // 
    // disable policy
    loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
    // TODO: disable configurable api
    CodeableEvaluator evaluator = new CodeableEvaluator();
    configurationService.setBooleanValue(evaluator.getConfigurationPropertyName(ConfigurationService.PROPERTY_ENABLED), false);
    logout();
    // after disable
    try {
        loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
        // 
        assertEquals(0, roleService.find(null, IdmBasePermission.READ).getTotalElements());
        assertEquals(0, roleTreeNodeService.find(null, IdmBasePermission.READ).getTotalElements());
        assertEquals(0, authorizationPolicyService.find(null, IdmBasePermission.READ).getTotalElements());
    } finally {
        logout();
        // enable policy
        loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
        // TODO: disable configurable api
        configurationService.setBooleanValue(evaluator.getConfigurationPropertyName(ConfigurationService.PROPERTY_ENABLED), true);
        logout();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) CodeableEvaluator(eu.bcvsolutions.idm.core.security.evaluator.CodeableEvaluator) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 89 with IdmRoleDto

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

the class SelfRoleRequestEvaluatorIntegrationTest method testCanReadSelfRoleRequest.

@Test
public void testCanReadSelfRoleRequest() {
    IdmRoleDto role = roleService.getByCode(InitDemoData.DEFAULT_ROLE_NAME);
    // prepare identity
    IdmIdentityDto identity = helper.createIdentity();
    // assign role request
    IdmRoleRequestDto roleRequest = helper.assignRoles(helper.getPrimeContract(identity.getId()), role);
    // 
    try {
        loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
        // 
        IdmRoleRequestDto read = roleRequestService.get(roleRequest.getId(), IdmBasePermission.READ);
        assertEquals(roleRequest, read);
        // 
        IdmConceptRoleRequestFilter filter = new IdmConceptRoleRequestFilter();
        filter.setRoleRequestId(roleRequest.getId());
        Page<IdmConceptRoleRequestDto> concepts = conceptRoleRequestController.find(filter, null, IdmBasePermission.READ);
        assertEquals(1, concepts.getTotalElements());
    } finally {
        logout();
    }
}
Also used : IdmConceptRoleRequestFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmConceptRoleRequestFilter) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmConceptRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 90 with IdmRoleDto

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

the class SelfRoleRequestEvaluatorIntegrationTest method testCannotReadForeignRoleRequest.

@Test(expected = ForbiddenEntityException.class)
public void testCannotReadForeignRoleRequest() {
    IdmRoleDto role = roleService.getByCode(InitDemoData.DEFAULT_ROLE_NAME);
    // prepare identities
    IdmIdentityDto identity = helper.createIdentity();
    IdmIdentityDto identityTwo = helper.createIdentity();
    // assign role request
    IdmRoleRequestDto roleRequest = helper.assignRoles(helper.getPrimeContract(identity.getId()), role);
    // 
    try {
        loginService.login(new LoginDto(identityTwo.getUsername(), identityTwo.getPassword()));
        // 
        roleRequestService.get(roleRequest.getId(), IdmBasePermission.READ);
    } finally {
        logout();
    }
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LoginDto(eu.bcvsolutions.idm.core.security.api.dto.LoginDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

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