use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class ExternalTaskRestServiceInteractionTest method testGetErrorDetailsThrowsAuthorizationException.
@Test
public void testGetErrorDetailsThrowsAuthorizationException() {
doThrow(new AuthorizationException("aMessage")).when(externalTaskService).getExternalTaskErrorDetails(any(String.class));
given().pathParam("id", "anExternalTaskId").then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo("aMessage")).when().get(GET_EXTERNAL_TASK_ERROR_DETAILS_URL);
verify(externalTaskService).getExternalTaskErrorDetails("anExternalTaskId");
verifyNoMoreInteractions(externalTaskService);
}
use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class GroupRestServiceInteractionTest method testDeleteGroupThrowsAuthorizationException.
@Test
public void testDeleteGroupThrowsAuthorizationException() {
String message = "expected exception";
doThrow(new AuthorizationException(message)).when(identityServiceMock).deleteGroup(MockProvider.EXAMPLE_GROUP_ID);
given().pathParam("id", MockProvider.EXAMPLE_GROUP_ID).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().delete(GROUP_URL);
}
use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class GroupRestServiceInteractionTest method testUpdateGroupThrowsAuthorizationException.
@Test
public void testUpdateGroupThrowsAuthorizationException() {
Group initialGroup = MockProvider.createMockGroup();
Group groupUpdate = MockProvider.createMockGroupUpdate();
GroupQuery sampleGroupQuery = mock(GroupQuery.class);
when(identityServiceMock.createGroupQuery()).thenReturn(sampleGroupQuery);
when(sampleGroupQuery.groupId(MockProvider.EXAMPLE_GROUP_ID)).thenReturn(sampleGroupQuery);
when(sampleGroupQuery.singleResult()).thenReturn(initialGroup);
String message = "exception expected";
doThrow(new AuthorizationException(message)).when(identityServiceMock).saveGroup(any(Group.class));
given().pathParam("id", MockProvider.EXAMPLE_GROUP_ID).body(GroupDto.fromGroup(groupUpdate)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().put(GROUP_URL);
// initial group was updated
verify(initialGroup).setName(groupUpdate.getName());
}
use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class GroupRestServiceInteractionTest method testDeleteGroupMemberThrowsAuthorizationException.
@Test
public void testDeleteGroupMemberThrowsAuthorizationException() {
String message = "expected exception";
doThrow(new AuthorizationException(message)).when(identityServiceMock).deleteMembership(MockProvider.EXAMPLE_USER_ID, MockProvider.EXAMPLE_GROUP_ID);
given().pathParam("id", MockProvider.EXAMPLE_GROUP_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().delete(GROUP_MEMBER_URL);
}
use of org.camunda.bpm.engine.AuthorizationException in project camunda-bpm-platform by camunda.
the class GroupRestServiceInteractionTest method testSaveGroupThrowsAuthorizationException.
@Test
public void testSaveGroupThrowsAuthorizationException() {
Group newGroup = MockProvider.createMockGroup();
String message = "exception expected";
when(identityServiceMock.newGroup(newGroup.getId())).thenReturn(newGroup);
doThrow(new AuthorizationException(message)).when(identityServiceMock).saveGroup(newGroup);
given().body(GroupDto.fromGroup(newGroup)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.getStatusCode()).contentType(ContentType.JSON).body("type", equalTo(AuthorizationException.class.getSimpleName())).body("message", equalTo(message)).when().post(GROUP_CREATE_URL);
}
Aggregations