use of net.codestory.http.filters.basic.BasicAuthFilter 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 net.codestory.http.filters.basic.BasicAuthFilter in project datashare by ICIJ.
the class UserTaskResourceTest method setupAppWith.
private void setupAppWith(String... userLogins) {
final PropertiesProvider propertiesProvider = new PropertiesProvider();
taskManager = new TaskManagerMemory(propertiesProvider);
configure(new CommonMode(new Properties()) {
@Override
protected void configure() {
bind(PropertiesProvider.class).toInstance(propertiesProvider);
bind(PipelineRegistry.class).toInstance(mock(PipelineRegistry.class));
bind(SessionIdStore.class).toInstance(SessionIdStore.inMemory());
bind(TaskManager.class).toInstance(taskManager);
bind(Filter.class).toInstance(new BasicAuthFilter("/", "ds", DatashareUser.users(userLogins)));
bind(TaskFactory.class).toInstance(mock(TaskFactory.class));
bind(Indexer.class).toInstance(mock(Indexer.class));
}
@Override
protected Routes addModeConfiguration(Routes routes) {
return routes.add(TaskResource.class).filter(Filter.class);
}
}.createWebConfiguration());
}
use of net.codestory.http.filters.basic.BasicAuthFilter in project datashare by ICIJ.
the class SettingsResourceTest method test_patch_configuration.
@Test
public void test_patch_configuration() throws IOException {
File settings = folder.newFile("file.settings");
Files.write(settings.toPath(), asList("foo=doe", "bar=baz"));
configure(routes -> routes.add(new SettingsResource(new PropertiesProvider(settings.getAbsolutePath()))).filter(new BasicAuthFilter("/", "icij", singleUser(local()))));
patch("/api/settings", "{\"data\": {\"foo\": \"qux\", \"xyzzy\":\"fred\"}}").withPreemptiveAuthentication("local", "pass").should().respond(200);
Properties properties = new PropertiesProvider(settings.getAbsolutePath()).getProperties();
assertThat(properties).includes(entry("foo", "qux"), entry("bar", "baz"), entry("xyzzy", "fred"));
}
use of net.codestory.http.filters.basic.BasicAuthFilter in project datashare by ICIJ.
the class NamedEntityResourceTest method test_get_named_entity_in_prod_mode.
@Test
public void test_get_named_entity_in_prod_mode() {
configure(routes -> routes.add(new NamedEntityResource(indexer)).filter(new BasicAuthFilter("/", "icij", DatashareUser.singleUser("anne"))));
NamedEntity toBeReturned = create(PERSON, "mention", asList(123L), "docId", "root", CORENLP, FRENCH);
doReturn(toBeReturned).when(indexer).get("anne-datashare", "my_id", "root_parent");
get("/api/anne-datashare/namedEntities/my_id?routing=root_parent").withAuthentication("anne", "notused").should().respond(200).haveType("application/json");
}
Aggregations