use of io.vertx.core.http.HttpClientOptions in project java-chassis by ServiceComb.
the class TestVertxTLSBuilder method testbuildClientOptionsBaseAuthPeerFalse.
@Test
public void testbuildClientOptionsBaseAuthPeerFalse() {
SSLOption option = SSLOption.buildFromYaml("rest.consumer");
SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
HttpClientOptions serverOptions = new HttpClientOptions();
new MockUp<SSLOption>() {
@Mock
public boolean isAuthPeer() {
return false;
}
};
VertxTLSBuilder.buildClientOptionsBase(option, custom, serverOptions);
Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
Assert.assertEquals(serverOptions.isTrustAll(), true);
}
use of io.vertx.core.http.HttpClientOptions in project java-chassis by ServiceComb.
the class TestVertxTLSBuilder method testbuildHttpClientOptions_ssl_withFactory.
@Test
public void testbuildHttpClientOptions_ssl_withFactory() {
ArchaiusUtils.setProperty("ssl.exist.sslOptionFactory", SSLOptionFactoryForTest.class.getName());
HttpClientOptions clientOptions = new HttpClientOptions();
VertxTLSBuilder.buildHttpClientOptions("exist", clientOptions);
Assert.assertTrue(clientOptions.isSsl());
Assert.assertTrue(clientOptions.isVerifyHost());
}
use of io.vertx.core.http.HttpClientOptions in project java-chassis by ServiceComb.
the class TestVertxTLSBuilder method testbuildHttpClientOptions_sslKey_noFactory.
@Test
public void testbuildHttpClientOptions_sslKey_noFactory() {
HttpClientOptions clientOptions = new HttpClientOptions();
VertxTLSBuilder.buildHttpClientOptions("notExist", clientOptions);
Assert.assertTrue(clientOptions.isSsl());
}
use of io.vertx.core.http.HttpClientOptions in project java-chassis by ServiceComb.
the class TestVertxTLSBuilder method testbuildClientOptionsBaseSTORE_JKS.
@Test
public void testbuildClientOptionsBaseSTORE_JKS() {
SSLOption option = SSLOption.buildFromYaml("rest.consumer");
SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
HttpClientOptions serverOptions = new HttpClientOptions();
new MockUp<SSLOption>() {
@Mock
public String getKeyStoreType() {
return "JKS";
}
};
VertxTLSBuilder.buildClientOptionsBase(option, custom, serverOptions);
Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
Assert.assertEquals(serverOptions.isTrustAll(), true);
}
use of io.vertx.core.http.HttpClientOptions in project java-chassis by ServiceComb.
the class HttpClientOptionsSPI method createHttpClientOptions.
static HttpClientOptions createHttpClientOptions(HttpClientOptionsSPI spi) {
HttpClientOptions httpClientOptions = new HttpClientOptions();
httpClientOptions.setProtocolVersion(spi.getHttpVersion());
httpClientOptions.setConnectTimeout(spi.getConnectTimeoutInMillis());
httpClientOptions.setIdleTimeout(spi.getIdleTimeoutInSeconds());
httpClientOptions.setTryUseCompression(spi.isTryUseCompression());
httpClientOptions.setMaxWaitQueueSize(spi.getMaxWaitQueueSize());
httpClientOptions.setMaxPoolSize(spi.getMaxPoolSize());
httpClientOptions.setKeepAlive(spi.isKeepAlive());
httpClientOptions.setMaxHeaderSize(spi.getMaxHeaderSize());
httpClientOptions.setKeepAliveTimeout(spi.getKeepAliveTimeout());
if (spi.isProxyEnable()) {
ProxyOptions proxy = new ProxyOptions();
proxy.setHost(spi.getProxyHost());
proxy.setPort(spi.getProxyPort());
proxy.setUsername(spi.getProxyUsername());
proxy.setPassword(Encryptions.decode(spi.getProxyPassword(), spi.getConfigTag()));
httpClientOptions.setProxyOptions(proxy);
}
if (spi.getHttpVersion() == HttpVersion.HTTP_2) {
httpClientOptions.setHttp2ClearTextUpgrade(false);
httpClientOptions.setUseAlpn(spi.isUseAlpn());
httpClientOptions.setHttp2MultiplexingLimit(spi.getHttp2MultiplexingLimit());
httpClientOptions.setHttp2MaxPoolSize(spi.getHttp2MaxPoolSize());
}
if (spi.isSsl()) {
VertxTLSBuilder.buildHttpClientOptions(spi.getConfigTag(), httpClientOptions);
}
return httpClientOptions;
}
Aggregations