From 9a0be053c46c679e5536f19c44c5e5dd4525ec59 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 12 Dec 2014 18:00:50 +0900 Subject: [PATCH] Add more assertions related with TLS renegotiation --- .../transport/socket/SocketSslEchoTest.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketSslEchoTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketSslEchoTest.java index 64142f3337..fece1b5a2e 100644 --- a/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketSslEchoTest.java +++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketSslEchoTest.java @@ -206,7 +206,7 @@ public class SocketSslEchoTest extends AbstractSocketTest { Channel sc = sb.bind().sync().channel(); Channel cc = cb.connect().sync().channel(); - Future hf = cc.pipeline().get(SslHandler.class).handshakeFuture(); + Future hf = ch.sslHandler.handshakeFuture(); cc.writeAndFlush(Unpooled.wrappedBuffer(data, 0, FIRST_MESSAGE_SIZE)); final AtomicBoolean firstByteWriteFutureDone = new AtomicBoolean(); @@ -228,10 +228,10 @@ public class SocketSslEchoTest extends AbstractSocketTest { if (needsRenegotiation && i >= data.length / 2) { needsRenegotiation = false; - SslHandler sslHandler = cc.pipeline().get(SslHandler.class); - sslHandler.engine().setEnabledCipherSuites(new String[] { renegotiation.cipherSuite }); - renegoFuture = sslHandler.renegotiate(); + ch.sslHandler.engine().setEnabledCipherSuites(new String[] { renegotiation.cipherSuite }); + renegoFuture = ch.sslHandler.renegotiate(); assertThat(renegoFuture, is(not(sameInstance(hf)))); + assertThat(renegoFuture.isDone(), is(false)); } } @@ -294,7 +294,9 @@ public class SocketSslEchoTest extends AbstractSocketTest { // When renegotiation is done, both the client and server side should be notified. try { if (renegotiation.type != RenegotiationType.NONE) { + assertThat(sh.sslHandler.engine().getSession().getCipherSuite(), is(renegotiation.cipherSuite)); assertThat(sh.negoCounter, is(2)); + assertThat(ch.sslHandler.engine().getSession().getCipherSuite(), is(renegotiation.cipherSuite)); assertThat(ch.negoCounter, is(2)); } else { assertThat(sh.negoCounter, is(1)); @@ -302,6 +304,13 @@ public class SocketSslEchoTest extends AbstractSocketTest { } } catch (Throwable t) { // TODO: Remove this once we fix this test. + logger.warn(sh.channel + + "[S] cipherSuite: " + sh.sslHandler.engine().getSession().getCipherSuite() + + ", negoCounter: " + sh.negoCounter); + logger.warn(ch.channel + + "[C] cipherSuite: " + ch.sslHandler.engine().getSession().getCipherSuite() + + ", negoCounter: " + ch.negoCounter); + TestUtils.dump(StringUtil.simpleClassName(this)); throw t; } @@ -312,6 +321,7 @@ public class SocketSslEchoTest extends AbstractSocketTest { final AtomicReference exception = new AtomicReference(); volatile int counter; private final boolean server; + volatile SslHandler sslHandler; volatile Future renegoFuture; volatile int negoCounter; @@ -320,8 +330,9 @@ public class SocketSslEchoTest extends AbstractSocketTest { } @Override - public void channelActive(ChannelHandlerContext ctx) throws Exception { + public void channelRegistered(ChannelHandlerContext ctx) throws Exception { channel = ctx.channel(); + sslHandler = channel.pipeline().get(SslHandler.class); } @Override @@ -357,6 +368,7 @@ public class SocketSslEchoTest extends AbstractSocketTest { renegoFuture = sslHandler.renegotiate(); assertThat(renegoFuture, is(not(sameInstance(hf)))); assertThat(renegoFuture, is(sameInstance(sslHandler.handshakeFuture()))); + assertThat(renegoFuture.isDone(), is(false)); } }