use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmAutomaticRoleRequestServiceIntegrationTest method testDeleteAutomaticAttributeRoleApproval.
@Test
public void testDeleteAutomaticAttributeRoleApproval() {
IdmRoleDto role = prepareRole();
IdmIdentityDto guaranteeIdentity = helper.createIdentity();
IdmRoleGuaranteeDto guarantee = new IdmRoleGuaranteeDto();
guarantee.setRole(role.getId());
guarantee.setGuarantee(guaranteeIdentity.getId());
role.getGuarantees().add(guarantee);
role = roleService.save(role);
IdmIdentityDto identity = helper.createIdentity();
IdmAutomaticRoleAttributeDto automaticRole = new IdmAutomaticRoleAttributeDto();
automaticRole.setRole(role.getId());
automaticRole.setName(role.getName());
IdmAutomaticRoleAttributeRuleDto rule = new IdmAutomaticRoleAttributeRuleDto();
rule.setAttributeName(IdmIdentity_.username.getName());
rule.setComparison(AutomaticRoleAttributeRuleComparison.EQUALS);
rule.setType(AutomaticRoleAttributeRuleType.IDENTITY);
rule.setValue(identity.getUsername());
// Create automatic role via manager
automaticRole = automaticRoleManager.createAutomaticRoleByAttribute(automaticRole, true, rule);
// Delete automatic role via manager
try {
automaticRoleManager.deleteAutomaticRole(automaticRole, false);
} catch (AcceptedException ex) {
// The request is in approval
Assert.assertNotNull(ex.getIdentifier());
UUID requestId = UUID.fromString(ex.getIdentifier());
loginAsNoAdmin(guaranteeIdentity.getUsername());
try {
completeTasksFromUsers(guaranteeIdentity.getUsername(), "approve");
} catch (ResultCodeException e) {
fail("User has permission to approve task. Error message: " + e.getLocalizedMessage());
} catch (Exception e) {
fail("Some problem: " + e.getLocalizedMessage());
}
IdmAutomaticRoleRequestDto request = roleRequestService.get(requestId);
Assert.assertEquals(RequestState.EXECUTED, request.getState());
IdmRoleTreeNodeDto deletedAutomaticRole = roleTreeNodeService.get(automaticRole.getId());
Assert.assertNull(deletedAutomaticRole);
return;
}
fail("Automatic role request have to be approving by gurantee!");
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method testDontAssingRoleForContractValidInThePast.
@Test
public void testDontAssingRoleForContractValidInThePast() {
IdmIdentityDto identity = helper.createIdentity();
//
IdmIdentityContractDto contractD = new IdmIdentityContractDto();
contractD.setIdentity(identity.getId());
contractD.setWorkPosition(nodeD.getId());
contractD.setValidTill(new LocalDate().minusDays(1));
contractD = service.save(contractD);
//
// create new automatic role
automaticRoleD = new IdmRoleTreeNodeDto();
automaticRoleD.setRecursionType(RecursionType.NO);
automaticRoleD.setRole(roleA.getId());
automaticRoleD.setTreeNode(nodeD.getId());
automaticRoleD = saveAutomaticRole(automaticRoleD, true);
//
// check
List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contractD.getId());
assertEquals(0, identityRoles.size());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method testFindAutomaticRoleWithRecursionUp.
@Test
public void testFindAutomaticRoleWithRecursionUp() {
// prepare
automaticRoleA = new IdmRoleTreeNodeDto();
automaticRoleA.setRecursionType(RecursionType.UP);
automaticRoleA.setRole(roleA.getId());
automaticRoleA.setTreeNode(nodeD.getId());
automaticRoleA = saveAutomaticRole(automaticRoleA, false);
//
// test
Set<IdmRoleTreeNodeDto> automaticRoles = roleTreeNodeService.getAutomaticRolesByTreeNode(nodeD.getId());
assertEquals(1, automaticRoles.size());
assertEquals(roleA.getId(), automaticRoles.iterator().next().getRole());
assertTrue(roleTreeNodeService.getAutomaticRolesByTreeNode(nodeF.getId()).isEmpty());
automaticRoles = roleTreeNodeService.getAutomaticRolesByTreeNode(nodeB.getId());
assertEquals(1, automaticRoles.size());
assertEquals(roleA.getId(), automaticRoles.iterator().next().getRole());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method testReferentialIntegrityOnTreeNode.
@Test
public void testReferentialIntegrityOnTreeNode() {
helper.setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, false);
try {
// prepare data
IdmRoleDto role = helper.createRole();
IdmTreeNodeDto treeNode = helper.createTreeNode();
// automatic role
IdmRoleTreeNodeDto roleTreeNode = helper.createRoleTreeNode(role, treeNode, false);
//
assertNotNull(roleTreeNode.getId());
assertEquals(roleTreeNode.getId(), roleTreeNodeService.get(roleTreeNode.getId()).getId());
//
helper.deleteTreeNode(treeNode.getId());
//
assertNull(roleTreeNodeService.get(roleTreeNode.getId()));
} finally {
helper.setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, true);
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method testFindAutomaticRoleWithRecursionDown.
@Test
public void testFindAutomaticRoleWithRecursionDown() {
// prepare
automaticRoleA = new IdmRoleTreeNodeDto();
automaticRoleA.setRecursionType(RecursionType.DOWN);
automaticRoleA.setRole(roleA.getId());
automaticRoleA.setTreeNode(nodeD.getId());
automaticRoleA = saveAutomaticRole(automaticRoleA, false);
//
// test
Set<IdmRoleTreeNodeDto> automaticRoles = roleTreeNodeService.getAutomaticRolesByTreeNode(nodeD.getId());
assertEquals(1, automaticRoles.size());
assertEquals(roleA.getId(), automaticRoles.iterator().next().getRole());
assertTrue(roleTreeNodeService.getAutomaticRolesByTreeNode(nodeB.getId()).isEmpty());
automaticRoles = roleTreeNodeService.getAutomaticRolesByTreeNode(nodeF.getId());
assertEquals(1, automaticRoles.size());
assertEquals(roleA.getId(), automaticRoles.iterator().next().getRole());
}
Aggregations