Home / Function/ testSniHandlerFailsOnTooBigClientHello() — netty Function Reference

testSniHandlerFailsOnTooBigClientHello() — netty Function Reference

Architecture documentation for the testSniHandlerFailsOnTooBigClientHello() function in SniHandlerTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  ca72757a_ae2c_ddee_a57a_7d10a220e027["testSniHandlerFailsOnTooBigClientHello()"]
  00b45f27_cbf5_af92_430f_7f0426117fa5["SniHandlerTest"]
  ca72757a_ae2c_ddee_a57a_7d10a220e027 -->|defined in| 00b45f27_cbf5_af92_430f_7f0426117fa5
  style ca72757a_ae2c_ddee_a57a_7d10a220e027 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

handler/src/test/java/io/netty/handler/ssl/SniHandlerTest.java lines 714–762

    @Test
    public void testSniHandlerFailsOnTooBigClientHello() throws Exception {
        SniHandler handler = new SniHandler(new Mapping<String, SslContext>() {
            @Override
            public SslContext map(String input) {
                throw new UnsupportedOperationException("Should not be called");
            }
        }, 10, 0);

        final AtomicReference<SniCompletionEvent> completionEventRef =
                new AtomicReference<SniCompletionEvent>();
        final EmbeddedChannel ch = new EmbeddedChannel(handler, new ChannelInboundHandlerAdapter() {
            @Override
            public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
                if (evt instanceof SniCompletionEvent) {
                    completionEventRef.set((SniCompletionEvent) evt);
                }
            }
        });
        final ByteBuf buffer = ch.alloc().buffer();
        buffer.writeByte(0x16);      // Content Type: Handshake
        buffer.writeShort((short) 0x0303); // TLS 1.2
        buffer.writeShort((short) 0x0006); // Packet length

        // 16_777_215
        buffer.writeByte((byte) 0x01); // Client Hello
        buffer.writeMedium(0xFFFFFF); // Length
        buffer.writeShort((short) 0x0303); // TLS 1.2

        assertThrows(TooLongFrameException.class, new Executable() {
            @Override
            public void execute() throws Throwable {
                ch.writeInbound(buffer);
            }
        });
        try {
            while (completionEventRef.get() == null) {
                Thread.sleep(100);
                // We need to run all pending tasks as the handshake timeout is scheduled on the EventLoop.
                ch.runPendingTasks();
            }
            SniCompletionEvent completionEvent = completionEventRef.get();
            assertNotNull(completionEvent);
            assertNotNull(completionEvent.cause());
            assertEquals(TooLongFrameException.class, completionEvent.cause().getClass());
        } finally {
            ch.finishAndReleaseAll();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testSniHandlerFailsOnTooBigClientHello() do?
testSniHandlerFailsOnTooBigClientHello() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/SniHandlerTest.java.
Where is testSniHandlerFailsOnTooBigClientHello() defined?
testSniHandlerFailsOnTooBigClientHello() is defined in handler/src/test/java/io/netty/handler/ssl/SniHandlerTest.java at line 714.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free