Search in sources :

Example 6 with ServerTlsHandler

use of io.grpc.netty.ProtocolNegotiators.ServerTlsHandler in project grpc-java by grpc.

the class ProtocolNegotiatorsTest method tlsAdapter_exceptionClosesChannel.

@Test
public void tlsAdapter_exceptionClosesChannel() throws Exception {
    ChannelHandler handler = new ServerTlsHandler(sslContext, grpcHandler);
    // Use addFirst due to the funny error handling in EmbeddedChannel.
    pipeline.addFirst(handler);
    pipeline.fireExceptionCaught(new Exception("bad"));
    assertFalse(channel.isOpen());
}
Also used : ServerTlsHandler(io.grpc.netty.ProtocolNegotiators.ServerTlsHandler) ChannelHandler(io.netty.channel.ChannelHandler) SSLException(javax.net.ssl.SSLException) ExpectedException(org.junit.rules.ExpectedException) Test(org.junit.Test)

Example 7 with ServerTlsHandler

use of io.grpc.netty.ProtocolNegotiators.ServerTlsHandler in project grpc-java by grpc.

the class ProtocolNegotiatorsTest method tlsHandler_userEventTriggeredNonSslEvent.

@Test
public void tlsHandler_userEventTriggeredNonSslEvent() throws Exception {
    ChannelHandler handler = new ServerTlsHandler(sslContext, grpcHandler);
    pipeline.addLast(handler);
    channelHandlerCtx = pipeline.context(handler);
    Object nonSslEvent = new Object();
    pipeline.fireUserEventTriggered(nonSslEvent);
    // A non ssl event should not cause the grpcHandler to be in the pipeline yet.
    ChannelHandlerContext grpcHandlerCtx = pipeline.context(grpcHandler);
    assertNull(grpcHandlerCtx);
}
Also used : ServerTlsHandler(io.grpc.netty.ProtocolNegotiators.ServerTlsHandler) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ChannelHandler(io.netty.channel.ChannelHandler) Test(org.junit.Test)

Example 8 with ServerTlsHandler

use of io.grpc.netty.ProtocolNegotiators.ServerTlsHandler in project grpc-java by grpc.

the class ProtocolNegotiatorsTest method tlsHandler_userEventTriggeredSslEvent_handshakeFailure.

@Test
public void tlsHandler_userEventTriggeredSslEvent_handshakeFailure() throws Exception {
    ChannelHandler handler = new ServerTlsHandler(sslContext, grpcHandler);
    pipeline.addLast(handler);
    channelHandlerCtx = pipeline.context(handler);
    Object sslEvent = new SslHandshakeCompletionEvent(new RuntimeException("bad"));
    pipeline.fireUserEventTriggered(sslEvent);
    // No h2 protocol was specified, so this should be closed.
    assertFalse(channel.isOpen());
    ChannelHandlerContext grpcHandlerCtx = pipeline.context(grpcHandler);
    assertNull(grpcHandlerCtx);
}
Also used : SslHandshakeCompletionEvent(io.netty.handler.ssl.SslHandshakeCompletionEvent) ServerTlsHandler(io.grpc.netty.ProtocolNegotiators.ServerTlsHandler) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ChannelHandler(io.netty.channel.ChannelHandler) Test(org.junit.Test)

Aggregations

ServerTlsHandler (io.grpc.netty.ProtocolNegotiators.ServerTlsHandler)8 ChannelHandler (io.netty.channel.ChannelHandler)8 Test (org.junit.Test)8 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)5 SslHandler (io.netty.handler.ssl.SslHandler)4 SSLException (javax.net.ssl.SSLException)2 ExpectedException (org.junit.rules.ExpectedException)2 SslHandshakeCompletionEvent (io.netty.handler.ssl.SslHandshakeCompletionEvent)1 SupportedCipherSuiteFilter (io.netty.handler.ssl.SupportedCipherSuiteFilter)1 Filter (java.util.logging.Filter)1 LogRecord (java.util.logging.LogRecord)1 Logger (java.util.logging.Logger)1