use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class RoleDuplicateBulkActionIntegrationTest method testDuplicateRoleWithTheCyclicComposition.
@Test
public void testDuplicateRoleWithTheCyclicComposition() {
// create cyclic composition
IdmRoleDto role = createRole();
IdmRoleDto subRole = getHelper().createRole();
getHelper().createRoleComposition(role, subRole);
getHelper().createRoleComposition(subRole, role);
//
//
String targetEnvironment = getHelper().createName();
IdmBulkActionDto bulkAction = findBulkAction(IdmRole.class, RoleDuplicateBulkAction.NAME);
bulkAction.setIdentifiers(Sets.newHashSet(role.getId()));
bulkAction.getProperties().put(RoleDuplicateBulkAction.PROPERTY_ENVIRONMENT, targetEnvironment);
bulkAction.setIdentifiers(Sets.newHashSet(role.getId()));
bulkAction.getProperties().put(DuplicateRoleCompositionProcessor.PARAMETER_INCLUDE_ROLE_COMPOSITION, true);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
//
checkResultLrt(processAction, 1l, null, null);
//
IdmRoleDto duplicate = roleService.getByBaseCodeAndEnvironment(subRole.getCode(), targetEnvironment);
//
Assert.assertEquals(findAllSubRoles(role).size(), findAllSubRoles(duplicate).size());
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class ScriptRedeployBulkActionIntegrationTest method processBulkActionWithoutPermission.
@Test
public void processBulkActionWithoutPermission() {
IdmScriptDto script1 = scriptService.getByCode(TEST_SCRIPT_CODE_1);
Set<UUID> scripts = new HashSet<UUID>();
scripts.add(script1.getId());
String origDesc = script1.getDescription();
script1.setDescription(CHANGED_TEST_DESC);
script1 = scriptService.save(script1);
assertNotEquals(script1.getDescription(), origDesc);
// user hasn't permission for script update
IdmIdentityDto readerIdentity = this.createUserWithAuthorities(IdmBasePermission.READ);
loginAsNoAdmin(readerIdentity.getUsername());
IdmBulkActionDto bulkAction = this.findBulkAction(IdmScript.class, ScriptRedeployBulkAction.NAME);
bulkAction.setIdentifiers(scripts);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 0l, null, null);
script1 = scriptService.get(script1.getId());
assertEquals(script1.getDescription(), CHANGED_TEST_DESC);
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class ScriptRedeployBulkActionIntegrationTest method processBulkActionByFilter.
@Test
public void processBulkActionByFilter() {
IdmScriptDto script1 = scriptService.getByCode(TEST_SCRIPT_CODE_1);
Set<UUID> scripts = new HashSet<UUID>();
scripts.add(script1.getId());
String origDesc = script1.getDescription();
script1.setDescription(CHANGED_TEST_DESC);
script1 = scriptService.save(script1);
assertNotEquals(script1.getDescription(), origDesc);
IdmScriptFilter filter = new IdmScriptFilter();
filter.setCode(TEST_SCRIPT_CODE_1);
List<IdmScriptDto> checkScripts = scriptService.find(filter, null).getContent();
assertEquals(1, checkScripts.size());
IdmBulkActionDto bulkAction = this.findBulkAction(IdmScript.class, ScriptRedeployBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1l, null, null);
script1 = scriptService.get(script1.getId());
assertEquals(script1.getDescription(), origDesc);
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class ScriptRedeployBulkActionIntegrationTest method processBulkActionByIds.
@Test
public void processBulkActionByIds() {
IdmScriptDto script1 = scriptService.getByCode(TEST_SCRIPT_CODE_1);
Set<UUID> scripts = new HashSet<UUID>();
scripts.add(script1.getId());
String origDesc = script1.getDescription();
script1.setDescription(CHANGED_TEST_DESC);
script1 = scriptService.save(script1);
assertNotEquals(script1.getDescription(), origDesc);
IdmBulkActionDto bulkAction = this.findBulkAction(IdmScript.class, ScriptRedeployBulkAction.NAME);
bulkAction.setIdentifiers(scripts);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1l, null, null);
script1 = scriptService.get(script1.getId());
assertEquals(script1.getDescription(), origDesc);
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class TreeTypeDeleteBulkActionIntegrationTest method testForceDelete.
@Test
public void testForceDelete() {
logout();
loginAsAdmin();
// create sub tree nodes, automatic roles, contract, contract positions
IdmTreeTypeDto treeType = getHelper().createTreeType();
IdmTreeNodeDto treeNode = getHelper().createTreeNode(treeType, null, null);
IdmTreeNodeDto subTreeNode = getHelper().createTreeNode(treeType, (String) null, treeNode);
IdmTreeNodeDto subSubTreeNode = getHelper().createTreeNode(treeType, (String) null, subTreeNode);
IdmTreeNodeDto otherTreeNode = getHelper().createTreeNode();
IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
IdmIdentityContractDto contract = getHelper().createContract(identity, subTreeNode);
IdmContractPositionDto contractPosition = getHelper().createContractPosition(contract, subSubTreeNode);
IdmRoleDto role = getHelper().createRole();
IdmIdentityRoleDto assignedRoleOne = getHelper().createIdentityRole(contract, role);
IdmIdentityRoleDto assignedRoleTwo = getHelper().createIdentityRole(contractPosition, role);
IdmIdentityRoleDto assignedRoleOther = getHelper().createIdentityRole(getHelper().getPrimeContract(identity), role);
IdmRoleTreeNodeDto automaticRole = getHelper().createRoleTreeNode(role, treeNode, RecursionType.DOWN, false);
//
// 3 manual, 2 automatic
Assert.assertEquals(5, identityRoleService.findAllByIdentity(identity.getId()).size());
//
// remove tree type
Map<String, Object> properties = new HashMap<>();
properties.put(EntityEventProcessor.PROPERTY_FORCE_DELETE, Boolean.TRUE);
// delete by bulk action
IdmBulkActionDto bulkAction = this.findBulkAction(IdmTreeType.class, TreeTypeDeleteBulkAction.NAME);
bulkAction.setIdentifiers(Sets.newHashSet(treeType.getId()));
bulkAction.setProperties(properties);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
//
checkResultLrt(processAction, 1l, 0l, 0l);
//
Assert.assertNull(treeTypeService.get(treeType));
Assert.assertNull(treeNodeService.get(treeNode));
Assert.assertNull(treeNodeService.get(subTreeNode));
Assert.assertNull(treeNodeService.get(subSubTreeNode));
Assert.assertNull(treeNodeService.get(subSubTreeNode));
Assert.assertNotNull(identityRoleService.get(assignedRoleOne));
Assert.assertNotNull(identityRoleService.get(assignedRoleTwo));
Assert.assertNull(identityContractService.get(contract).getWorkPosition());
Assert.assertNull(contractPositionService.get(contractPosition).getWorkPosition());
Assert.assertNull(roleTreeNodeService.get(automaticRole));
//
Assert.assertNotNull(treeNodeService.get(otherTreeNode));
Assert.assertNotNull(getHelper().getPrimeContract(identity));
Assert.assertNotNull(identityRoleService.get(assignedRoleOther));
}
Aggregations