use of io.airlift.event.client.NullEventClient in project airlift by airlift.
the class TestHttpServerCipher method createServer.
private static HttpServer createServer(HttpServlet servlet, NodeInfo nodeInfo, HttpServerInfo httpServerInfo, HttpServerConfig config) {
HashLoginServiceProvider loginServiceProvider = new HashLoginServiceProvider(config);
HttpServerProvider serverProvider = new HttpServerProvider(httpServerInfo, nodeInfo, config, servlet, ImmutableSet.of(new DummyFilter()), ImmutableSet.of(), ImmutableSet.of(), new RequestStats(), new NullEventClient());
serverProvider.setTheAdminServlet(new DummyServlet());
serverProvider.setLoginService(loginServiceProvider.get());
serverProvider.setTokenManager(new TraceTokenManager());
return serverProvider.get();
}
use of io.airlift.event.client.NullEventClient in project airlift by airlift.
the class TestHttpServerProvider method createServer.
private void createServer(HttpServlet servlet) {
HashLoginServiceProvider loginServiceProvider = new HashLoginServiceProvider(config);
HttpServerProvider serverProvider = new HttpServerProvider(httpServerInfo, nodeInfo, config, optionalHttpsConfig(), servlet, ImmutableSet.of(new DummyFilter()), ImmutableSet.of(), ImmutableSet.of(), clientCertificate, new RequestStats(), new NullEventClient(), Optional.empty());
serverProvider.setTheAdminServlet(new DummyServlet());
serverProvider.setLoginService(loginServiceProvider.get());
serverProvider.setTokenManager(new TraceTokenManager());
server = serverProvider.get();
}
use of io.airlift.event.client.NullEventClient in project airlift by airlift.
the class TestHttpServerCipher method createServer.
private static HttpServer createServer(HttpServlet servlet, NodeInfo nodeInfo, HttpServerInfo httpServerInfo, HttpServerConfig config, HttpsConfig httpsConfig) {
HashLoginServiceProvider loginServiceProvider = new HashLoginServiceProvider(config);
HttpServerProvider serverProvider = new HttpServerProvider(httpServerInfo, nodeInfo, config, Optional.of(httpsConfig), servlet, ImmutableSet.of(new DummyFilter()), ImmutableSet.of(), ImmutableSet.of(), ClientCertificate.NONE, new RequestStats(), new NullEventClient(), Optional.empty());
serverProvider.setTheAdminServlet(new DummyServlet());
serverProvider.setLoginService(loginServiceProvider.get());
serverProvider.setTokenManager(new TraceTokenManager());
return serverProvider.get();
}
use of io.airlift.event.client.NullEventClient in project airlift by airlift.
the class TestJettyMultipleCerts method test.
@Test
public void test() throws Exception {
HttpServlet servlet = new HttpServlet() {
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setStatus(200);
response.getOutputStream().write((request.getServerName() + " OK").getBytes(UTF_8));
}
};
HttpServerConfig config = new HttpServerConfig().setLogEnabled(false).setHttpEnabled(false).setHttpPort(0).setHttpsEnabled(true);
HttpsConfig httpsConfig = new HttpsConfig().setHttpsPort(0).setKeystorePath(getResource("multiple-certs/server.p12").getPath()).setKeystorePassword("airlift");
HashLoginServiceProvider loginServiceProvider = new HashLoginServiceProvider(config);
NodeInfo nodeInfo = new NodeInfo(new NodeConfig().setEnvironment("test").setNodeInternalAddress("localhost"));
HttpServerInfo httpServerInfo = new HttpServerInfo(config, Optional.of(httpsConfig), nodeInfo);
HttpServerProvider serverProvider = new HttpServerProvider(httpServerInfo, nodeInfo, config, Optional.of(httpsConfig), servlet, ImmutableSet.of(new DummyFilter()), ImmutableSet.of(), ImmutableSet.of(), ClientCertificate.NONE, new RequestStats(), new NullEventClient(), Optional.empty());
serverProvider.setTheAdminServlet(new DummyServlet());
serverProvider.setLoginService(loginServiceProvider.get());
serverProvider.setTokenManager(new TraceTokenManager());
try (Closer closer = Closer.create()) {
HttpServer server = serverProvider.get();
closer.register(() -> {
try {
server.stop();
} catch (Exception ignore) {
}
});
server.start();
JettyHttpClient client = new JettyHttpClient(new HttpClientConfig().setTrustStorePath(getResource("multiple-certs/server.p12").getPath()).setTrustStorePassword("airlift"));
closer.register(client);
int httpsPort = httpServerInfo.getHttpsUri().getPort();
tryHost(client, HostAndPort.fromParts("localhost", httpsPort));
for (String name : List.of("127.0.0.1", "::1")) {
assertThatThrownBy(() -> tryHost(client, HostAndPort.fromParts(name, httpsPort))).hasMessageStartingWith(name + " Failed communicating with server").hasRootCauseMessage("No subject alternative names present");
}
//
for (String name : List.of("single1", "single2", "single3", "single4")) {
if (doesDomainResolveToLocalhost(name)) {
tryHost(client, HostAndPort.fromParts(name, httpsPort));
}
}
}
}
Aggregations