Search in sources :

Example 66 with IdmEntityStateDto

use of eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto in project CzechIdMng by bcvsolutions.

the class AbstractMonitoringIgnoredBulkAction method processDto.

@Override
protected OperationResult processDto(DTO dto) {
    IdmEntityStateDto state = new IdmEntityStateDto();
    state.setResult(new OperationResultDto.Builder(OperationState.BLOCKED).setModel(new DefaultResultModel(CoreResultCode.MONITORING_IGNORED)).build());
    entityStateManager.saveState(dto, state);
    // 
    return new OperationResult.Builder(OperationState.EXECUTED).build();
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult)

Example 67 with IdmEntityStateDto

use of eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmEntityStateServiceIntegrationTest method testReferentialIntegrityOwnerIsDeleted.

@Test
@Ignore
public void testReferentialIntegrityOwnerIsDeleted() {
    IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
    // 
    IdmEntityStateDto entityState = new IdmEntityStateDto();
    entityState.setOwnerId(lookupService.getOwnerId(identity));
    entityState.setOwnerType(lookupService.getOwnerType(identity));
    entityState.setResult(new OperationResultDto(OperationState.BLOCKED));
    entityState = entityStateService.save(entityState);
    // 
    IdmEntityStateDto entityStateTwo = new IdmEntityStateDto();
    entityStateTwo.setOwnerId(lookupService.getOwnerId(identityTwo));
    entityStateTwo.setOwnerType(lookupService.getOwnerType(identityTwo));
    entityStateTwo.setResult(new OperationResultDto(OperationState.BLOCKED));
    entityStateTwo = entityStateService.save(entityStateTwo);
    // 
    Assert.assertNotNull(entityState.getId());
    Assert.assertNotNull(entityStateTwo.getId());
    // 
    getHelper().getService(IdmIdentityService.class).delete(identityTwo);
    // 
    Assert.assertNull(entityStateService.get(entityStateTwo));
    Assert.assertNotNull(entityStateService.get(entityState));
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) IdmIdentityService(eu.bcvsolutions.idm.core.api.service.IdmIdentityService) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 68 with IdmEntityStateDto

use of eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmEntityEventServiceIntegrationTest method testReferentialIntegrityOwnerIsDeleted.

@Test
@Ignore
public void testReferentialIntegrityOwnerIsDeleted() {
    IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
    IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
    // 
    IdmEntityEventDto entityEvent = new IdmEntityEventDto();
    entityEvent.setOwnerType(entityEventManager.getOwnerType(identity.getClass()));
    entityEvent.setEventType("empty");
    entityEvent.setOwnerId(identity.getId());
    entityEvent.setInstanceId("empty");
    entityEvent.setResult(new OperationResultDto(OperationState.BLOCKED));
    entityEvent.setPriority(PriorityType.NORMAL);
    entityEvent = entityEventService.save(entityEvent);
    // 
    Assert.assertNotNull(entityEvent.getId());
    // 
    IdmEntityStateDto entityState = new IdmEntityStateDto(entityEvent);
    entityState.setResult(new OperationResultDto(OperationState.BLOCKED));
    entityState = entityStateService.save(entityState);
    // 
    Assert.assertNotNull(entityState.getId());
    // 
    identityService.delete(identityTwo);
    // 
    Assert.assertNotNull(identityService.get(identity));
    Assert.assertNotNull(entityEventService.get(entityEvent));
    Assert.assertNotNull(entityStateService.get(entityState));
    // 
    identityService.delete(identity);
    // 
    Assert.assertNull(identityService.get(identity));
    Assert.assertNull(entityEventService.get(entityEvent));
    Assert.assertNull(entityStateService.get(entityState));
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) Ignore(org.junit.Ignore) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 69 with IdmEntityStateDto

use of eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmEntityEventServiceIntegrationTest method testReferentialIntegrity.

