testConnectWithTokenValidation() — netty Function Reference
Architecture documentation for the testConnectWithTokenValidation() function in QuicChannelConnectTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 393c0f20_5ebe_f5a5_9bad_387abf5a5aea["testConnectWithTokenValidation()"] 1e1bc485_1969_4537_ef9b_f28971b2f663["QuicChannelConnectTest"] 393c0f20_5ebe_f5a5_9bad_387abf5a5aea -->|defined in| 1e1bc485_1969_4537_ef9b_f28971b2f663 50ae9935_9ff5_26ef_46de_b1c885717ce2["BytesCountingHandler()"] 393c0f20_5ebe_f5a5_9bad_387abf5a5aea -->|calls| 50ae9935_9ff5_26ef_46de_b1c885717ce2 5f0fc68a_3438_a865_1307_d0a3144b2c00["assertState()"] 393c0f20_5ebe_f5a5_9bad_387abf5a5aea -->|calls| 5f0fc68a_3438_a865_1307_d0a3144b2c00 style 393c0f20_5ebe_f5a5_9bad_387abf5a5aea fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicChannelConnectTest.java lines 601–676
@ParameterizedTest
@MethodSource("newSslTaskExecutors")
public void testConnectWithTokenValidation(Executor executor) throws Throwable {
int numBytes = 8;
ChannelActiveVerifyHandler serverQuicChannelHandler = new ChannelActiveVerifyHandler();
CountDownLatch serverLatch = new CountDownLatch(1);
CountDownLatch clientLatch = new CountDownLatch(1);
// Disable token validation
Channel server = QuicTestUtils.newServer(executor, new QuicTokenHandler() {
@Override
public boolean writeToken(ByteBuf out, ByteBuf dcid, InetSocketAddress address) {
out.writeInt(0)
.writeBytes(dcid, dcid.readerIndex(), dcid.readableBytes());
return true;
}
@Override
public int validateToken(ByteBuf token, InetSocketAddress address) {
// Use readInt() so we adjust the readerIndex of the token.
assertEquals(0, token.readInt());
return token.readerIndex();
}
@Override
public int maxTokenLength() {
return 96;
}
},
serverQuicChannelHandler, new BytesCountingHandler(serverLatch, numBytes));
InetSocketAddress address = (InetSocketAddress) server.localAddress();
Channel channel = QuicTestUtils.newClient(executor);
try {
ChannelActiveVerifyHandler clientQuicChannelHandler = new ChannelActiveVerifyHandler();
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientQuicChannelHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
.connect()
.get();
QuicConnectionAddress localAddress = (QuicConnectionAddress) quicChannel.localAddress();
QuicConnectionAddress remoteAddress = (QuicConnectionAddress) quicChannel.remoteAddress();
assertNotNull(localAddress);
assertNotNull(remoteAddress);
QuicStreamChannel stream = quicChannel.createStream(QuicStreamType.BIDIRECTIONAL,
new BytesCountingHandler(clientLatch, numBytes)).get();
stream.writeAndFlush(Unpooled.directBuffer().writeZero(numBytes)).sync();
clientLatch.await();
QuicheQuicSslEngine quicheQuicSslEngine = (QuicheQuicSslEngine) quicChannel.sslEngine();
assertNotNull(quicheQuicSslEngine);
assertEquals(QuicTestUtils.PROTOS[0],
// Just do the cast as getApplicationProtocol() only exists in SSLEngine itself since Java9+ and
// we may run on an earlier version
quicheQuicSslEngine.getApplicationProtocol());
stream.close().sync();
quicChannel.close().sync();
ChannelFuture closeFuture = quicChannel.closeFuture().await();
assertTrue(closeFuture.isSuccess());
clientQuicChannelHandler.assertState();
serverQuicChannelHandler.assertState();
assertEquals(serverQuicChannelHandler.localAddress(), remoteAddress);
assertEquals(serverQuicChannelHandler.remoteAddress(), localAddress);
} finally {
serverLatch.await();
server.close().sync();
// Close the parent Datagram channel as well.
channel.close().sync();
shutdown(executor);
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does testConnectWithTokenValidation() do?
testConnectWithTokenValidation() is a function in the netty codebase, defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicChannelConnectTest.java.
Where is testConnectWithTokenValidation() defined?
testConnectWithTokenValidation() is defined in codec-native-quic/src/test/java/io/netty/handler/codec/quic/QuicChannelConnectTest.java at line 601.
What does testConnectWithTokenValidation() call?
testConnectWithTokenValidation() calls 2 function(s): BytesCountingHandler, assertState.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free