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;
}
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());
}
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);
}
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);
}
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);
}
Aggregations