Search in sources :

Example 1 with PermissionException

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);
}
Also used : Response(javax.ws.rs.core.Response) PermissionException(org.graylog.plugins.views.search.errors.PermissionException) Test(org.junit.Test)

Example 2 with PermissionException

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());
}
Also used : PermissionException(org.graylog.plugins.views.search.errors.PermissionException) Response(javax.ws.rs.core.Response) ApiError(org.graylog2.plugin.rest.ApiError) Test(org.junit.Test)

Example 3 with PermissionException

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());
}
Also used : PermissionException(org.graylog.plugins.views.search.errors.PermissionException) MessagesRequest(org.graylog.plugins.views.search.export.MessagesRequest) SearchUser(org.graylog.plugins.views.search.permissions.SearchUser) Test(org.junit.jupiter.api.Test)

Aggregations

PermissionException (org.graylog.plugins.views.search.errors.PermissionException)3 Response (javax.ws.rs.core.Response)2 Test (org.junit.Test)2 MessagesRequest (org.graylog.plugins.views.search.export.MessagesRequest)1 SearchUser (org.graylog.plugins.views.search.permissions.SearchUser)1 ApiError (org.graylog2.plugin.rest.ApiError)1 Test (org.junit.jupiter.api.Test)1