@Test
@Transactional
public void testReferentialIntegrity() {
    IdmEntityEventDto entityEvent = new IdmEntityEventDto();
    entityEvent.setOwnerType("empty");
    entityEvent.setEventType("empty");
    entityEvent.setOwnerId(UUID.randomUUID());
    entityEvent.setInstanceId("empty");
    entityEvent.setResult(new OperationResultDto(OperationState.BLOCKED));
    entityEvent.setPriority(PriorityType.NORMAL);
    entityEvent = entityEventService.save(entityEvent);
    // 
    Assert.assertNotNull(entityEvent.getId());
    // 
    IdmEntityStateDto entityState = new IdmEntityStateDto(entityEvent);
    entityState.setResult(new OperationResultDto(OperationState.BLOCKED));
    entityState = entityStateService.save(entityState);
    // 
    Assert.assertNotNull(entityState.getId());
    // 
    entityEventService.delete(entityEvent);
    // 
    Assert.assertNull(entityEventService.get(entityEvent));
    Assert.assertNull(entityStateService.get(entityState));
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 70 with IdmEntityStateDto

use of eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmIdentityContractServiceIntegrationTest method testSkipAndRemoveAutomaticRoleOnInvalidContract.

@Test
public void testSkipAndRemoveAutomaticRoleOnInvalidContract() {
    IdmTreeNodeDto node = getHelper().createTreeNode();
    // define automatic role for parent
    IdmRoleDto role = getHelper().createRole();
    IdmRoleDto subRole = getHelper().createRole();
    getHelper().createRoleComposition(role, subRole);
    IdmRoleTreeNodeDto automaticRole = getHelper().createRoleTreeNode(role, node, RecursionType.NO, true);
    // create identity with contract on node
    IdmIdentityDto identity = getHelper().createIdentity((GuardedString) null);
    IdmIdentityContractDto contract = getHelper().createContract(identity, node);
    // role should be assigned now
    List<IdmIdentityRoleDto> assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
    Assert.assertEquals(2, assignedRoles.size());
    Assert.assertTrue(assignedRoles.stream().anyMatch(ir -> automaticRole.getId().equals(ir.getAutomaticRole())));
    Assert.assertTrue(assignedRoles.stream().anyMatch(ir -> ir.getDirectRole() != null));
    // 
    contract.setValidTill(LocalDate.now().minusDays(2));
    EntityEvent<IdmIdentityContractDto> event = new IdentityContractEvent(IdentityContractEventType.UPDATE, contract);
    event.getProperties().put(AutomaticRoleManager.SKIP_RECALCULATION, Boolean.TRUE);
    contract = service.publish(event).getContent();
    UUID contractId = contract.getId();
    IdmEntityStateFilter filter = new IdmEntityStateFilter();
    filter.setStates(Lists.newArrayList(OperationState.BLOCKED));
    filter.setResultCode(CoreResultCode.AUTOMATIC_ROLE_SKIPPED_INVALID_CONTRACT.getCode());
    filter.setOwnerType(entityStateManager.getOwnerType(IdmIdentityContractDto.class));
    List<IdmEntityStateDto> skippedStates = entityStateManager.findStates(filter, null).getContent();
    Assert.assertTrue(skippedStates.stream().anyMatch(s -> s.getOwnerId().equals(contractId)));
    // 
    assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
    Assert.assertEquals(2, assignedRoles.size());
    Assert.assertTrue(assignedRoles.stream().anyMatch(ir -> automaticRole.getId().equals(ir.getAutomaticRole())));
    Assert.assertTrue(assignedRoles.stream().anyMatch(ir -> ir.getDirectRole() != null));
    // 
    // recount skipped automatic roles
    longRunningTaskManager.execute(new ProcessSkippedAutomaticRoleByTreeForContractTaskExecutor());
    skippedStates = entityStateManager.findStates(filter, null).getContent();
    Assert.assertFalse(skippedStates.stream().anyMatch(s -> s.getOwnerId().equals(automaticRole.getId())));
    // 
    assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
    Assert.assertTrue(assignedRoles.isEmpty());
}
Also used : Lists(org.testng.collections.Lists) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) ProcessAutomaticRoleByTreeTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.ProcessAutomaticRoleByTreeTaskExecutor) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmIdentityContract(eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) ProcessSkippedAutomaticRoleByTreeForContractTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.ProcessSkippedAutomaticRoleByTreeForContractTaskExecutor) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) AutomaticRoleManager(eu.bcvsolutions.idm.core.api.service.AutomaticRoleManager) AutowireHelper(eu.bcvsolutions.idm.core.api.utils.AutowireHelper) IdmAutomaticRoleAttributeDto(eu.bcvsolutions.idm.core.api.dto.IdmAutomaticRoleAttributeDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) After(org.junit.After) TransactionContextHolder(eu.bcvsolutions.idm.core.api.domain.TransactionContextHolder) IdmLongRunningTaskFilter(eu.bcvsolutions.idm.core.scheduler.api.dto.filter.IdmLongRunningTaskFilter) LongRunningTaskEventType(eu.bcvsolutions.idm.core.scheduler.api.event.LongRunningTaskEvent.LongRunningTaskEventType) EmptyResultDataAccessException(org.springframework.dao.EmptyResultDataAccessException) AutomaticRoleAttributeRuleType(eu.bcvsolutions.idm.core.api.domain.AutomaticRoleAttributeRuleType) RecursionType(eu.bcvsolutions.idm.core.api.domain.RecursionType) IdmIdentityContractService(eu.bcvsolutions.idm.core.api.service.IdmIdentityContractService) ContractPositionEventType(eu.bcvsolutions.idm.core.model.event.ContractPositionEvent.ContractPositionEventType) ContractState(eu.bcvsolutions.idm.core.api.domain.ContractState) IdentityContractEventType(eu.bcvsolutions.idm.core.model.event.IdentityContractEvent.IdentityContractEventType) LongRunningFutureTask(eu.bcvsolutions.idm.core.scheduler.api.dto.LongRunningFutureTask) Set(java.util.Set) AcceptedException(eu.bcvsolutions.idm.core.api.exception.AcceptedException) IdmEntityStateFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityStateFilter) UUID(java.util.UUID) Page(org.springframework.data.domain.Page) IdmContractPositionDto(eu.bcvsolutions.idm.core.api.dto.IdmContractPositionDto) IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) RemoveAutomaticRoleTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.RemoveAutomaticRoleTaskExecutor) IdmContractGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto) List(java.util.List) EventConfiguration(eu.bcvsolutions.idm.core.api.config.domain.EventConfiguration) ContractBasePermission(eu.bcvsolutions.idm.core.security.api.domain.ContractBasePermission) Assert.assertFalse(org.junit.Assert.assertFalse) LocalDate(java.time.LocalDate) IdentityContractEvent(eu.bcvsolutions.idm.core.model.event.IdentityContractEvent) ContractPositionEvent(eu.bcvsolutions.idm.core.model.event.ContractPositionEvent) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) IdmContractPositionService(eu.bcvsolutions.idm.core.api.service.IdmContractPositionService) IdmTreeNodeService(eu.bcvsolutions.idm.core.api.service.IdmTreeNodeService) IdmRoleTreeNodeService(eu.bcvsolutions.idm.core.api.service.IdmRoleTreeNodeService) PermissionContext(eu.bcvsolutions.idm.core.api.dto.filter.PermissionContext) IdmContractGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter) IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) EntityStateManager(eu.bcvsolutions.idm.core.api.service.EntityStateManager) LookupService(eu.bcvsolutions.idm.core.api.service.LookupService) IdmContractPositionFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractPositionFilter) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) IdmLongRunningTaskService(eu.bcvsolutions.idm.core.scheduler.api.service.IdmLongRunningTaskService) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) Before(org.junit.Before) IdmIdentityRoleService(eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService) SchedulerConfiguration(eu.bcvsolutions.idm.core.scheduler.api.config.SchedulerConfiguration) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) LongRunningTaskManager(eu.bcvsolutions.idm.core.scheduler.api.service.LongRunningTaskManager) Assert.assertNotNull(org.junit.Assert.assertNotNull) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmEntityEventFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter) Assert.assertTrue(org.junit.Assert.assertTrue) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) Test(org.junit.Test) IdmContractGuaranteeService(eu.bcvsolutions.idm.core.api.service.IdmContractGuaranteeService) ApplicationContext(org.springframework.context.ApplicationContext) IdmIdentityContract_(eu.bcvsolutions.idm.core.model.entity.IdmIdentityContract_) IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) PrivateIdentityConfiguration(eu.bcvsolutions.idm.core.api.config.domain.PrivateIdentityConfiguration) AutomaticRoleAttributeRuleComparison(eu.bcvsolutions.idm.core.api.domain.AutomaticRoleAttributeRuleComparison) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) IdentityConfiguration(eu.bcvsolutions.idm.core.api.config.domain.IdentityConfiguration) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) Transactional(org.springframework.transaction.annotation.Transactional) IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) ProcessSkippedAutomaticRoleByTreeForContractTaskExecutor(eu.bcvsolutions.idm.core.scheduler.task.impl.ProcessSkippedAutomaticRoleByTreeForContractTaskExecutor) IdentityContractEvent(eu.bcvsolutions.idm.core.model.event.IdentityContractEvent) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) UUID(java.util.UUID) IdmEntityStateFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityStateFilter) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmEntityStateDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto)77 OperationResultDto (eu.bcvsolutions.idm.core.api.dto.OperationResultDto)43 Test (org.junit.Test)41 UUID (java.util.UUID)40 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)33 DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)30 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)30 OperationState (eu.bcvsolutions.idm.core.api.domain.OperationState)24 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)23 List (java.util.List)21 Autowired (org.springframework.beans.factory.annotation.Autowired)21 IdmEntityEventDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto)20 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)19 Transactional (org.springframework.transaction.annotation.Transactional)19 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)18 Lists (com.google.common.collect.Lists)15 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)15 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)15 Assert (org.junit.Assert)14 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)13