@Test void failConnectIfSaslMechsListEmpty() { SaslListMechanismsHandler handler = new SaslListMechanismsHandler(endpointContext); channel.pipeline().addLast(handler); assertEquals(handler, channel.pipeline().get(SaslListMechanismsHandler.class)); ChannelFuture connectFuture = channel.connect(new InetSocketAddress("1.2.3.4", 1234)); assertFalse(connectFuture.isDone()); channel.pipeline().fireChannelActive(); channel.runPendingTasks(); ByteBuf writtenRequest = channel.readOutbound(); verifyRequest(writtenRequest, MemcacheProtocol.Opcode.SASL_LIST_MECHS.opcode(), false, false, false); assertNotNull(channel.pipeline().get(SaslListMechanismsHandler.class)); ReferenceCountUtil.release(writtenRequest); ByteBuf response = decodeHexDump(readResource( "success_sasl_list_mechs_empty_response.txt", ErrorMapLoadingHandlerTest.class )); channel.writeInbound(response); channel.runPendingTasks(); assertFalse(connectFuture.isSuccess()); AuthenticationFailureException cause = (AuthenticationFailureException) connectFuture.cause(); assertTrue(cause.getMessage().contains("Received empty mechanism list from server")); }
@Override public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) { interceptedConnectPromise = promise; ChannelPromise downstream = ctx.newPromise(); downstream.addListener(f -> { if (!f.isSuccess() && !interceptedConnectPromise.isDone()) { ConnectTimings.record(ctx.channel(), this.getClass()); interceptedConnectPromise.tryFailure(f.cause()); } }); ctx.connect(remoteAddress, localAddress, downstream); }
SaslListMechanismsHandler extends ChannelDuplexHandler { @Override public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) { interceptedConnectPromise = promise; ChannelPromise downstream = ctx.newPromise(); downstream.addListener(f -> { if (!f.isSuccess() && !interceptedConnectPromise.isDone()) { ConnectTimings.record(ctx.channel(), this.getClass()); interceptedConnectPromise.tryFailure(f.cause()); } }); ctx.connect(remoteAddress, localAddress, downstream); } }
SaslListMechanismsHandler extends ChannelDuplexHandler { @Override public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) { interceptedConnectPromise = promise; ChannelPromise downstream = ctx.newPromise(); downstream.addListener(f -> { if (!f.isSuccess() && !interceptedConnectPromise.isDone()) { ConnectTimings.record(ctx.channel(), this.getClass()); interceptedConnectPromise.tryFailure(f.cause()); } }); ctx.connect(remoteAddress, localAddress, downstream); } SaslListMechanismsHandler(final EndpointContext endpointContext); }
SaslListMechanismsHandler extends ChannelDuplexHandler { @Override public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) { interceptedConnectPromise = promise; ChannelPromise downstream = ctx.newPromise(); downstream.addListener(f -> { if (!f.isSuccess() && !interceptedConnectPromise.isDone()) { ConnectTimings.record(ctx.channel(), this.getClass()); interceptedConnectPromise.tryFailure(f.cause()); } }); ctx.connect(remoteAddress, localAddress, downstream); } SaslListMechanismsHandler(final EndpointContext endpointContext); @Override void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress,
                      final SocketAddress localAddress, final ChannelPromise promise); @Override void channelActive(final ChannelHandlerContext ctx); @Override void channelRead(final ChannelHandlerContext ctx, final Object msg); @Override void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause); }
SaslListMechanismsHandler extends ChannelDuplexHandler { @Override public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) { interceptedConnectPromise = promise; ChannelPromise downstream = ctx.newPromise(); downstream.addListener(f -> { if (!f.isSuccess() && !interceptedConnectPromise.isDone()) { ConnectTimings.record(ctx.channel(), this.getClass()); interceptedConnectPromise.tryFailure(f.cause()); } }); ctx.connect(remoteAddress, localAddress, downstream); } SaslListMechanismsHandler(final EndpointContext endpointContext); @Override void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress,
                      final SocketAddress localAddress, final ChannelPromise promise); @Override void channelActive(final ChannelHandlerContext ctx); @Override void channelRead(final ChannelHandlerContext ctx, final Object msg); @Override void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause);  }