Search in sources :

Example 46 with AuthorizationException

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

the class TaskVariableRestResourceInteractionTest method testGetSingleVariableThrowsAuthorizationException.

@Test
public void testGetSingleVariableThrowsAuthorizationException() {
    String variableKey = "aVariableKey";
    String message = "excpected exception";
    when(taskServiceMock.getVariableTyped(anyString(), anyString(), anyBoolean())).thenThrow(new AuthorizationException(message));
    given().pathParam("id", EXAMPLE_TASK_ID).pathParam("varId", variableKey).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).body("type", is(AuthorizationException.class.getSimpleName())).body("message", is(message)).when().get(SINGLE_TASK_SINGLE_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 47 with AuthorizationException

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

the class TaskVariableRestResourceInteractionTest method testPutSingleVariableThrowsAuthorizationException.

@Test
public void testPutSingleVariableThrowsAuthorizationException() {
    String variableKey = "aVariableKey";
    String variableValue = "1abc";
    String type = "String";
    Map<String, Object> variableJson = VariablesBuilder.getVariableValueMap(variableValue, type);
    String message = "expected exception";
    doThrow(new AuthorizationException(message)).when(taskServiceMock).setVariable(anyString(), anyString(), any());
    given().pathParam("id", EXAMPLE_TASK_ID).pathParam("varId", variableKey).contentType(ContentType.JSON).body(variableJson).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().put(SINGLE_TASK_PUT_SINGLE_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 48 with AuthorizationException

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

the class TaskVariableRestResourceInteractionTest method testPutSingleBinaryVariableThrowsAuthorizationException.

@Test
public void testPutSingleBinaryVariableThrowsAuthorizationException() {
    byte[] bytes = "someContent".getBytes();
    String variableKey = "aVariableKey";
    String message = "expected exception";
    doThrow(new AuthorizationException(message)).when(taskServiceMock).setVariable(anyString(), anyString(), any());
    given().pathParam("id", EXAMPLE_TASK_ID).pathParam("varId", variableKey).multiPart("data", "unspecified", bytes).expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().post(SINGLE_TASK_SINGLE_BINARY_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 49 with AuthorizationException

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

the class CleanableHistoricBatchReportServiceTest method testMissingAuthorization.

@Test
public void testMissingAuthorization() {
    String message = "not authorized";
    when(historicBatchReport.list()).thenThrow(new AuthorizationException(message));
    given().then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().get(HISTORIC_REPORT_URL);
}
Also used : AuthorizationException(org.camunda.bpm.engine.AuthorizationException) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

Example 50 with AuthorizationException

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

the class CleanableHistoricDecisionInstanceReportServiceTest method testMissingAuthorization.

@Test
public void testMissingAuthorization() {
    String message = "not authorized";
    when(historicDecisionInstanceReport.list()).thenThrow(new AuthorizationException(message));
    given().then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().get(HISTORIC_REPORT_URL);
}
Also used : AuthorizationException(org.camunda.bpm.engine.AuthorizationException) Matchers.anyString(org.mockito.Matchers.anyString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test) AbstractRestServiceTest(org.camunda.bpm.engine.rest.AbstractRestServiceTest)

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