Search in sources :

Example 1 with PipelineRegistry

use of io.crate.netty.channel.PipelineRegistry in project crate by crate.

the class CrateHttpsTransportTest method testPipelineConfiguration.

@Test
public void testPipelineConfiguration() throws Exception {
    Settings settings = Settings.builder().put(PATH_HOME_SETTING.getKey(), "/tmp").put(SslSettings.SSL_HTTP_ENABLED.getKey(), true).put(SslSettings.SSL_TRUSTSTORE_FILEPATH.getKey(), trustStoreFile.getAbsolutePath()).put(SslSettings.SSL_TRUSTSTORE_PASSWORD.getKey(), "keystorePassword").put(SslSettings.SSL_KEYSTORE_FILEPATH.getKey(), keyStoreFile.getAbsolutePath()).put(SslSettings.SSL_KEYSTORE_PASSWORD.getKey(), "keystorePassword").put(SslSettings.SSL_KEYSTORE_KEY_PASSWORD.getKey(), "keystorePassword").build();
    NetworkService networkService = new NetworkService(Collections.singletonList(new NetworkService.CustomNameResolver() {

        @Override
        public InetAddress[] resolveDefault() {
            return new InetAddress[] { InetAddresses.forString("127.0.0.1") };
        }

        @Override
        public InetAddress[] resolveIfPossible(String value) throws IOException {
            return new InetAddress[] { InetAddresses.forString("127.0.0.1") };
        }
    }));
    PipelineRegistry pipelineRegistry = new PipelineRegistry(settings);
    pipelineRegistry.setSslContextProvider(new SslContextProvider(settings));
    Netty4HttpServerTransport transport = new Netty4HttpServerTransport(settings, networkService, BigArrays.NON_RECYCLING_INSTANCE, mock(ThreadPool.class), NamedXContentRegistry.EMPTY, pipelineRegistry, new NettyBootstrap(), mock(NodeClient.class));
    EmbeddedChannel channel = new EmbeddedChannel();
    try {
        transport.start();
        Netty4HttpServerTransport.HttpChannelHandler httpChannelHandler = (Netty4HttpServerTransport.HttpChannelHandler) transport.configureServerChannelHandler();
        httpChannelHandler.initChannel(channel);
        assertThat(channel.pipeline().first(), instanceOf(SslHandler.class));
    } finally {
        transport.stop();
        transport.close();
        channel.releaseInbound();
        channel.close().awaitUninterruptibly();
    }
}
Also used : NodeClient(org.elasticsearch.client.node.NodeClient) ThreadPool(org.elasticsearch.threadpool.ThreadPool) Netty4HttpServerTransport(org.elasticsearch.http.netty4.Netty4HttpServerTransport) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) PipelineRegistry(io.crate.netty.channel.PipelineRegistry) SslHandler(io.netty.handler.ssl.SslHandler) NetworkService(org.elasticsearch.common.network.NetworkService) SslContextProvider(io.crate.protocols.ssl.SslContextProvider) InetAddress(java.net.InetAddress) Settings(org.elasticsearch.common.settings.Settings) SslSettings(io.crate.protocols.ssl.SslSettings) NettyBootstrap(io.crate.netty.NettyBootstrap) Test(org.junit.Test)

Aggregations

NettyBootstrap (io.crate.netty.NettyBootstrap)1 PipelineRegistry (io.crate.netty.channel.PipelineRegistry)1 SslContextProvider (io.crate.protocols.ssl.SslContextProvider)1 SslSettings (io.crate.protocols.ssl.SslSettings)1 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1 SslHandler (io.netty.handler.ssl.SslHandler)1 InetAddress (java.net.InetAddress)1 NodeClient (org.elasticsearch.client.node.NodeClient)1 NetworkService (org.elasticsearch.common.network.NetworkService)1 Settings (org.elasticsearch.common.settings.Settings)1 Netty4HttpServerTransport (org.elasticsearch.http.netty4.Netty4HttpServerTransport)1 ThreadPool (org.elasticsearch.threadpool.ThreadPool)1 Test (org.junit.Test)1