Search in sources :

Example 86 with AuthorizationException

use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.

the class FilterAuthorizationsTest method testSaveFilterNotPermitted.

public void testSaveFilterNotPermitted() {
    Filter filter = new FilterEntity(EntityTypes.TASK);
    try {
        filterService.saveFilter(filter);
        fail("Exception expected");
    } catch (AuthorizationException e) {
    // expected
    }
}
Also used : Filter(org.camunda.bpm.engine.filter.Filter) FilterEntity(org.camunda.bpm.engine.impl.persistence.entity.FilterEntity) AuthorizationException(org.camunda.bpm.engine.AuthorizationException)

Example 87 with AuthorizationException

use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.

the class FilterAuthorizationsTest method testDeleteFilterNotPermitted.

public void testDeleteFilterNotPermitted() {
    Filter filter = createTestFilter();
    try {
        filterService.deleteFilter(filter.getId());
        fail("Exception expected");
    } catch (AuthorizationException e) {
    // expected
    }
}
Also used : Filter(org.camunda.bpm.engine.filter.Filter) AuthorizationException(org.camunda.bpm.engine.AuthorizationException)

Example 88 with AuthorizationException

use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.

the class TaskAuthorizationTest method testSaveTaskInsertWithoutAuthorization.

// save task (insert) //////////////////////////////////////////////////////////
public void testSaveTaskInsertWithoutAuthorization() {
    // given
    TaskEntity task = TaskEntity.create();
    try {
        // when
        taskService.saveTask(task);
        fail("Exception expected: It should not be possible to save a task.");
    } catch (AuthorizationException e) {
        // then
        assertTextPresent("The user with id 'test' does not have 'CREATE' permission on resource 'Task'", e.getMessage());
    }
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) AuthorizationException(org.camunda.bpm.engine.AuthorizationException)

Example 89 with AuthorizationException

use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.

the class HistoricDecisionInstanceAuthorizationTest method testDeleteHistoricDecisionInstanceByInstanceIdWithoutAuthorization.

public void testDeleteHistoricDecisionInstanceByInstanceIdWithoutAuthorization() {
    // given
    createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, READ_HISTORY);
    startProcessInstanceAndEvaluateDecision();
    HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
    HistoricDecisionInstance historicDecisionInstance = query.includeInputs().includeOutputs().singleResult();
    try {
        // when
        historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.getId());
        fail("expect authorization exception");
    } catch (AuthorizationException e) {
        // then
        assertThat(e.getMessage(), is("The user with id 'test' does not have 'DELETE_HISTORY' permission on resource 'testDecision' of type 'DecisionDefinition'."));
    }
}
Also used : AuthorizationException(org.camunda.bpm.engine.AuthorizationException) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)

Example 90 with AuthorizationException

use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.

the class HistoricProcessInstanceAuthorizationTest method testReportWithQueryCriterionProcessDefinitionKeyInAndMissingReadHistoryPermission.

public void testReportWithQueryCriterionProcessDefinitionKeyInAndMissingReadHistoryPermission() {
    // given
    ProcessInstance processInstance1 = startProcessInstanceByKey(PROCESS_KEY);
    ProcessInstance processInstance2 = startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY);
    disableAuthorization();
    runtimeService.deleteProcessInstance(processInstance1.getProcessInstanceId(), "");
    runtimeService.deleteProcessInstance(processInstance2.getProcessInstanceId(), "");
    enableAuthorization();
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, READ_HISTORY);
    // when
    try {
        historyService.createHistoricProcessInstanceReport().processDefinitionKeyIn(PROCESS_KEY, MESSAGE_START_PROCESS_KEY).duration(PeriodUnit.MONTH);
        // then
        fail("Exception expected: It should not be possible to create a historic process instance report");
    } catch (AuthorizationException e) {
    }
}
Also used : AuthorizationException(org.camunda.bpm.engine.AuthorizationException) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance)

Aggregations

AuthorizationException (org.camunda.bpm.engine.AuthorizationException)213 Test (org.junit.Test)142 Matchers.anyString (org.mockito.Matchers.anyString)116 Matchers.containsString (org.hamcrest.Matchers.containsString)55 HashMap (java.util.HashMap)50 Authorization (org.camunda.bpm.engine.authorization.Authorization)22 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)21 MissingAuthorization (org.camunda.bpm.engine.authorization.MissingAuthorization)21 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)20 RestException (org.camunda.bpm.engine.rest.exception.RestException)14 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)13 User (org.camunda.bpm.engine.identity.User)12 Group (org.camunda.bpm.engine.identity.Group)10 Tenant (org.camunda.bpm.engine.identity.Tenant)10 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)10 ArrayList (java.util.ArrayList)8 LinkedHashMap (java.util.LinkedHashMap)7 Map (java.util.Map)7 ExampleVariableObject (org.camunda.bpm.engine.rest.helper.ExampleVariableObject)7 ManagementService (org.camunda.bpm.engine.ManagementService)6