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