use of eu.bcvsolutions.idm.core.api.exception.ForbiddenEntityException in project CzechIdMng by bcvsolutions.
the class IdentityDisableBulkActionTest method checkEvaluatorForLrt.
@Test
public void checkEvaluatorForLrt() {
IdmIdentityDto identity = getHelper().createIdentity();
IdmRoleDto createRole = getHelper().createRole();
getHelper().createBasePolicy(createRole.getId(), CoreGroupPermission.IDENTITY, IdmIdentity.class, IdmBasePermission.READ, IdentityBasePermission.MANUALLYDISABLE);
getHelper().createIdentityRole(identity, createRole);
loginAsNoAdmin(identity.getUsername());
IdmBulkActionDto bulkAction = this.findBulkAction(IdmIdentity.class, IdentityDisableBulkAction.NAME);
Set<UUID> ids = this.getIdFromList(this.createIdentities(5));
bulkAction.setIdentifiers(ids);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
IdmLongRunningTaskDto lrt = checkResultLrt(processAction, 5l, null, null);
try {
longRunningTaskService.get(lrt.getId(), IdmBasePermission.READ);
fail("User hasn't permission for read the long running task.");
} catch (ForbiddenEntityException ex) {
assertTrue(ex.getMessage().contains(lrt.getId().toString()));
assertTrue(ex.getMessage().contains(IdmBasePermission.READ.toString()));
} catch (Exception ex) {
fail("Bad exception: " + ex.getMessage());
}
// create authorization with SelfLongRunningTaskEvaluator
getHelper().createAuthorizationPolicy(createRole.getId(), CoreGroupPermission.SCHEDULER, IdmLongRunningTask.class, SelfLongRunningTaskEvaluator.class, IdmBasePermission.READ);
try {
IdmLongRunningTaskDto longRunningTaskDto = longRunningTaskService.get(lrt.getId(), IdmBasePermission.READ);
assertNotNull(longRunningTaskDto);
assertEquals(lrt, longRunningTaskDto);
} catch (ForbiddenEntityException ex) {
fail("User has permission for read the long running task. " + ex.getMessage());
} catch (Exception ex) {
fail("Bad exception: " + ex.getMessage());
}
}
Aggregations