use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class RootResourcePluginTest method test_invalid_folder_should_throw_error.
@Test
public void test_invalid_folder_should_throw_error() {
server.configure(routes -> routes.add(new RootResource(new PropertiesProvider(new HashMap<String, String>() {
{
put("pluginsDir", "unknown");
}
}))));
get("/").should().respond(500);
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class SettingsResourceTest method test_patch_configuration_should_answer_403_in_server_mode.
@Test
public void test_patch_configuration_should_answer_403_in_server_mode() {
PropertiesProvider properties = new PropertiesProvider(new HashMap<String, String>() {
{
put("mode", "SERVER");
}
});
configure(routes -> routes.add(new SettingsResource(properties)).filter(new BasicAuthFilter("/", "icij", singleUser(local()))));
patch("/api/settings", "{\"data\": {\"foo\": \"qux\", \"xyzzy\":\"fred\"}}").withPreemptiveAuthentication("local", "pass").should().respond(403);
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class TaskResourceTest method test_index_and_scan_default_directory.
@Test
public void test_index_and_scan_default_directory() {
RestAssert response = post("/api/task/batchUpdate/index/file", "{}");
HashMap<String, String> properties = getDefaultProperties();
properties.put("foo", "bar");
response.should().respond(200).haveType("application/json");
verify(taskFactory).createScanTask(local(), "extract:queue", Paths.get("/default/data/dir"), new PropertiesProvider(properties).getProperties());
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class TaskResourceTest method test_index_queue_with_options.
@Test
public void test_index_queue_with_options() {
RestAssert response = post("/api/task/batchUpdate/index", "{\"options\":{\"key1\":\"val1\",\"key2\":\"val2\"}}");
response.should().haveType("application/json");
verify(taskFactory).createIndexTask(local(), "extract:queue", new PropertiesProvider(new HashMap<String, String>() {
{
put("key1", "val1");
put("key2", "val2");
}
}).getProperties());
verify(taskFactory, never()).createScanTask(eq(local()), eq("extract:queue"), any(Path.class), any(Properties.class));
}
use of org.icij.datashare.PropertiesProvider in project datashare by ICIJ.
the class TaskResourceTest method test_scan_with_options.
@Test
public void test_scan_with_options() {
String path = getClass().getResource("/docs/").getPath();
RestAssert response = post("/api/task/batchUpdate/scan/" + path.substring(1), "{\"options\":{\"key\":\"val\",\"foo\":\"qux\"}}");
ShouldChain responseBody = response.should().haveType("application/json");
List<String> taskNames = taskManager.waitTasksToBeDone(1, SECONDS).stream().map(t -> t.name).collect(toList());
assertThat(taskNames.size()).isEqualTo(1);
responseBody.should().contain(format("{\"name\":\"%s\"", taskNames.get(0)));
HashMap<String, String> defaultProperties = getDefaultProperties();
defaultProperties.put("key", "val");
defaultProperties.put("foo", "qux");
verify(taskFactory).createScanTask(local(), "extract:queue", Paths.get(path), new PropertiesProvider(defaultProperties).getProperties());
verify(taskFactory, never()).createIndexTask(any(User.class), anyString(), any(Properties.class));
}
Aggregations