use of org.graylog.plugins.views.search.errors.PermissionException in project graylog2-server by Graylog2.
the class PermissionExceptionMapperTest method responseHasStatus403.
@Test
public void responseHasStatus403() {
Response response = sut.toResponse(new PermissionException(""));
assertThat(response.getStatus()).isEqualTo(403);
}
use of org.graylog.plugins.views.search.errors.PermissionException in project graylog2-server by Graylog2.
the class PermissionExceptionMapperTest method responseHasMessageFromException.
@Test
public void responseHasMessageFromException() {
PermissionException exception = new PermissionException("a message to you rudy");
Response response = sut.toResponse(exception);
assertThat(((ApiError) response.getEntity()).message()).isEqualTo(exception.getMessage());
}
use of org.graylog.plugins.views.search.errors.PermissionException in project graylog2-server by Graylog2.
the class MessagesResourceTest method checksStreamPermissionsForPlainRequest.
@Test
void checksStreamPermissionsForPlainRequest() {
final SearchUser searchUser = TestSearchUser.builder().denyStream("stream-1").build();
MessagesRequest request = validRequest().toBuilder().streams(ImmutableSet.of("stream-1")).build();
PermissionException exception = new PermissionException("The wurst is yet to come");
doThrow(exception).when(executionGuard).checkUserIsPermittedToSeeStreams(eq(ImmutableSet.of("stream-1")), any());
assertThatExceptionOfType(PermissionException.class).isThrownBy(() -> sut.retrieve(request, searchUser)).withMessageContaining(exception.getMessage());
}
Aggregations