Home / Function/ testSslTLVEncodeProxy() — netty Function Reference

testSslTLVEncodeProxy() — netty Function Reference

Architecture documentation for the testSslTLVEncodeProxy() function in HaProxyMessageEncoderTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  d088e373_9657_80e7_340b_9eab3347e15a["testSslTLVEncodeProxy()"]
  4545ac9d_2f62_4ac7_c80f_5975d8175456["HaProxyMessageEncoderTest"]
  d088e373_9657_80e7_340b_9eab3347e15a -->|defined in| 4545ac9d_2f62_4ac7_c80f_5975d8175456
  style d088e373_9657_80e7_340b_9eab3347e15a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-haproxy/src/test/java/io/netty/handler/codec/haproxy/HaProxyMessageEncoderTest.java lines 274–327

    @Test
    public void testSslTLVEncodeProxy() {
        EmbeddedChannel ch = new EmbeddedChannel(INSTANCE);

        List<HAProxyTLV> tlvs = new ArrayList<HAProxyTLV>();

        ByteBuf helloWorld = Unpooled.copiedBuffer("hello world", CharsetUtil.US_ASCII);
        HAProxyTLV alpnTlv = new HAProxyTLV(Type.PP2_TYPE_ALPN, (byte) 0x01, helloWorld.copy());
        tlvs.add(alpnTlv);

        ByteBuf arbitrary = Unpooled.copiedBuffer("an arbitrary string", CharsetUtil.US_ASCII);
        HAProxyTLV authorityTlv = new HAProxyTLV(Type.PP2_TYPE_AUTHORITY, (byte) 0x01, arbitrary.copy());
        tlvs.add(authorityTlv);

        ByteBuf sslContent = Unpooled.copiedBuffer("some ssl content", CharsetUtil.US_ASCII);
        HAProxySSLTLV haProxySSLTLV = new HAProxySSLTLV(1, (byte) 0x01, tlvs, sslContent.copy());

        HAProxyMessage message = new HAProxyMessage(
                HAProxyProtocolVersion.V2, HAProxyCommand.PROXY, HAProxyProxiedProtocol.TCP4,
                "192.168.0.1", "192.168.0.11", 56324, 443,
                Collections.<HAProxyTLV>singletonList(haProxySSLTLV));
        assertTrue(ch.writeOutbound(message));

        ByteBuf byteBuf = ch.readOutbound();

        assertEquals(byteBuf.getUnsignedShort(14), byteBuf.readableBytes() - V2_HEADER_BYTES_LENGTH);
        ByteBuf tlv = byteBuf.skipBytes(V2_HEADER_BYTES_LENGTH + IPv4_ADDRESS_BYTES_LENGTH);

        // ssl tlv type
        assertEquals(haProxySSLTLV.typeByteValue(), tlv.readByte());

        // length
        int bufLength = tlv.readUnsignedShort();
        assertEquals(bufLength, tlv.readableBytes());

        // client, verify
        assertEquals(0x01, byteBuf.readByte());
        assertEquals(1, byteBuf.readInt());

        // alpn tlv
        assertEquals(alpnTlv.typeByteValue(), tlv.readByte());
        bufLength = tlv.readShort();
        assertEquals(helloWorld.array().length, bufLength);
        assertEquals(helloWorld, tlv.readSlice(bufLength));

        // authority tlv
        assertEquals(authorityTlv.typeByteValue(), tlv.readByte());
        bufLength = tlv.readShort();
        assertEquals(arbitrary.array().length, bufLength);
        assertEquals(arbitrary, tlv.readSlice(bufLength));

        byteBuf.release();
        assertFalse(ch.finish());
    }

Domain

Subdomains

Frequently Asked Questions

What does testSslTLVEncodeProxy() do?
testSslTLVEncodeProxy() is a function in the netty codebase, defined in codec-haproxy/src/test/java/io/netty/handler/codec/haproxy/HaProxyMessageEncoderTest.java.
Where is testSslTLVEncodeProxy() defined?
testSslTLVEncodeProxy() is defined in codec-haproxy/src/test/java/io/netty/handler/codec/haproxy/HaProxyMessageEncoderTest.java at line 274.

Analyze Your Own Codebase

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

Try Supermodel Free