Search in sources :

Example 6 with AuthorizationException

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

the class TaskRestServiceInteractionTest method testUnclaimTaskThrowsAuthorizationException.

@Test
public void testUnclaimTaskThrowsAuthorizationException() {
    String message = "expected exception";
    doThrow(new AuthorizationException(message)).when(taskServiceMock).setAssignee(anyString(), anyString());
    given().pathParam("id", EXAMPLE_TASK_ID).header("accept", MediaType.APPLICATION_JSON).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().post(UNCLAIM_TASK_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 7 with AuthorizationException

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

the class TaskRestServiceInteractionTest method testSetAssigneeThrowsAuthorizationException.

@Test
public void testSetAssigneeThrowsAuthorizationException() {
    String message = "expected exception";
    doThrow(new AuthorizationException(message)).when(taskServiceMock).setAssignee(anyString(), anyString());
    given().pathParam("id", EXAMPLE_TASK_ID).contentType(POST_JSON_CONTENT_TYPE).body(EMPTY_JSON_OBJECT).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().post(ASSIGNEE_TASK_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 8 with AuthorizationException

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

the class TenantRestServiceInteractionTest method saveTenantThrowsAuthorizationException.

@Test
public void saveTenantThrowsAuthorizationException() {
    Tenant newTenant = MockProvider.createMockTenant();
    when(identityServiceMock.newTenant(MockProvider.EXAMPLE_TENANT_ID)).thenReturn(newTenant);
    String message = "exception expected";
    doThrow(new AuthorizationException(message)).when(identityServiceMock).saveTenant(newTenant);
    given().body(TenantDto.fromTenant(newTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().post(TENANT_CREATE_URL);
}
Also used : Tenant(org.camunda.bpm.engine.identity.Tenant) AuthorizationException(org.camunda.bpm.engine.AuthorizationException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 9 with AuthorizationException

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

the class TenantRestServiceInteractionTest method createTenantUserMembershipThrowsAuthorizationException.

@Test
public void createTenantUserMembershipThrowsAuthorizationException() {
    String message = "expected exception";
    doThrow(new AuthorizationException(message)).when(identityServiceMock).createTenantUserMembership(MockProvider.EXAMPLE_TENANT_ID, MockProvider.EXAMPLE_USER_ID);
    given().pathParam("id", MockProvider.EXAMPLE_TENANT_ID).pathParam("userId", MockProvider.EXAMPLE_USER_ID).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().put(TENANT_USER_MEMBER_URL);
}
Also used : AuthorizationException(org.camunda.bpm.engine.AuthorizationException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 10 with AuthorizationException

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

the class TenantRestServiceInteractionTest method updateTenantThrowsAuthorizationException.

@Test
public void updateTenantThrowsAuthorizationException() {
    Tenant updatedTenant = MockProvider.createMockTenant();
    when(updatedTenant.getName()).thenReturn("updatedName");
    String message = "exception expected";
    doThrow(new AuthorizationException(message)).when(identityServiceMock).saveTenant(any(Tenant.class));
    given().pathParam("id", MockProvider.EXAMPLE_TENANT_ID).body(TenantDto.fromTenant(updatedTenant)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().put(TENANT_URL);
}
Also used : Tenant(org.camunda.bpm.engine.identity.Tenant) AuthorizationException(org.camunda.bpm.engine.AuthorizationException) 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