Search in sources :

Example 46 with HttpClientOptions

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);
}
Also used : MockUp(mockit.MockUp) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom) HttpClientOptions(io.vertx.core.http.HttpClientOptions) Test(org.junit.Test)

Example 47 with HttpClientOptions

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());
}
Also used : HttpClientOptions(io.vertx.core.http.HttpClientOptions) Test(org.junit.Test)

Example 48 with HttpClientOptions

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());
}
Also used : HttpClientOptions(io.vertx.core.http.HttpClientOptions) Test(org.junit.Test)

Example 49 with HttpClientOptions

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);
}
Also used : MockUp(mockit.MockUp) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom) HttpClientOptions(io.vertx.core.http.HttpClientOptions) Test(org.junit.Test)

Example 50 with HttpClientOptions

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;
}
Also used : ProxyOptions(io.vertx.core.net.ProxyOptions) HttpClientOptions(io.vertx.core.http.HttpClientOptions)

Aggregations

HttpClientOptions (io.vertx.core.http.HttpClientOptions)101 Test (org.junit.Test)51 HttpClient (io.vertx.core.http.HttpClient)27 HttpClientRequest (io.vertx.core.http.HttpClientRequest)23 HttpServerOptions (io.vertx.core.http.HttpServerOptions)19 CountDownLatch (java.util.concurrent.CountDownLatch)15 HttpMethod (io.vertx.core.http.HttpMethod)14 SSLCustom (org.apache.servicecomb.foundation.ssl.SSLCustom)14 SSLOption (org.apache.servicecomb.foundation.ssl.SSLOption)14 HttpVersion (io.vertx.core.http.HttpVersion)13 AtomicReference (java.util.concurrent.atomic.AtomicReference)13 Vertx (io.vertx.core.Vertx)11 MockUp (mockit.MockUp)11 DeploymentOptions (io.vertx.core.DeploymentOptions)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)10 Buffer (io.vertx.core.buffer.Buffer)9 HttpServer (io.vertx.core.http.HttpServer)8 HttpServerResponse (io.vertx.core.http.HttpServerResponse)8 VertxOptions (io.vertx.core.VertxOptions)7 VertxInternal (io.vertx.core.impl.VertxInternal)7