use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmAutomaticRoleRequestServiceIntegrationTest method testTreeAutomaticRoleDisapprovalWithSecurityWF.
@Test
public void testTreeAutomaticRoleDisapprovalWithSecurityWF() {
IdmRoleDto role = prepareRole();
configurationService.setValue(IdmRoleService.WF_BY_ROLE_PRIORITY_PREFIX + role.getPriority(), APPROVE_ROLE_BY_GUARANTEE_AND_SECURITY_KEY);
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
try {
automaticRole = automaticRoleManager.createAutomaticRoleByTree(automaticRole, false);
} catch (AcceptedException ex) {
// The request is in approval
Assert.assertNotNull(ex.getIdentifier());
UUID requestId = UUID.fromString(ex.getIdentifier());
loginAsNoAdmin(guaranteeIdentity.getUsername());
try {
// by guarantor
completeTasksFromUsers(guaranteeIdentity.getUsername(), "disapprove");
} 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.DISAPPROVED, request.getState());
Assert.assertNull(request.getAutomaticRole());
return;
} finally {
configurationService.setValue(IdmRoleService.WF_BY_ROLE_PRIORITY_PREFIX + role.getPriority(), APPROVE_ROLE_BY_GUARANTEE_KEY);
}
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 DefaultIdmAutomaticRoleRequestServiceIntegrationTest method testDeleteAutomaticAttributeRoleApproval.
@Test
public void testDeleteAutomaticAttributeRoleApproval() {
IdmRoleDto role = prepareRole();
IdmIdentityDto guaranteeIdentity = getHelper().createIdentity();
getHelper().createRoleGuarantee(role, guaranteeIdentity);
IdmIdentityDto identity = getHelper().createIdentity();
IdmAutomaticRoleAttributeDto automaticRole = new IdmAutomaticRoleAttributeDto();
automaticRole.setRole(role.getId());
automaticRole.setName(role.getCode());
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 DefaultIdmAutomaticRoleRequestServiceIntegrationTest method testCreateTreeAutomaticRoleWithRecursion.
@Test
public void testCreateTreeAutomaticRoleWithRecursion() {
IdmRoleDto role = prepareRole();
IdmTreeNodeDto nodeOne = getHelper().createTreeNode();
IdmRoleTreeNodeDto automaticRole = new IdmRoleTreeNodeDto();
automaticRole.setRole(role.getId());
automaticRole.setName(role.getCode());
automaticRole.setRecursionType(RecursionType.DOWN);
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(RecursionType.DOWN, treeAutomaticRole.getRecursionType());
// Create second
IdmRoleTreeNodeDto automaticRoleTwo = new IdmRoleTreeNodeDto();
automaticRoleTwo.setRole(role.getId());
automaticRoleTwo.setName(role.getCode());
automaticRoleTwo.setRecursionType(RecursionType.UP);
automaticRoleTwo.setTreeNode(nodeOne.getId());
// Create automatic role via manager
IdmRoleTreeNodeDto treeAutomaticRoleTwo = automaticRoleManager.createAutomaticRoleByTree(automaticRoleTwo, true);
Assert.assertNotNull(treeAutomaticRoleTwo.getId());
Assert.assertEquals(RecursionType.UP, treeAutomaticRoleTwo.getRecursionType());
// Create third
IdmRoleTreeNodeDto automaticRoleThree = new IdmRoleTreeNodeDto();
automaticRoleThree.setRole(role.getId());
automaticRoleThree.setName(role.getCode());
automaticRoleThree.setRecursionType(RecursionType.NO);
automaticRoleThree.setTreeNode(nodeOne.getId());
// Create automatic role via manager
IdmRoleTreeNodeDto treeAutomaticRoleThree = automaticRoleManager.createAutomaticRoleByTree(automaticRoleThree, true);
Assert.assertNotNull(treeAutomaticRoleThree.getId());
Assert.assertEquals(RecursionType.NO, treeAutomaticRoleThree.getRecursionType());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method testAssingRoleForContractValidInTheFuture.
@Test
public void testAssingRoleForContractValidInTheFuture() {
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
//
IdmIdentityContractDto contractD = new IdmIdentityContractDto();
contractD.setIdentity(identity.getId());
contractD.setWorkPosition(nodeD.getId());
contractD.setValidFrom(LocalDate.now().plusDays(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(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 DefaultIdmIdentityContractServiceIntegrationTest method saveAutomaticRole.
/**
* Save automatic role with repository and manual create and wait for task
* @param automaticRole
* @return
*/
private IdmRoleTreeNodeDto saveAutomaticRole(IdmRoleTreeNodeDto automaticRole, boolean withLongRunningTask) {
// default name
automaticRole.setName("default");
IdmRoleTreeNodeDto roleTreeNode = roleTreeNodeService.saveInternal(automaticRole);
//
if (withLongRunningTask) {
ProcessAutomaticRoleByTreeTaskExecutor task = new ProcessAutomaticRoleByTreeTaskExecutor();
task.setAutomaticRoles(Lists.newArrayList(roleTreeNode.getId()));
taskManager.executeSync(task);
}
//
return roleTreeNodeService.get(roleTreeNode.getId());
}
Aggregations