Search in sources :

Example 26 with SearchUser

use of org.graylog.plugins.views.search.permissions.SearchUser in project graylog2-server by Graylog2.

the class SearchDomainTest method saveAddsOwnerToSearch.

@Test
public void saveAddsOwnerToSearch() {
    final Search search = mockSearchWithOwner(null);
    final SearchUser searchUser = mock(SearchUser.class);
    when(searchUser.username()).thenReturn("eberhard");
    when(searchUser.isAdmin()).thenReturn(true);
    sut.saveForUser(search, searchUser);
    final ArgumentCaptor<Search> savedCaptor = ArgumentCaptor.forClass(Search.class);
    verify(dbService, times(1)).save(savedCaptor.capture());
    final Search result = savedCaptor.getValue();
    assertThat(result.owner()).contains("eberhard");
}
Also used : SearchUser(org.graylog.plugins.views.search.permissions.SearchUser) Test(org.junit.Test)

Aggregations

SearchUser (org.graylog.plugins.views.search.permissions.SearchUser)26 Test (org.junit.Test)19 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 ForbiddenException (javax.ws.rs.ForbiddenException)4 Search (org.graylog.plugins.views.search.Search)4 RestResourceBaseTest (org.graylog2.rest.resources.RestResourceBaseTest)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 ApiOperation (io.swagger.annotations.ApiOperation)3 Collection (java.util.Collection)3 POST (javax.ws.rs.POST)3 ViewDTO (org.graylog.plugins.views.search.views.ViewDTO)3 RelativeRange (org.graylog2.plugin.indexer.searches.timeranges.RelativeRange)3 Test (org.junit.jupiter.api.Test)3 Api (io.swagger.annotations.Api)2 ApiParam (io.swagger.annotations.ApiParam)2 Collections (java.util.Collections)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Assertions.assertThatExceptionOfType (org.assertj.core.api.Assertions.assertThatExceptionOfType)2 AuditEvent (org.graylog2.audit.jersey.AuditEvent)2