Home / Class/ SocksAuthRequestDecoderTest Class — netty Architecture

SocksAuthRequestDecoderTest Class — netty Architecture

Architecture documentation for the SocksAuthRequestDecoderTest class in SocksAuthRequestDecoderTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  d73ea5d3_bd98_0ebe_c074_f8db2a668b15["SocksAuthRequestDecoderTest"]
  b30941e2_dcee_3f2f_db53_c0adbfe46c88["SocksAuthRequestDecoderTest.java"]
  d73ea5d3_bd98_0ebe_c074_f8db2a668b15 -->|defined in| b30941e2_dcee_3f2f_db53_c0adbfe46c88
  16483e73_c6e3_c595_24ea_ff56afea2f13["testAuthRequestDecoder()"]
  d73ea5d3_bd98_0ebe_c074_f8db2a668b15 -->|method| 16483e73_c6e3_c595_24ea_ff56afea2f13
  5f983d51_6aa4_28f1_6f95_cdae834be7ab["testAuthRequestDecoderPartialSend()"]
  d73ea5d3_bd98_0ebe_c074_f8db2a668b15 -->|method| 5f983d51_6aa4_28f1_6f95_cdae834be7ab

Relationship Graph

Source Code

codec-socks/src/test/java/io/netty/handler/codec/socks/SocksAuthRequestDecoderTest.java lines 27–73

public class SocksAuthRequestDecoderTest {

    private static final String username = "testUserName";
    private static final String password = "testPassword";

    @Test
    public void testAuthRequestDecoder() {
        SocksAuthRequest msg = new SocksAuthRequest(username, password);
        SocksAuthRequestDecoder decoder = new SocksAuthRequestDecoder();
        EmbeddedChannel embedder = new EmbeddedChannel(decoder);
        SocksCommonTestUtils.writeMessageIntoEmbedder(embedder, msg);
        msg = embedder.readInbound();
        assertEquals(username, msg.username());
        assertEquals(password, msg.password());
        assertNull(embedder.readInbound());
    }

    @Test
    public void testAuthRequestDecoderPartialSend() {
        EmbeddedChannel ch = new EmbeddedChannel(new SocksAuthRequestDecoder());
        ByteBuf byteBuf = Unpooled.buffer(16);

        // Send username and password size
        byteBuf.writeByte(SocksSubnegotiationVersion.AUTH_PASSWORD.byteValue());
        byteBuf.writeByte(username.length());
        byteBuf.writeBytes(username.getBytes());
        byteBuf.writeByte(password.length());
        ch.writeInbound(byteBuf);

        // Check that channel is empty
        assertNull(ch.readInbound());

        // Send password
        ByteBuf byteBuf2 = Unpooled.buffer();
        byteBuf2.writeBytes(password.getBytes());
        ch.writeInbound(byteBuf2);

        // Read message from channel
        SocksAuthRequest msg = ch.readInbound();

        // Check message
        assertEquals(username, msg.username());
        assertEquals(password, msg.password());

        assertFalse(ch.finishAndReleaseAll());
    }
}

Frequently Asked Questions

What is the SocksAuthRequestDecoderTest class?
SocksAuthRequestDecoderTest is a class in the netty codebase, defined in codec-socks/src/test/java/io/netty/handler/codec/socks/SocksAuthRequestDecoderTest.java.
Where is SocksAuthRequestDecoderTest defined?
SocksAuthRequestDecoderTest is defined in codec-socks/src/test/java/io/netty/handler/codec/socks/SocksAuthRequestDecoderTest.java at line 27.

Analyze Your Own Codebase

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

Try Supermodel Free