use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class IndexerHelper method indexEmbeddedFile.
File indexEmbeddedFile(String project, String docPath) throws IOException {
Path path = get(getClass().getResource(docPath).getPath());
Extractor extractor = new Extractor(new DocumentFactory().withIdentifier(new DigestIdentifier("SHA-384", Charset.defaultCharset())));
extractor.setDigester(new UpdatableDigester(project, Entity.HASHER.toString()));
TikaDocument document = extractor.extract(path);
ElasticsearchSpewer elasticsearchSpewer = new ElasticsearchSpewer(client, l -> ENGLISH, new FieldNames(), mock(Publisher.class), new PropertiesProvider()).withRefresh(IMMEDIATE).withIndex("test-datashare");
elasticsearchSpewer.write(document);
return path.toFile();
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class DocumentResourceTest method setUp.
@Before
public void setUp() {
initMocks(this);
configure(routes -> routes.add(new DocumentResource(repository, indexer)).filter(new LocalUserFilter(new PropertiesProvider())));
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class IndexResourceTest method test_no_auth_post_forward_request_to_elastic_with_body.
@Test
public void test_no_auth_post_forward_request_to_elastic_with_body() {
configure(routes -> routes.add(new IndexResource(indexer)).filter(new LocalUserFilter(new PropertiesProvider(new HashMap<String, String>() {
{
put("defaultUserName", "test");
}
}))));
post("/api/index/search/test-datashare/_search", "{}").should().respond(200).contain("\"successful\":1");
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class IndexResourceTest method test_no_auth_options_forward_request_to_elastic.
@Test
public void test_no_auth_options_forward_request_to_elastic() {
configure(routes -> routes.add(new IndexResource(indexer)).filter(new LocalUserFilter(new PropertiesProvider(new HashMap<String, String>() {
{
put("defaultUserName", "test");
}
}))));
options("/api/index/search/test-datashare").should().respond(200);
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class IndexResourceTest method test_no_auth_get_forward_request_to_elastic_if_granted_to_read_index.
@Test
public void test_no_auth_get_forward_request_to_elastic_if_granted_to_read_index() {
configure(routes -> routes.add(new IndexResource(indexer)).filter(new LocalUserFilter(new PropertiesProvider(new HashMap<String, String>() {
{
put("defaultUserName", "test");
}
}))));
get("/api/index/search/unauthorized/_search").should().respond(401);
}
Aggregations