use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityAddRoleBulkActionIntegrationTest method processBulkActionWithoutPermission.
@Test
public void processBulkActionWithoutPermission() {
// user hasn't permission for change permission identity
IdmIdentityDto identityForLogin = getHelper().createIdentity();
IdmRoleDto permissionRole = getHelper().createRole();
getHelper().createBasePolicy(permissionRole.getId(), CoreGroupPermission.IDENTITY, IdmIdentity.class, IdmBasePermission.READ);
getHelper().createBasePolicy(permissionRole.getId(), CoreGroupPermission.IDENTITYCONTRACT, IdmIdentityContract.class, IdmBasePermission.AUTOCOMPLETE);
getHelper().createIdentityRole(identityForLogin, permissionRole);
loginAsNoAdmin(identityForLogin.getUsername());
IdmRoleDto createRole = getHelper().createRole();
List<IdmIdentityDto> identities = this.createIdentities(5);
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityAddRoleBulkAction.NAME);
Set<UUID> ids = this.getIdFromList(identities);
bulkAction.setIdentifiers(this.getIdFromList(identities));
Map<String, Object> properties = new HashMap<>();
properties.put(IdentityAddRoleBulkAction.ROLE_CODE, Lists.newArrayList(createRole.getId().toString()));
properties.put(IdentityAddRoleBulkAction.PRIMARY_CONTRACT_CODE, Boolean.TRUE);
properties.put(IdentityAddRoleBulkAction.APPROVE_CODE, Boolean.FALSE);
bulkAction.setProperties(properties);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 0l, 0l, 5l);
for (UUID id : ids) {
IdmIdentityDto identity = identityService.get(id);
List<IdmIdentityContractDto> contracts = identityContractService.findAllByIdentity(identity.getId());
assertEquals(1, contracts.size());
IdmIdentityContractDto contract = contracts.get(0);
List<IdmIdentityRoleDto> identityRoles = identityRoleService.findAllByContract(contract.getId());
assertTrue(identityRoles.isEmpty());
}
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityDeleteBulkActionIntegrationTest method testProcessBulkActionByFilterWithRemove.
@Test
public void testProcessBulkActionByFilterWithRemove() {
String testLastName = "bulkActionLastName" + System.currentTimeMillis();
List<IdmIdentityDto> identities = this.createIdentities(5);
IdmIdentityDto removedIdentity = identities.get(0);
IdmIdentityDto removedIdentity2 = identities.get(1);
for (IdmIdentityDto identity : identities) {
identity.setLastName(testLastName);
identity = identityService.save(identity);
assertTrue(identity.getState() != IdentityState.DISABLED_MANUALLY);
}
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setLastName(testLastName);
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityDeleteBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
bulkAction.setRemoveIdentifiers(Sets.newHashSet(removedIdentity.getId(), removedIdentity2.getId()));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 3l, null, null);
Set<UUID> ids = getIdFromList(identities);
for (UUID id : ids) {
IdmIdentityDto dto = identityService.get(id);
if (id.equals(removedIdentity.getId()) || id.equals(removedIdentity2.getId())) {
assertNotNull(dto);
continue;
}
assertNull(dto);
}
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityEnableBulkActionTest method processBulkActionWithoutPermission.
@Test
public void processBulkActionWithoutPermission() {
// user hasn't permission for update identity
IdmIdentityDto adminIdentity = this.createUserWithAuthorities(IdmBasePermission.READ);
loginAsNoAdmin(adminIdentity.getUsername());
List<IdmIdentityDto> identities = this.createIdentities(5);
for (IdmIdentityDto identity : identities) {
identity = identityService.disable(identity.getId());
assertTrue(identity.getState() == IdentityState.DISABLED_MANUALLY);
}
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityEnableBulkAction.NAME);
Set<UUID> ids = this.getIdFromList(identities);
bulkAction.setIdentifiers(this.getIdFromList(identities));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 0l, 0l, 5l);
for (UUID id : ids) {
IdmIdentityDto identityDto = identityService.get(id);
assertNotNull(identityDto);
assertTrue(identityDto.getState() == IdentityState.DISABLED_MANUALLY);
}
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityEnableBulkActionTest method processBulkActionByFilter.
@Test
public void processBulkActionByFilter() {
String testFirstName = "bulkActionFirstName" + System.currentTimeMillis();
List<IdmIdentityDto> identities = this.createIdentities(5);
for (IdmIdentityDto identity : identities) {
identity.setFirstName(testFirstName);
identity = identityService.save(identity);
identity = identityService.disable(identity.getId());
assertTrue(identity.getState() == IdentityState.DISABLED_MANUALLY);
}
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setFirstName(testFirstName);
List<IdmIdentityDto> checkIdentities = identityService.find(filter, null).getContent();
assertEquals(5, checkIdentities.size());
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityEnableBulkAction.NAME);
bulkAction.setTransformedFilter(filter);
bulkAction.setFilter(toMap(filter));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 5l, null, null);
for (IdmIdentityDto identity : identities) {
IdmIdentityDto dto = identityService.get(identity.getId());
assertNotNull(dto);
assertTrue(dto.getState() == IdentityState.VALID);
}
}
use of eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto in project CzechIdMng by bcvsolutions.
the class IdentityEnableBulkActionTest method processBulkActionByIds.
@Test
public void processBulkActionByIds() {
List<IdmIdentityDto> identities = this.createIdentities(5);
for (IdmIdentityDto identity : identities) {
identity.setState(IdentityState.DISABLED_MANUALLY);
identity = identityService.save(identity);
assertTrue(identity.getState() == IdentityState.DISABLED_MANUALLY);
}
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityEnableBulkAction.NAME);
Set<UUID> ids = this.getIdFromList(identities);
bulkAction.setIdentifiers(this.getIdFromList(identities));
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 5l, null, null);
for (UUID id : ids) {
IdmIdentityDto identityDto = identityService.get(id);
assertNotNull(identityDto);
assertTrue(identityDto.getState() == IdentityState.VALID);
}
}
Aggregations