Search in sources :

Example 41 with IdmBulkActionDto

use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.

the class RemoteServerDeleteBulkAction method prevalidate.

@Override
public ResultModels prevalidate() {
    IdmBulkActionDto action = getAction();
    List<UUID> entities = getEntities(action, new StringBuilder());
    ResultModels result = new ResultModels();
    Map<ResultModel, Long> models = new HashMap<>();
    entities.forEach(remoteServerId -> {
        SysSystemFilter systemFilter = new SysSystemFilter();
        systemFilter.setRemoteServerId(remoteServerId);
        long count = systemService.count(systemFilter);
        if (count > 0) {
            SysConnectorServerDto remoteServer = getService().get(remoteServerId);
            models.put(new DefaultResultModel(AccResultCode.REMOTE_SYSTEM_DELETE_FAILED_HAS_SYSTEMS, ImmutableMap.of("remoteServer", remoteServer.getFullServerName(), "count", count)), count);
        }
    });
    // 
    // Sort by count
    List<Entry<ResultModel, Long>> collect = models.entrySet().stream().sorted(Collections.reverseOrder(Map.Entry.comparingByValue())).collect(Collectors.toList());
    collect.forEach(entry -> {
        result.addInfo(entry.getKey());
    });
    // 
    return result;
}
Also used : IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) SysSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) HashMap(java.util.HashMap) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) ResultModels(eu.bcvsolutions.idm.core.api.dto.ResultModels) Entry(java.util.Map.Entry) UUID(java.util.UUID) SysConnectorServerDto(eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto)

Example 42 with IdmBulkActionDto

use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.

the class AccountManagementTest method testNoRemoveIdentityAccountIfRoleSystemRemovedAndRecreate.

@Test
public /**
 * IdentityAccount already exist, but doesn't have relation on RoleSystem. This
 * could happen if system mapping was deleted and recreated or if was role use
 * as sync default role, but without mapping on this system.
 */
void testNoRemoveIdentityAccountIfRoleSystemRemovedAndRecreate() {
    IdmRoleDto roleOne = getHelper().createRole();
    // create test system with mapping and link her to role
    SysSystemDto systemOne = getHelper().createTestResourceSystem(true);
    SysRoleSystemDto roleSystem = getHelper().createRoleSystem(roleOne, systemOne);
    IdmIdentityDto identity = getHelper().createIdentity();
    IdmRoleRequestDto roleRequestOne = getHelper().createRoleRequest(identity, roleOne);
    getHelper().executeRequest(roleRequestOne, false);
    // check after create
    List<IdmIdentityRoleDto> assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
    Assert.assertEquals(1, assignedRoles.size());
    // check created account
    AccAccountDto accountOne = accountService.getAccount(identity.getUsername(), systemOne.getId());
    Assert.assertNotNull(accountOne);
    Assert.assertNotNull(getHelper().findResource(accountOne.getRealUid()));
    // Delete role-system -> relation on role-system from identity-account will be removed.
    roleSystemService.delete(roleSystem);
    roleSystem = getHelper().createRoleSystem(roleOne, systemOne);
    // Execute ACM and provisioning via bulk action
    IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityAccountManagementBulkAction.NAME);
    bulkAction.setIdentifiers(Sets.newHashSet(identity.getId()));
    bulkActionManager.processAction(bulkAction);
    // Account must exist
    AccAccountDto accountTwo = accountService.getAccount(identity.getUsername(), systemOne.getId());
    Assert.assertNotNull(accountTwo);
    Assert.assertNotNull(getHelper().findResource(accountTwo.getRealUid()));
    // Account must have same ID as original -> must not be deleted
    Assert.assertEquals(accountOne.getId(), accountTwo.getId());
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 43 with IdmBulkActionDto

use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.

the class AccountManagementTest method testCreateIdentityAccountIfRoleSystemCreated.

