use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class JobAuthorizationTest method testSetJobRetriesWithoutAuthorization.
// set job retries ////////////////////////////////////////////////
public void testSetJobRetriesWithoutAuthorization() {
// given
Job job = selectAnyJob();
String jobId = job.getId();
try {
// when
managementService.setJobRetries(jobId, 1);
fail("Exception expected: It should not be possible to set job retries");
} catch (AuthorizationException e) {
// then
String message = e.getMessage();
assertTextPresent(userId, message);
assertTextPresent(UPDATE.getName(), message);
assertTextPresent(PROCESS_INSTANCE.resourceName(), message);
assertTextPresent(UPDATE_INSTANCE.getName(), message);
assertTextPresent(job.getProcessDefinitionKey(), message);
assertTextPresent(PROCESS_DEFINITION.resourceName(), message);
}
}
use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class ProcessInstanceAuthorizationTest method testSuspendProcessInstanceByProcessDefinitionIdWithUpdatePermissionOnProcessInstance.
public void testSuspendProcessInstanceByProcessDefinitionIdWithUpdatePermissionOnProcessInstance() {
// given
ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
String processInstanceId = instance.getId();
String processDefinitionId = instance.getProcessDefinitionId();
createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE);
try {
// when
runtimeService.suspendProcessInstanceByProcessDefinitionId(processDefinitionId);
fail("Exception expected: It should not be posssible to suspend a process instance.");
} catch (AuthorizationException e) {
// then
String message = e.getMessage();
assertTextPresent(userId, message);
assertTextPresent(UPDATE_INSTANCE.getName(), message);
assertTextPresent(PROCESS_KEY, message);
assertTextPresent(PROCESS_DEFINITION.resourceName(), message);
}
}
use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class ProcessInstanceAuthorizationTest method testSuspendProcessInstanceByProcessDefinitionKeyWithUpdatePermissionOnProcessInstance.
public void testSuspendProcessInstanceByProcessDefinitionKeyWithUpdatePermissionOnProcessInstance() {
// given
ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
String processInstanceId = instance.getId();
createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE);
try {
// when
runtimeService.suspendProcessInstanceByProcessDefinitionKey(PROCESS_KEY);
fail("Exception expected: It should not be posssible to suspend a process instance.");
} catch (AuthorizationException e) {
// then
String message = e.getMessage();
assertTextPresent(userId, message);
assertTextPresent(UPDATE_INSTANCE.getName(), message);
assertTextPresent(PROCESS_KEY, message);
assertTextPresent(PROCESS_DEFINITION.resourceName(), message);
}
}
use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class ProcessInstanceAuthorizationTest method testActivateProcessInstanceByProcessDefinitionKeyWithUpdatePermissionOnProcessInstance.
public void testActivateProcessInstanceByProcessDefinitionKeyWithUpdatePermissionOnProcessInstance() {
// given
ProcessInstance instance = startProcessInstanceByKey(PROCESS_KEY);
String processInstanceId = instance.getId();
suspendProcessInstanceById(processInstanceId);
createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, UPDATE);
try {
// when
runtimeService.activateProcessInstanceByProcessDefinitionKey(PROCESS_KEY);
fail("Exception expected: It should not be posssible to suspend a process instance.");
} catch (AuthorizationException e) {
// then
String message = e.getMessage();
assertTextPresent(userId, message);
assertTextPresent(UPDATE_INSTANCE.getName(), message);
assertTextPresent(PROCESS_KEY, message);
assertTextPresent(PROCESS_DEFINITION.resourceName(), message);
}
}
use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class IdentityServiceAuthorizationsTest method testTenantUserMembershipCreateAuthorizations.
public void testTenantUserMembershipCreateAuthorizations() {
User jonny1 = identityService.newUser("jonny1");
identityService.saveUser(jonny1);
Tenant tenant1 = identityService.newTenant("tenant1");
identityService.saveTenant(tenant1);
// add base permission which allows nobody to create memberships
Authorization basePerms = authorizationService.createNewAuthorization(AUTH_TYPE_GLOBAL);
basePerms.setResource(TENANT_MEMBERSHIP);
basePerms.setResourceId(ANY);
// add all then remove 'create'
basePerms.addPermission(ALL);
basePerms.removePermission(CREATE);
authorizationService.saveAuthorization(basePerms);
processEngineConfiguration.setAuthorizationEnabled(true);
identityService.setAuthenticatedUserId(jonny2);
try {
identityService.createTenantUserMembership("tenant1", "jonny1");
fail("exception expected");
} catch (AuthorizationException e) {
assertEquals(1, e.getMissingAuthorizations().size());
MissingAuthorization info = e.getMissingAuthorizations().get(0);
assertEquals(jonny2, e.getUserId());
assertExceptionInfo(CREATE.getName(), TENANT_MEMBERSHIP.resourceName(), "tenant1", info);
}
}
Aggregations