Search in sources :

Example 6 with SSLCustom

use of org.apache.servicecomb.foundation.ssl.SSLCustom 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 7 with SSLCustom

use of org.apache.servicecomb.foundation.ssl.SSLCustom in project java-chassis by ServiceComb.

the class TestVertxTLSBuilder method testbuildHttpServerOptionsRequest.

@Test
public void testbuildHttpServerOptionsRequest() {
    SSLOption option = SSLOption.buildFromYaml("rest.provider");
    SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
    HttpServerOptions serverOptions = new HttpServerOptions();
    new MockUp<SSLOption>() {

        @Mock
        public boolean isAuthPeer() {
            return false;
        }
    };
    VertxTLSBuilder.buildNetServerOptions(option, custom, serverOptions);
    Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
    Assert.assertEquals(serverOptions.getClientAuth(), ClientAuth.REQUEST);
}
Also used : HttpServerOptions(io.vertx.core.http.HttpServerOptions) MockUp(mockit.MockUp) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom) Test(org.junit.Test)

Example 8 with SSLCustom

use of org.apache.servicecomb.foundation.ssl.SSLCustom in project java-chassis by ServiceComb.

the class HighwayClient method createTcpClientConfig.

private TcpClientConfig createTcpClientConfig() {
    TcpClientConfig tcpClientConfig = new TcpClientConfig();
    // global request timeout to be login timeout
    tcpClientConfig.setMsLoginTimeout(DynamicPropertyFactory.getInstance().getLongProperty("servicecomb.request.timeout", TcpClientConfig.DEFAULT_LOGIN_TIMEOUT).get());
    SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null);
    SSLOption sslOption;
    if (factory == null) {
        sslOption = SSLOption.buildFromYaml(SSL_KEY);
    } else {
        sslOption = factory.createSSLOption();
    }
    SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass());
    VertxTLSBuilder.buildClientOptionsBase(sslOption, sslCustom, tcpClientConfig);
    return tcpClientConfig;
}
Also used : TcpClientConfig(org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig) SSLOptionFactory(org.apache.servicecomb.foundation.ssl.SSLOptionFactory) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom)

Example 9 with SSLCustom

use of org.apache.servicecomb.foundation.ssl.SSLCustom in project incubator-servicecomb-java-chassis by apache.

the class TestVertxTLSBuilder method testbuildHttpServerOptions.

@Test
public void testbuildHttpServerOptions() {
    SSLOption option = SSLOption.buildFromYaml("rest.provider");
    SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
    HttpServerOptions serverOptions = new HttpServerOptions();
    VertxTLSBuilder.buildNetServerOptions(option, custom, serverOptions);
    Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
    Assert.assertEquals(serverOptions.getClientAuth(), ClientAuth.REQUEST);
}
Also used : HttpServerOptions(io.vertx.core.http.HttpServerOptions) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom) Test(org.junit.Test)

Example 10 with SSLCustom

use of org.apache.servicecomb.foundation.ssl.SSLCustom in project incubator-servicecomb-java-chassis by apache.

the class TestVertxTLSBuilder method testbuildHttpServerOptionsRequest.

@Test
public void testbuildHttpServerOptionsRequest() {
    SSLOption option = SSLOption.buildFromYaml("rest.provider");
    SSLCustom custom = SSLCustom.createSSLCustom(option.getSslCustomClass());
    HttpServerOptions serverOptions = new HttpServerOptions();
    new MockUp<SSLOption>() {

        @Mock
        public boolean isAuthPeer() {
            return false;
        }
    };
    VertxTLSBuilder.buildNetServerOptions(option, custom, serverOptions);
    Assert.assertEquals(serverOptions.getEnabledSecureTransportProtocols().toArray().length, 1);
    Assert.assertEquals(serverOptions.getClientAuth(), ClientAuth.REQUEST);
}
Also used : HttpServerOptions(io.vertx.core.http.HttpServerOptions) MockUp(mockit.MockUp) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom) Test(org.junit.Test)

Aggregations

SSLCustom (org.apache.servicecomb.foundation.ssl.SSLCustom)27 SSLOption (org.apache.servicecomb.foundation.ssl.SSLOption)27 Test (org.junit.Test)16 HttpClientOptions (io.vertx.core.http.HttpClientOptions)15 SSLOptionFactory (org.apache.servicecomb.foundation.ssl.SSLOptionFactory)11 MockUp (mockit.MockUp)8 HttpServerOptions (io.vertx.core.http.HttpServerOptions)6 ProxyOptions (io.vertx.core.net.ProxyOptions)3 Http2Settings (io.vertx.core.http.Http2Settings)2 NetServer (io.vertx.core.net.NetServer)2 NetServerOptions (io.vertx.core.net.NetServerOptions)2 InetSocketAddress (java.net.InetSocketAddress)2 TcpClientConfig (org.apache.servicecomb.foundation.vertx.client.tcp.TcpClientConfig)2 DefaultTcpServerMetrics (org.apache.servicecomb.foundation.vertx.metrics.DefaultTcpServerMetrics)2 DefaultServerEndpointMetric (org.apache.servicecomb.foundation.vertx.metrics.metric.DefaultServerEndpointMetric)2