@Test
public void testCreateIdentityAccountIfRoleSystemCreated() {
    IdmRoleDto roleOne = getHelper().createRole();
    // create test system with mapping
    SysSystemDto systemOne = getHelper().createTestResourceSystem(true);
    IdmIdentityDto identity = getHelper().createIdentity();
    IdmRoleRequestDto roleRequestOne = getHelper().createRoleRequest(identity, roleOne);
    getHelper().executeRequest(roleRequestOne, false);
    // check after create
    List<IdmIdentityRoleDto> assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
    Assert.assertEquals(1, assignedRoles.size());
    // check created account -> role-system mapping does not exist -> account is null
    AccAccountDto accountOne = accountService.getAccount(identity.getUsername(), systemOne.getId());
    Assert.assertNull(accountOne);
    getHelper().createRoleSystem(roleOne, systemOne);
    // Execute ACM and provisioning via bulk action
    IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityAccountManagementBulkAction.NAME);
    bulkAction.setIdentifiers(Sets.newHashSet(identity.getId()));
    bulkActionManager.processAction(bulkAction);
    // Account must exists now
    accountOne = accountService.getAccount(identity.getUsername(), systemOne.getId());
    Assert.assertNotNull(accountOne);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 44 with IdmBulkActionDto

use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.

the class AccountManagementTest method testRemoveIdentityAccountIfRoleSystemRemoved.

@Test
public void testRemoveIdentityAccountIfRoleSystemRemoved() {
    IdmRoleDto roleOne = getHelper().createRole();
    // create test system with mapping and link her to role
    SysSystemDto systemOne = getHelper().createTestResourceSystem(true);
    SysRoleSystemDto roleSystem = getHelper().createRoleSystem(roleOne, systemOne);
    IdmIdentityDto identity = getHelper().createIdentity();
    IdmRoleRequestDto roleRequestOne = getHelper().createRoleRequest(identity, roleOne);
    getHelper().executeRequest(roleRequestOne, false);
    // check after create
    List<IdmIdentityRoleDto> assignedRoles = identityRoleService.findAllByIdentity(identity.getId());
    Assert.assertEquals(1, assignedRoles.size());
    // check created account
    AccAccountDto accountOne = accountService.getAccount(identity.getUsername(), systemOne.getId());
    Assert.assertNotNull(accountOne);
    Assert.assertNotNull(getHelper().findResource(accountOne.getRealUid()));
    roleSystemService.delete(roleSystem);
    // Execute ACM and provisioning via bulk action
    IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityAccountManagementBulkAction.NAME);
    bulkAction.setIdentifiers(Sets.newHashSet(identity.getId()));
    bulkActionManager.processAction(bulkAction);
    // Account must not exist
    accountOne = accountService.getAccount(identity.getUsername(), systemOne.getId());
    Assert.assertNull(accountOne);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) SysRoleSystemDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmRoleRequestDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 45 with IdmBulkActionDto

use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.

the class ProvisioningOperationDeleteBulkActionIntegrationTest method testDeleteInvalidOperation.

@Test
public void testDeleteInvalidOperation() {
    SysSystemDto system = getHelper().createTestResourceSystem(false);
    SysProvisioningOperationDto operationOne = createOperation(system);
    // internal - broke referential integrity
    systemEntityService.deleteInternalById(operationOne.getSystemEntity());
    IdmBulkActionDto bulkAction = this.findBulkAction(SysProvisioningOperation.class, ProvisioningOperationDeleteBulkAction.NAME);
    bulkAction.setIdentifiers(ImmutableSet.of(operationOne.getId()));
    IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
    checkResultLrt(processAction, 1l, null, null);
}
Also used : IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) Test(org.junit.Test)

Aggregations

IdmBulkActionDto (eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto)262 Test (org.junit.Test)238 AbstractBulkActionTest (eu.bcvsolutions.idm.test.api.AbstractBulkActionTest)220 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)142 UUID (java.util.UUID)129 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)98 HashMap (java.util.HashMap)72 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)64 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)52 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)41 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)38 ResultModels (eu.bcvsolutions.idm.core.api.dto.ResultModels)35 HashSet (java.util.HashSet)33 List (java.util.List)29 Autowired (org.springframework.beans.factory.annotation.Autowired)26 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)24 After (org.junit.After)21 Assert (org.junit.Assert)21 Before (org.junit.Before)21 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)20