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());
}
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);
}
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);
}
Aggregations