Search in sources :

Example 6 with LocalUserFilter

use of org.icij.datashare.session.LocalUserFilter in project datashare by ICIJ.

the class BatchSearchResourceTest method setUp.

@Before
public void setUp() {
    initMocks(this);
    configure(routes -> routes.add(new BatchSearchResource(batchSearchRepository, batchSearchQueue, new PropertiesProvider())).filter(new LocalUserFilter(new PropertiesProvider())));
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) LocalUserFilter(org.icij.datashare.session.LocalUserFilter) Before(org.junit.Before)

Example 7 with LocalUserFilter

use of org.icij.datashare.session.LocalUserFilter in project datashare by ICIJ.

the class UserResourceTest method setUp.

@Before
public void setUp() {
    initMocks(this);
    configure(routes -> routes.add(new UserResource(repository)).filter(new LocalUserFilter(new PropertiesProvider())));
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) LocalUserFilter(org.icij.datashare.session.LocalUserFilter) Before(org.junit.Before)

Example 8 with LocalUserFilter

use of org.icij.datashare.session.LocalUserFilter in project datashare by ICIJ.

the class ApiKeyResourceTest method setUp.

@Before
public void setUp() {
    initMocks(this);
    configure(routes -> routes.add(new ApiKeyResource(taskFactory)).filter(new LocalUserFilter(new PropertiesProvider())));
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) LocalUserFilter(org.icij.datashare.session.LocalUserFilter) Before(org.junit.Before)

Example 9 with LocalUserFilter

use of org.icij.datashare.session.LocalUserFilter in project datashare by ICIJ.

the class RootResourcePluginTest method setUp.

@Before
public void setUp() {
    propertiesProvider = new PropertiesProvider(new HashMap<String, String>() {

        {
            put("pluginsDir", folder.getRoot().toString());
        }
    });
    server.configure(routes -> routes.add(new RootResource(propertiesProvider)).bind("/plugins", folder.getRoot()).filter(new LocalUserFilter(new PropertiesProvider())));
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) LocalUserFilter(org.icij.datashare.session.LocalUserFilter) HashMap(java.util.HashMap)

Example 10 with LocalUserFilter

use of org.icij.datashare.session.LocalUserFilter in project datashare by ICIJ.

the class BatchSearchResourceTest method test_get_search_results_csv_with_url_prefix_parameter.

@Test
public void test_get_search_results_csv_with_url_prefix_parameter() {
    server.configure(routes -> {
        PropertiesProvider propertiesProvider = new PropertiesProvider(new HashMap<String, String>() {

            {
                put("rootHost", "http://foo.com:12345");
            }
        });
        routes.add(new BatchSearchResource(batchSearchRepository, batchSearchQueue, propertiesProvider)).filter(new LocalUserFilter(propertiesProvider));
    });
    when(batchSearchRepository.get(User.local(), "batchSearchId")).thenReturn(new BatchSearch(project("prj"), "name", "desc", asSet("q"), User.local()));
    when(batchSearchRepository.getResults(User.local(), "batchSearchId", new BatchSearchRepository.WebQuery())).thenReturn(singletonList(new SearchResult("q", "docId", "rootId", Paths.get("/path/to/doc"), new Date(), "content/type", 123L, 1)));
    get("/api/batch/search/result/csv/batchSearchId").should().respond(200).haveType("text/csv").haveHeader("Content-Disposition", "attachment;filename=\"batchSearchId.csv\"").contain("\"http://foo.com:12345/#/d/prj/docId/rootId\",\"docId\",\"rootId\"");
}
Also used : PropertiesProvider(org.icij.datashare.PropertiesProvider) LocalUserFilter(org.icij.datashare.session.LocalUserFilter) BatchSearch(org.icij.datashare.batch.BatchSearch) JooqBatchSearchRepository(org.icij.datashare.db.JooqBatchSearchRepository) BatchSearchRepository(org.icij.datashare.batch.BatchSearchRepository) SearchResult(org.icij.datashare.batch.SearchResult) AbstractProdWebServerTest(org.icij.datashare.web.testhelpers.AbstractProdWebServerTest) Test(org.junit.Test)

Aggregations

PropertiesProvider (org.icij.datashare.PropertiesProvider)12 LocalUserFilter (org.icij.datashare.session.LocalUserFilter)12 Before (org.junit.Before)6 HashMap (java.util.HashMap)5 AbstractProdWebServerTest (org.icij.datashare.web.testhelpers.AbstractProdWebServerTest)5 Test (org.junit.Test)5 BatchSearch (org.icij.datashare.batch.BatchSearch)1 BatchSearchRepository (org.icij.datashare.batch.BatchSearchRepository)1 SearchResult (org.icij.datashare.batch.SearchResult)1 JooqBatchSearchRepository (org.icij.datashare.db.JooqBatchSearchRepository)1