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();
}
}
Aggregations