use of org.neo4j.server.web.WebServer in project neo4j by neo4j.
the class DBMSModuleTest method shouldRegisterAtRootByDefault.
@Test
public void shouldRegisterAtRootByDefault() throws Exception {
WebServer webServer = mock(WebServer.class);
Config config = mock(Config.class);
CommunityNeoWebServer neoServer = mock(CommunityNeoWebServer.class);
when(neoServer.getBaseUri()).thenReturn(new URI("http://localhost:7575"));
when(neoServer.getWebServer()).thenReturn(webServer);
when(config.get(GraphDatabaseSettings.auth_enabled)).thenReturn(true);
when(config.get(ServerSettings.http_paths_blacklist)).thenReturn(emptyList());
var module = new DBMSModule(webServer, config, () -> new DiscoverableURIs.Builder().build(), NullLogProvider.getInstance());
module.start();
verify(webServer).addJAXRSClasses(anyList(), anyString(), isNull());
}
use of org.neo4j.server.web.WebServer in project neo4j by neo4j.
the class DBMSModuleTest method shouldNotRegisterUserServiceWhenAuthDisabled.
@SuppressWarnings("unchecked")
@Test
public void shouldNotRegisterUserServiceWhenAuthDisabled() throws Exception {
WebServer webServer = mock(WebServer.class);
Config config = mock(Config.class);
CommunityNeoServer neoServer = mock(CommunityNeoServer.class);
when(neoServer.baseUri()).thenReturn(new URI("http://localhost:7575"));
when(neoServer.getWebServer()).thenReturn(webServer);
when(config.get(GraphDatabaseSettings.auth_enabled)).thenReturn(false);
DBMSModule module = new DBMSModule(webServer, config);
module.start();
verify(webServer).addJAXRSClasses(anyList(), anyString(), anyCollection());
verify(webServer, never()).addJAXRSClasses(Matchers.argThat(new ArgumentMatcher<List<String>>() {
@Override
public boolean matches(Object argument) {
List<String> argumentList = (List<String>) argument;
return argumentList.contains(UserService.class.getName());
}
@Override
public void describeTo(Description description) {
description.appendText("<List containing " + UserService.class.getName() + ">");
}
}), anyString(), anyCollection());
}
use of org.neo4j.server.web.WebServer in project neo4j by neo4j.
the class ManagementApiModuleTest method shouldRegisterASingleUri.
@Test
public void shouldRegisterASingleUri() throws Exception {
WebServer webServer = mock(WebServer.class);
CommunityNeoServer neoServer = mock(CommunityNeoServer.class);
when(neoServer.baseUri()).thenReturn(new URI("http://localhost:7575"));
when(neoServer.getWebServer()).thenReturn(webServer);
Map<String, String> params = new HashMap();
String managementPath = "/db/manage";
params.put(ServerSettings.management_api_path.name(), managementPath);
Config config = Config.embeddedDefaults(params);
when(neoServer.getConfig()).thenReturn(config);
ManagementApiModule module = new ManagementApiModule(webServer, config);
module.start();
verify(webServer).addJAXRSClasses(any(List.class), anyString(), anyCollection());
}
use of org.neo4j.server.web.WebServer in project neo4j by neo4j.
the class RESTApiModuleTest method shouldRegisterASingleUri.
@Test
public void shouldRegisterASingleUri() throws Exception {
// Given
WebServer webServer = mock(WebServer.class);
Map<String, String> params = new HashMap();
String path = "/db/data";
params.put(ServerSettings.rest_api_path.name(), path);
Config config = Config.embeddedDefaults(params);
Dependencies deps = new Dependencies();
deps.satisfyDependency(new UsageData(mock(JobScheduler.class)));
Database db = mock(Database.class);
// When
RESTApiModule module = new RESTApiModule(webServer, config, deps, NullLogProvider.getInstance());
module.start();
// Then
verify(webServer).addJAXRSClasses(any(List.class), anyString(), anyCollection());
}
use of org.neo4j.server.web.WebServer in project neo4j by neo4j.
the class ThirdPartyJAXRSModuleTest method shouldReportThirdPartyPackagesAtSpecifiedMount.
@Test
void shouldReportThirdPartyPackagesAtSpecifiedMount() throws Exception {
// Given
WebServer webServer = mock(WebServer.class);
CommunityNeoWebServer neoServer = mock(CommunityNeoWebServer.class);
when(neoServer.getBaseUri()).thenReturn(new URI("http://localhost:7575"));
when(neoServer.getWebServer()).thenReturn(webServer);
Config config = mock(Config.class);
List<ThirdPartyJaxRsPackage> jaxRsPackages = new ArrayList<>();
String path = "/third/party/package";
jaxRsPackages.add(new ThirdPartyJaxRsPackage("org.example.neo4j", path));
when(config.get(ServerSettings.third_party_packages)).thenReturn(jaxRsPackages);
// When
ThirdPartyJAXRSModule module = new ThirdPartyJAXRSModule(webServer, config, NullLogProvider.getInstance());
module.start();
// Then
verify(webServer).addJAXRSPackages(any(List.class), anyString(), any());
}
Aggregations