Search in sources :

Example 1 with CodeableEvaluator

use of eu.bcvsolutions.idm.core.security.evaluator.CodeableEvaluator 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();
    // 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();
        // 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) Test(org.junit.Test) AbstractEvaluatorIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractEvaluatorIntegrationTest)

Aggregations

IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)1 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)1 LoginDto (eu.bcvsolutions.idm.core.security.api.dto.LoginDto)1 CodeableEvaluator (eu.bcvsolutions.idm.core.security.evaluator.CodeableEvaluator)1 AbstractEvaluatorIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractEvaluatorIntegrationTest)1 Test (org.junit.Test)1