use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method testDontAssingRoleForDisabledContract.
@Test
public void testDontAssingRoleForDisabledContract() {
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
//
IdmIdentityContractDto contractD = new IdmIdentityContractDto();
contractD.setIdentity(identity.getId());
contractD.setWorkPosition(nodeD.getId());
contractD.setState(ContractState.DISABLED);
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 testAssignAutomaticRoleToExistIdentitySync.
@Test
public void testAssignAutomaticRoleToExistIdentitySync() {
getHelper().setConfigurationValue(EventConfiguration.PROPERTY_EVENT_ASYNCHRONOUS_ENABLED, false);
//
IdmIdentityDto identityOne = getHelper().createIdentityOnly();
IdmIdentityDto identityTwo = getHelper().createIdentityOnly();
IdmIdentityDto identityThree = getHelper().createIdentityOnly();
IdmTreeNodeDto treeNode = getHelper().createTreeNode();
IdmIdentityContractDto contractOne = getHelper().createContract(identityOne, treeNode);
IdmIdentityContractDto contractTwo = getHelper().createContract(identityTwo, treeNode);
IdmIdentityContractDto contractThree = getHelper().createContract(identityThree, treeNode);
IdmRoleDto role = getHelper().createRole();
IdmRoleTreeNodeDto automaticRole = getHelper().createAutomaticRole(role, treeNode);
//
List<IdmIdentityRoleDto> assignedRoles = identityRoleService.findByAutomaticRole(automaticRole.getId(), null).getContent();
Assert.assertEquals(3, assignedRoles.size());
Assert.assertTrue(assignedRoles.stream().anyMatch(ir -> ir.getIdentityContract().equals(contractOne.getId())));
Assert.assertTrue(assignedRoles.stream().anyMatch(ir -> ir.getIdentityContract().equals(contractTwo.getId())));
Assert.assertTrue(assignedRoles.stream().anyMatch(ir -> ir.getIdentityContract().equals(contractThree.getId())));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method testAssingRoleByNewAutomaticRoleForExistingContracts.
@Test
public void testAssingRoleByNewAutomaticRoleForExistingContracts() {
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
//
IdmIdentityContractDto contract = new IdmIdentityContractDto();
contract.setIdentity(identity.getId());
contract.setPosition("new position");
contract = service.save(contract);
//
IdmIdentityContractDto contractF = new IdmIdentityContractDto();
contractF.setIdentity(identity.getId());
contractF.setWorkPosition(nodeF.getId());
contractF = service.save(contractF);
//
IdmIdentityContractDto contractD = new IdmIdentityContractDto();
contractD.setIdentity(identity.getId());
contractD.setWorkPosition(nodeD.getId());
contractD = service.save(contractD);
//
IdmIdentityContractDto contractB = new IdmIdentityContractDto();
contractB.setIdentity(identity.getId());
contractB.setWorkPosition(nodeB.getId());
contractB = service.save(contractB);
//
// create new automatic role
automaticRoleD = new IdmRoleTreeNodeDto();
automaticRoleD.setRecursionType(RecursionType.DOWN);
automaticRoleD.setRole(roleA.getId());
automaticRoleD.setTreeNode(nodeD.getId());
automaticRoleD = saveAutomaticRole(automaticRoleD, true);
//
// check
List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contractB.getId());
assertTrue(identityRoles.isEmpty());
//
identityRoles = identityRoleService.findAllByContract(contractD.getId());
assertEquals(1, identityRoles.size());
assertEquals(automaticRoleD.getId(), identityRoles.get(0).getAutomaticRole());
//
identityRoles = identityRoleService.findAllByContract(contractF.getId());
assertEquals(1, identityRoles.size());
assertEquals(automaticRoleD.getId(), identityRoles.get(0).getAutomaticRole());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmAutomaticRoleRequestServiceIntegrationTest method testCreateTreeAutomaticRole.
@Test
public void testCreateTreeAutomaticRole() {
IdmRoleDto role = prepareRole();
IdmTreeNodeDto nodeOne = getHelper().createTreeNode();
IdmRoleTreeNodeDto automaticRole = new IdmRoleTreeNodeDto();
automaticRole.setRole(role.getId());
automaticRole.setName(role.getCode());
automaticRole.setTreeNode(nodeOne.getId());
// Create automatic role via manager
automaticRole = automaticRoleManager.createAutomaticRoleByTree(automaticRole, true);
Assert.assertNotNull(automaticRole.getId());
IdmRoleTreeNodeDto treeAutomaticRole = roleTreeNodeService.get(automaticRole.getId());
Assert.assertNotNull(treeAutomaticRole);
Assert.assertEquals(nodeOne.getId(), treeAutomaticRole.getTreeNode());
Assert.assertEquals(RecursionType.NO, treeAutomaticRole.getRecursionType());
Assert.assertEquals(role.getId(), treeAutomaticRole.getRole());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmAutomaticRoleRequestServiceIntegrationTest method testDeleteTreeAutomaticRoleApproval.
@Test
public void testDeleteTreeAutomaticRoleApproval() {
IdmRoleDto role = prepareRole();
IdmTreeNodeDto nodeOne = getHelper().createTreeNode();
IdmIdentityDto guaranteeIdentity = getHelper().createIdentity();
getHelper().createRoleGuarantee(role, guaranteeIdentity);
IdmRoleTreeNodeDto automaticRole = new IdmRoleTreeNodeDto();
automaticRole.setRole(role.getId());
automaticRole.setName(role.getCode());
automaticRole.setTreeNode(nodeOne.getId());
// Create automatic role via manager
automaticRole = automaticRoleManager.createAutomaticRoleByTree(automaticRole, true);
Assert.assertNotNull(automaticRole.getId());
IdmRoleTreeNodeDto treeAutomaticRole = roleTreeNodeService.get(automaticRole.getId());
Assert.assertNotNull(treeAutomaticRole);
Assert.assertEquals(nodeOne.getId(), treeAutomaticRole.getTreeNode());
Assert.assertEquals(role.getId(), treeAutomaticRole.getRole());
// 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!");
}
Aggregations