Search in sources :

Example 61 with AuthorizationException

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

the class ExecutionRestServiceInteractionTest method testDeleteLocalVariableThrowsAuthorizationException.

@Test
public void testDeleteLocalVariableThrowsAuthorizationException() {
    String variableKey = "aVariableKey";
    String message = "expected exception";
    doThrow(new AuthorizationException(message)).when(runtimeServiceMock).removeVariableLocal(anyString(), anyString());
    given().pathParam("id", MockProvider.EXAMPLE_EXECUTION_ID).pathParam("varId", variableKey).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", is(AuthorizationException.class.getSimpleName())).body("message", is(message)).when().delete(SINGLE_EXECUTION_LOCAL_VARIABLE_URL);
}
Also used : AuthorizationException(org.camunda.bpm.engine.AuthorizationException) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 62 with AuthorizationException

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

the class ExternalTaskRestServiceInteractionTest method testSetRetriesThrowsAuthorizationException.

@Test
public void testSetRetriesThrowsAuthorizationException() {
    doThrow(new AuthorizationException("aMessage")).when(externalTaskService).setRetries(any(String.class), anyInt());
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("retries", "5");
    given().contentType(POST_JSON_CONTENT_TYPE).body(parameters).pathParam("id", "anExternalTaskId").then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo("aMessage")).when().put(RETRIES_EXTERNAL_TASK_URL);
}
Also used : AuthorizationException(org.camunda.bpm.engine.AuthorizationException) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 63 with AuthorizationException

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

the class ExternalTaskRestServiceInteractionTest method testUnlockThrowsAuthorizationException.

@Test
public void testUnlockThrowsAuthorizationException() {
    doThrow(new AuthorizationException("aMessage")).when(externalTaskService).unlock(any(String.class));
    given().pathParam("id", "anExternalTaskId").then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo("aMessage")).when().post(UNLOCK_EXTERNAL_TASK_URL);
    verify(externalTaskService).unlock("anExternalTaskId");
    verifyNoMoreInteractions(externalTaskService);
}
Also used : AuthorizationException(org.camunda.bpm.engine.AuthorizationException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 64 with AuthorizationException

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

the class ExternalTaskRestServiceInteractionTest method testHandleBpmnErrorThrowsAuthorizationException.

@Test
public void testHandleBpmnErrorThrowsAuthorizationException() {
    doThrow(new AuthorizationException("aMessage")).when(externalTaskService).handleBpmnError(any(String.class), any(String.class), any(String.class));
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("workerId", "aWorkerId");
    parameters.put("errorCode", "errorCode");
    given().contentType(POST_JSON_CONTENT_TYPE).body(parameters).pathParam("id", "anExternalTaskId").then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo("aMessage")).when().post(HANDLE_EXTERNAL_TASK_BPMN_ERROR_URL);
}
Also used : AuthorizationException(org.camunda.bpm.engine.AuthorizationException) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 65 with AuthorizationException

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

the class ExternalTaskRestServiceInteractionTest method testSetPriorityThrowsAuthorizationException.

@Test
public void testSetPriorityThrowsAuthorizationException() {
    doThrow(new AuthorizationException("aMessage")).when(externalTaskService).setPriority(any(String.class), anyInt());
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("priority", "5");
    given().contentType(POST_JSON_CONTENT_TYPE).body(parameters).pathParam("id", "anExternalTaskId").then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo("aMessage")).when().put(PRIORITY_EXTERNAL_TASK_URL);
}
Also used : AuthorizationException(org.camunda.bpm.engine.AuthorizationException) HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

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