use of io.airlift.http.client.HttpClientConfig in project airlift by airlift.
the class TestTestingHttpServer method testRequest.
@Test
public void testRequest() throws Exception {
DummyServlet servlet = new DummyServlet();
TestingHttpServer server = createTestingHttpServer(servlet, ImmutableMap.of());
try {
server.start();
try (HttpClient client = new JettyHttpClient(new HttpClientConfig().setConnectTimeout(new Duration(1, SECONDS)))) {
StatusResponse response = client.execute(prepareGet().setUri(server.getBaseUrl()).build(), createStatusResponseHandler());
assertEquals(response.getStatusCode(), HttpServletResponse.SC_OK);
assertEquals(servlet.getCallCount(), 1);
}
} finally {
server.stop();
}
}
use of io.airlift.http.client.HttpClientConfig in project airlift by airlift.
the class TestHttpEventClient method setup.
@BeforeMethod
public void setup() throws Exception {
httpClient = new JettyHttpClient(new HttpClientConfig().setConnectTimeout(new Duration(10, SECONDS)));
servlet = new DummyServlet();
server = createServer(servlet);
server.start();
}
use of io.airlift.http.client.HttpClientConfig in project airlift by airlift.
the class TestHttpServerProvider method testHttps.
@Test
public void testHttps() throws Exception {
config.setHttpEnabled(false).setHttpsEnabled(true);
httpsConfig.setKeystorePath(getResource("test.keystore.with.two.passwords").getPath()).setKeystorePassword("airlift").setKeyManagerPassword("airliftkey").setAutomaticHttpsSharedSecret("shared-secret");
createAndStartServer();
HttpClientConfig http1ClientConfig = new HttpClientConfig().setHttp2Enabled(false).setTrustStorePath(getResource("test.truststore").getPath()).setTrustStorePassword("airlift").setAutomaticHttpsSharedSecret("shared-secret");
try (JettyHttpClient httpClient = createJettyClient(http1ClientConfig)) {
verifyHttps(httpClient, "localhost");
verifyHttps(httpClient, "127-0-0-1.ip");
verifyHttps(httpClient, "x--1.ip");
}
}
use of io.airlift.http.client.HttpClientConfig in project airlift by airlift.
the class TestHttpServerProvider method testHttp.
@Test
public void testHttp() throws Exception {
createServer();
server.start();
try (JettyHttpClient httpClient = new JettyHttpClient(new HttpClientConfig().setHttp2Enabled(false))) {
StatusResponse response = httpClient.execute(prepareGet().setUri(httpServerInfo.getHttpUri()).build(), createStatusResponseHandler());
assertEquals(response.getStatusCode(), HttpServletResponse.SC_OK);
assertEquals(response.getHeader("X-Protocol"), "HTTP/1.1");
}
try (JettyHttpClient httpClient = new JettyHttpClient(new HttpClientConfig().setHttp2Enabled(true))) {
StatusResponse response = httpClient.execute(prepareGet().setUri(httpServerInfo.getHttpUri()).build(), createStatusResponseHandler());
assertEquals(response.getStatusCode(), HttpServletResponse.SC_OK);
assertEquals(response.getHeader("X-Protocol"), "HTTP/2.0");
}
}
use of io.airlift.http.client.HttpClientConfig in project airlift by airlift.
the class TestHttpServerProvider method testClientCertificateJava.
@Test
public void testClientCertificateJava() throws Exception {
config.setHttpEnabled(false).setHttpsEnabled(true);
httpsConfig.setKeystorePath(getResource("clientcert-java/server.keystore").getPath()).setKeystorePassword("airlift").setAutomaticHttpsSharedSecret("shared-secret");
clientCertificate = ClientCertificate.REQUIRED;
createAndStartServer(createCertTestServlet());
HttpClientConfig clientConfig = new HttpClientConfig().setKeyStorePath(getResource("clientcert-java/client.keystore").getPath()).setKeyStorePassword("airlift").setTrustStorePath(getResource("clientcert-java/client.truststore").getPath()).setTrustStorePassword("airlift").setAutomaticHttpsSharedSecret("shared-secret");
assertClientCertificateRequest(clientConfig, "localhost");
assertClientCertificateRequest(clientConfig, "127-0-0-1.ip");
assertClientCertificateRequest(clientConfig, "x--1.ip");
}
Aggregations