Search in sources :

Example 1 with JdkSslClientContext

use of io.netty.handler.ssl.JdkSslClientContext in project riposte by Nike-Inc.

the class HttpChannelInitializerTest method initChannel_does_not_add_debugLoggingHandler_if_debugChannelLifecycleLoggingEnabled_is_false.

@Test
public void initChannel_does_not_add_debugLoggingHandler_if_debugChannelLifecycleLoggingEnabled_is_false() throws SSLException {
    // given
    HttpChannelInitializer hci = basicHttpChannelInitializer(new JdkSslClientContext(), 42, 100, false, mock(RequestValidator.class), createRequestAndResponseFilterMock());
    // when
    hci.initChannel(socketChannelMock);
    // then
    ArgumentCaptor<ChannelHandler> channelHandlerArgumentCaptor = ArgumentCaptor.forClass(ChannelHandler.class);
    verify(channelPipelineMock, atLeastOnce()).addLast(anyString(), channelHandlerArgumentCaptor.capture());
    List<ChannelHandler> handlers = channelHandlerArgumentCaptor.getAllValues();
    assertThat(findChannelHandler(handlers, LoggingHandler.class), nullValue());
}
Also used : LoggingHandler(io.netty.handler.logging.LoggingHandler) RequestValidator(com.nike.riposte.server.error.validation.RequestValidator) JdkSslClientContext(io.netty.handler.ssl.JdkSslClientContext) ChannelHandler(io.netty.channel.ChannelHandler) Test(org.junit.Test)

Example 2 with JdkSslClientContext

use of io.netty.handler.ssl.JdkSslClientContext in project riposte by Nike-Inc.

the class HttpChannelInitializerTest method initChannel_adds_debugLoggingHandler_first_if_debugChannelLifecycleLoggingEnabled_is_true.

@Test
public void initChannel_adds_debugLoggingHandler_first_if_debugChannelLifecycleLoggingEnabled_is_true() throws SSLException {
    // given
    HttpChannelInitializer hci = basicHttpChannelInitializer(new JdkSslClientContext(), 42, 100, true, mock(RequestValidator.class), createRequestAndResponseFilterMock());
    // when
    hci.initChannel(socketChannelMock);
    // then
    ArgumentCaptor<ChannelHandler> channelHandlerArgumentCaptor = ArgumentCaptor.forClass(ChannelHandler.class);
    verify(channelPipelineMock, atLeastOnce()).addLast(anyString(), channelHandlerArgumentCaptor.capture());
    List<ChannelHandler> handlers = channelHandlerArgumentCaptor.getAllValues();
    assertThat(handlers.get(0), instanceOf(LoggingHandler.class));
}
Also used : LoggingHandler(io.netty.handler.logging.LoggingHandler) RequestValidator(com.nike.riposte.server.error.validation.RequestValidator) JdkSslClientContext(io.netty.handler.ssl.JdkSslClientContext) ChannelHandler(io.netty.channel.ChannelHandler) Test(org.junit.Test)

Example 3 with JdkSslClientContext

use of io.netty.handler.ssl.JdkSslClientContext in project netty by netty.

the class SocketSslClientRenegotiateTest method data.

public static Collection<Object[]> data() throws Exception {
    List<SslContext> serverContexts = new ArrayList<SslContext>();
    List<SslContext> clientContexts = new ArrayList<SslContext>();
    clientContexts.add(new JdkSslClientContext(CERT_FILE));
    boolean hasOpenSsl = OpenSsl.isAvailable();
    if (hasOpenSsl) {
        OpenSslServerContext context = new OpenSslServerContext(CERT_FILE, KEY_FILE);
        serverContexts.add(context);
    } else {
        logger.warn("OpenSSL is unavailable and thus will not be tested.", OpenSsl.unavailabilityCause());
    }
    List<Object[]> params = new ArrayList<Object[]>();
    for (SslContext sc : serverContexts) {
        for (SslContext cc : clientContexts) {
            for (int i = 0; i < 32; i++) {
                params.add(new Object[] { sc, cc, true });
                params.add(new Object[] { sc, cc, false });
            }
        }
    }
    return params;
}
Also used : JdkSslClientContext(io.netty.handler.ssl.JdkSslClientContext) OpenSslServerContext(io.netty.handler.ssl.OpenSslServerContext) ArrayList(java.util.ArrayList) SslContext(io.netty.handler.ssl.SslContext)

Aggregations

JdkSslClientContext (io.netty.handler.ssl.JdkSslClientContext)3 RequestValidator (com.nike.riposte.server.error.validation.RequestValidator)2 ChannelHandler (io.netty.channel.ChannelHandler)2 LoggingHandler (io.netty.handler.logging.LoggingHandler)2 Test (org.junit.Test)2 OpenSslServerContext (io.netty.handler.ssl.OpenSslServerContext)1 SslContext (io.netty.handler.ssl.SslContext)1 ArrayList (java.util.ArrayList)1