use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class IdentityRoleValidRequestIntegrationTest method deleteRole.
@Test(expected = ResultCodeException.class)
public void deleteRole() {
IdmIdentityDto identity = createAndSaveIdentity();
IdmRoleDto role = createAndSaveRole();
IdmTreeTypeDto treeType = createAndSaveTreeType();
IdmTreeNodeDto treeNode = createAndSaveTreeNode(treeType);
IdmIdentityContractDto identityContract = createAndSaveIdentityContract(identity, treeNode);
LocalDate from = new LocalDate();
from = from.plusDays(5);
createAndSaveIdentityRole(identityContract, role, null, from);
List<IdmIdentityRoleValidRequestDto> list = identityRoleValidRequestService.find(null).getContent();
int size = list.size();
// role has identity, ok - throw error
roleService.delete(role);
list = identityRoleValidRequestService.find(null).getContent();
assertNotEquals(size, list.size());
list = identityRoleValidRequestService.findAllValidRequestForRoleId(role.getId());
assertEquals(true, list.isEmpty());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class IdentityRoleValidRequestIntegrationTest method deleteIdentityContract.
@Test
public void deleteIdentityContract() {
IdmIdentityDto identity = createAndSaveIdentity();
IdmRoleDto role = createAndSaveRole();
IdmTreeTypeDto treeType = createAndSaveTreeType();
IdmTreeNodeDto treeNode = createAndSaveTreeNode(treeType);
IdmIdentityContractDto identityContract = createAndSaveIdentityContract(identity, treeNode);
LocalDate from = new LocalDate();
from = from.plusDays(5);
createAndSaveIdentityRole(identityContract, role, null, from);
List<IdmIdentityRoleValidRequestDto> list = identityRoleValidRequestService.find(null).getContent();
int size = list.size();
identityContractService.delete(identityContract);
list = identityRoleValidRequestService.find(null).getContent();
assertNotEquals(size, list.size());
list = identityRoleValidRequestService.findAllValidRequestForIdentityContractId(identityContract.getId());
assertEquals(true, list.isEmpty());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class CodeableEvaluatorIntegrationTest method testPermissionByUuid.
@Test
public void testPermissionByUuid() {
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
// prepare role
IdmRoleDto role = helper.createRole();
//
IdmAuthorizationPolicyDto dto = new IdmAuthorizationPolicyDto();
dto.setRole(role.getId());
dto.setEvaluator(CodeableEvaluator.class);
dto.setGroupPermission(CoreGroupPermission.ROLE.getName());
dto.setAuthorizableType(IdmRole.class.getCanonicalName());
dto.getEvaluatorProperties().put(CodeableEvaluator.PARAMETER_IDENTIFIER, role.getId().toString());
dto.setPermissions(IdmBasePermission.READ);
authorizationPolicyService.save(dto);
// prepare identity
IdmIdentityDto identity = helper.createIdentity();
identity.setPassword(new GuardedString("heslo"));
identityService.save(identity);
// assign role
helper.createIdentityRole(identity, role);
logout();
//
try {
loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
//
// evaluate access
List<IdmRoleDto> roles = roleService.find(null, IdmBasePermission.READ).getContent();
assertEquals(1, roles.size());
assertEquals(role.getId(), roles.get(0).getId());
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class CodeableEvaluatorIntegrationTest method testPermissionByCode.
@Test
public void testPermissionByCode() {
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
// prepare role
IdmRoleDto role = helper.createRole();
//
IdmAuthorizationPolicyDto dto = new IdmAuthorizationPolicyDto();
dto.setRole(role.getId());
dto.setEvaluator(CodeableEvaluator.class);
dto.setGroupPermission(CoreGroupPermission.ROLE.getName());
dto.setAuthorizableType(IdmRole.class.getCanonicalName());
dto.getEvaluatorProperties().put(CodeableEvaluator.PARAMETER_IDENTIFIER, role.getCode());
dto.setPermissions(IdmBasePermission.READ);
authorizationPolicyService.save(dto);
// prepare identity
IdmIdentityDto identity = helper.createIdentity();
identity.setPassword(new GuardedString("heslo"));
identityService.save(identity);
// assign role
helper.createIdentityRole(identity, role);
logout();
//
try {
loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
//
// evaluate access
List<IdmRoleDto> roles = roleService.find(null, IdmBasePermission.READ).getContent();
assertEquals(1, roles.size());
assertEquals(role.getId(), roles.get(0).getId());
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleDto in project CzechIdMng by bcvsolutions.
the class ConfigurationEvaluatorIntegrationTest method testReadSecuredWithPermissions.
@Test
public void testReadSecuredWithPermissions() {
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
// prepare role
IdmRoleDto role = helper.createRole();
//
IdmAuthorizationPolicyDto dto = new IdmAuthorizationPolicyDto();
dto.setRole(role.getId());
dto.setEvaluator(ConfigurationEvaluator.class);
dto.setGroupPermission(CoreGroupPermission.CONFIGURATION.getName());
dto.setAuthorizableType(IdmConfiguration.class.getCanonicalName());
dto.getEvaluatorProperties().put(ConfigurationEvaluator.PARAMETER_SECURED, Boolean.TRUE.toString());
dto.setPermissions(IdmBasePermission.READ);
authorizationPolicyService.save(dto);
// prepare identity
IdmIdentityDto identity = helper.createIdentity();
identity.setPassword(new GuardedString("heslo"));
identityService.save(identity);
// assign role
helper.createIdentityRole(identity, role);
logout();
//
try {
loginService.login(new LoginDto(identity.getUsername(), identity.getPassword()));
//
// evaluate access
List<IdmConfigurationDto> configs = configurationService.find(null, IdmBasePermission.READ).getContent();
assertTrue(configs.contains(publicConfig));
assertTrue(configs.contains(privateConfig));
} finally {
logout();
}
}
Aggregations