use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class NotificationTemplateRedeployBulkActionIntegrationTest method processBulkActionByFilter.
@Test
public void processBulkActionByFilter() {
IdmNotificationTemplateDto template1 = templateService.getByCode(TEST_TEMPLATE);
Set<UUID> templates = new HashSet<UUID>();
templates.add(template1.getId());
String origSubj = template1.getSubject();
template1.setSubject(CHANGED_TEST_DESC);
template1 = templateService.save(template1);
assertNotEquals(template1.getSubject(), origSubj);
IdmNotificationTemplateFilter filter = new IdmNotificationTemplateFilter();
filter.setText(CHANGED_TEST_DESC);
List<IdmNotificationTemplateDto> checkScripts = templateService.find(filter, null).getContent();
assertEquals(1, checkScripts.size());
IdmBulkActionDto bulkAction = this.findBulkAction(IdmNotificationTemplate.class, NotificationTemplateRedeployBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1l, null, null);
template1 = templateService.get(template1.getId());
assertEquals(template1.getSubject(), origSubj);
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class AuthorizationPolicyDisableBulkActionIntegrationTest method processBulkActionByFilter.
@Test
public void processBulkActionByFilter() {
List<IdmAuthorizationPolicyDto> policies = createPolicies(5);
IdmAuthorizationPolicyFilter filter = new IdmAuthorizationPolicyFilter();
filter.setId(policies.get(2).getId());
List<IdmAuthorizationPolicyDto> checkPolicies = service.find(filter, null).getContent();
Assert.assertEquals(1, checkPolicies.size());
IdmBulkActionDto bulkAction = findBulkAction(IdmAuthorizationPolicy.class, AuthorizationPolicyDisableBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1l, null, null);
Assert.assertTrue(service.get(policies.get(2)).isDisabled());
Assert.assertFalse(service.get(policies.get(1)).isDisabled());
Assert.assertFalse(service.get(policies.get(3)).isDisabled());
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class ManualWorkflowTaskDelegationBulkActionTest method testBulkActionByIds.
@Test
public void testBulkActionByIds() {
// Enable approving of a role-request by manager.
getHelper().setConfigurationValue(ChangeIdentityPermissionTest.APPROVE_BY_MANAGER_ENABLE, true);
IdmRoleDto roleOne = getHelper().createRole();
IdmIdentityDto delegator = getHelper().createIdentity();
IdmIdentityDto subordinate = getHelper().createIdentity();
IdmIdentityContractDto subordinateContract = getHelper().createContract(subordinate);
getHelper().createContractGuarantee(subordinateContract, delegator);
WorkflowFilterDto taskFilter = new WorkflowFilterDto();
taskFilter.setCandidateOrAssigned(delegator.getUsername());
List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(0, tasks.size());
// Assing role -> reuqest will be in progress state.
IdmRoleRequestDto roleRequest = getHelper().createRoleRequest(subordinateContract, ConceptRoleRequestOperation.ADD, roleOne);
roleRequest.setExecuteImmediately(false);
roleRequest = roleRequestService.save(roleRequest);
roleRequest = getHelper().executeRequest(roleRequest, false, true);
assertEquals(RoleRequestState.IN_PROGRESS, roleRequest.getState());
tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(1, tasks.size());
List<IdentityLinkDto> identityLinks = tasks.get(0).getIdentityLinks();
assertEquals(1, identityLinks.size());
// Task is assigned to the delegator now.
assertEquals(delegator.getId(), UUID.fromString(identityLinks.get(0).getUserId()));
IdmBulkActionDto bulkAction = this.findBulkActionForDto(WorkflowTaskInstanceAbstractDto.class, ManualWorkflowTaskDelegationBulkAction.NAME);
Set<UUID> ids = Sets.newHashSet();
ids.add(UUID.fromString(tasks.get(0).getId()));
IdmIdentityDto delegate = getHelper().createIdentity();
bulkAction.setIdentifiers(ids);
bulkAction.getProperties().put(ManualWorkflowTaskDelegationBulkAction.DELEGATE_ATTRIBUTE, delegate.getId());
bulkAction.getProperties().put(ManualWorkflowTaskDelegationBulkAction.CANDIDATE_OR_ASSIGNED_FILTER_FIELD, delegator.getId());
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1l, null, null);
WorkflowTaskInstanceDto task = workflowTaskInstanceService.get(tasks.get(0).getId());
assertNotNull(task);
identityLinks = task.getIdentityLinks();
assertEquals(2, identityLinks.size());
// Check delegator as participant in the task.
long participantCount = identityLinks.stream().filter(identityLink -> IdentityLinkType.PARTICIPANT.equals(identityLink.getType()) && UUID.fromString(identityLink.getUserId()).equals(delegator.getId())).count();
assertEquals(1, participantCount);
// Check delegate as candidat in the task;
long candidateCount = identityLinks.stream().filter(identityLink -> IdentityLinkType.CANDIDATE.equals(identityLink.getType()) && UUID.fromString(identityLink.getUserId()).equals(delegate.getId())).count();
assertEquals(1, candidateCount);
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class ManualWorkflowTaskDelegationBulkActionTest method testBulkActionWithoutPermission.
@Test
public void testBulkActionWithoutPermission() {
// Enable approving of a role-request by manager.
getHelper().setConfigurationValue(ChangeIdentityPermissionTest.APPROVE_BY_MANAGER_ENABLE, true);
IdmRoleDto roleOne = getHelper().createRole();
IdmIdentityDto delegator = getHelper().createIdentity();
IdmIdentityDto subordinate = getHelper().createIdentity();
IdmIdentityContractDto subordinateContract = getHelper().createContract(subordinate);
getHelper().createContractGuarantee(subordinateContract, delegator);
WorkflowFilterDto taskFilter = new WorkflowFilterDto();
taskFilter.setCandidateOrAssigned(delegator.getUsername());
List<WorkflowTaskInstanceDto> tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(0, tasks.size());
// Assing role -> reuqest will be in progress state.
IdmRoleRequestDto roleRequest = getHelper().createRoleRequest(subordinateContract, ConceptRoleRequestOperation.ADD, roleOne);
roleRequest.setExecuteImmediately(false);
roleRequest = roleRequestService.save(roleRequest);
roleRequest = getHelper().executeRequest(roleRequest, false, true);
assertEquals(RoleRequestState.IN_PROGRESS, roleRequest.getState());
tasks = workflowTaskInstanceService.find(taskFilter, null).getContent();
assertEquals(1, tasks.size());
List<IdentityLinkDto> identityLinks = tasks.get(0).getIdentityLinks();
assertEquals(1, identityLinks.size());
// Task is assigned to the delegator now.
assertEquals(delegator.getId(), UUID.fromString(identityLinks.get(0).getUserId()));
IdmBulkActionDto bulkAction = this.findBulkActionForDto(WorkflowTaskInstanceAbstractDto.class, ManualWorkflowTaskDelegationBulkAction.NAME);
Set<UUID> ids = Sets.newHashSet();
ids.add(UUID.fromString(tasks.get(0).getId()));
IdmIdentityDto delegate = getHelper().createIdentity();
// User hasn't permission for read a workflow tasks.
IdmIdentityDto anotherUser = this.createUserWithAuthorities(IdmBasePermission.READ);
// Attacker
loginWithout(anotherUser.getUsername(), IdmGroupPermission.APP_ADMIN, CoreGroupPermission.WORKFLOW_TASK_ADMIN);
bulkAction.setIdentifiers(ids);
bulkAction.getProperties().put(ManualWorkflowTaskDelegationBulkAction.DELEGATE_ATTRIBUTE, delegate.getId());
bulkAction.getProperties().put(ManualWorkflowTaskDelegationBulkAction.CANDIDATE_OR_ASSIGNED_FILTER_FIELD, delegator.getId());
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 0l, 0l, 0l);
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class FormAttributeDeleteBulkActionIntegrationTest method testDeleteWithFilledValues.
@Test
public void testDeleteWithFilledValues() {
IdmIdentityDto owner = getHelper().createIdentity((GuardedString) null);
//
IdmFormAttributeDto attributeDefinitionOne = new IdmFormAttributeDto();
attributeDefinitionOne.setCode(getHelper().createName());
attributeDefinitionOne.setName(attributeDefinitionOne.getCode());
attributeDefinitionOne.setPersistentType(PersistentType.TEXT);
IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmIdentity.class, getHelper().createName(), Lists.newArrayList(attributeDefinitionOne));
attributeDefinitionOne = formDefinitionOne.getMappedAttributeByCode(attributeDefinitionOne.getCode());
//
IdmFormValueDto value = new IdmFormValueDto(attributeDefinitionOne);
value.setValue(getHelper().createName());
formService.saveValues(owner, formDefinitionOne, Lists.newArrayList(value));
Assert.assertEquals(value.getStringValue(), formService.getValues(owner, formDefinitionOne).get(0).getStringValue());
//
IdmBulkActionDto bulkAction = findBulkAction(IdmFormAttribute.class, FormAttributeDeleteBulkAction.NAME);
Set<UUID> ids = Sets.newHashSet(attributeDefinitionOne.getId());
bulkAction.setIdentifiers(ids);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
// without force
checkResultLrt(processAction, null, 1l, null);
Assert.assertEquals(value.getStringValue(), formService.getValues(owner, formDefinitionOne).get(0).getStringValue());
// with force
Map<String, Object> properties = new HashMap<>();
properties.put(EntityEventProcessor.PROPERTY_FORCE_DELETE, Boolean.TRUE);
// delete by bulk action
bulkAction = findBulkAction(IdmFormAttribute.class, FormAttributeDeleteBulkAction.NAME);
bulkAction.setIdentifiers(ids);
bulkAction.setProperties(properties);
//
processAction = bulkActionManager.processAction(bulkAction);
// with force
checkResultLrt(processAction, 1l, null, null);
Assert.assertTrue(formService.getValues(owner, formDefinitionOne).isEmpty());
//
formService.deleteDefinition(formDefinitionOne);
getHelper().deleteIdentity(owner.getId());
}
Aggregations