Socks5CommandResponseDecoderTest Class — netty Architecture
Architecture documentation for the Socks5CommandResponseDecoderTest class in Socks5CommandResponseDecoderTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 1043f194_ebf4_2696_122a_10f7c5e3f0f4["Socks5CommandResponseDecoderTest"] 67dca5f6_9616_c349_a4e6_e3a6aa55641f["Socks5CommandResponseDecoderTest.java"] 1043f194_ebf4_2696_122a_10f7c5e3f0f4 -->|defined in| 67dca5f6_9616_c349_a4e6_e3a6aa55641f 57eafce2_4597_33ba_95f2_1032bae5b8fe["test()"] 1043f194_ebf4_2696_122a_10f7c5e3f0f4 -->|method| 57eafce2_4597_33ba_95f2_1032bae5b8fe 21357c90_b616_4c45_8cc8_f06dc301fe20["testSocksCmdResponseDecoder()"] 1043f194_ebf4_2696_122a_10f7c5e3f0f4 -->|method| 21357c90_b616_4c45_8cc8_f06dc301fe20 e14c3ffa_a7f2_039b_8371_4309805a050a["testInvalidAddress()"] 1043f194_ebf4_2696_122a_10f7c5e3f0f4 -->|method| e14c3ffa_a7f2_039b_8371_4309805a050a 5b1a7a90_5336_6276_5ebe_e336797bbf40["testSocksCmdResponseDecoderIncludingHost()"] 1043f194_ebf4_2696_122a_10f7c5e3f0f4 -->|method| 5b1a7a90_5336_6276_5ebe_e336797bbf40
Relationship Graph
Source Code
codec-socks/src/test/java/io/netty/handler/codec/socksx/v5/Socks5CommandResponseDecoderTest.java lines 30–106
public class Socks5CommandResponseDecoderTest {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(Socks5CommandResponseDecoderTest.class);
private static final Socks5CommandStatus[] STATUSES = {
Socks5CommandStatus.ADDRESS_UNSUPPORTED,
Socks5CommandStatus.COMMAND_UNSUPPORTED,
Socks5CommandStatus.CONNECTION_REFUSED,
Socks5CommandStatus.FAILURE,
Socks5CommandStatus.FORBIDDEN,
Socks5CommandStatus.HOST_UNREACHABLE,
Socks5CommandStatus.NETWORK_UNREACHABLE,
Socks5CommandStatus.SUCCESS,
Socks5CommandStatus.TTL_EXPIRED
};
private static void test(
Socks5CommandStatus status, Socks5AddressType bndAddrType, String bndAddr, int bndPort) {
logger.debug("Testing status: " + status + " bndAddrType: " + bndAddrType);
Socks5CommandResponse msg =
new DefaultSocks5CommandResponse(status, bndAddrType, bndAddr, bndPort);
EmbeddedChannel embedder = new EmbeddedChannel(new Socks5CommandResponseDecoder());
Socks5CommonTestUtils.writeFromServerToClient(embedder, msg);
msg = embedder.readInbound();
assertEquals(msg.status(), status);
if (bndAddr != null) {
assertEquals(msg.bndAddr(), bndAddr);
}
assertEquals(msg.bndPort(), bndPort);
assertNull(embedder.readInbound());
}
/**
* Verifies that sent socks messages are decoded correctly.
*/
@Test
public void testSocksCmdResponseDecoder() {
for (Socks5CommandStatus cmdStatus: STATUSES) {
for (Socks5AddressType addressType : Arrays.asList(Socks5AddressType.DOMAIN,
Socks5AddressType.IPv4,
Socks5AddressType.IPv6)) {
test(cmdStatus, addressType, null, 0);
}
}
}
/**
* Verifies that invalid bound host will fail with IllegalArgumentException during encoding.
*/
@Test
public void testInvalidAddress() {
assertThrows(IllegalArgumentException.class, new Executable() {
@Override
public void execute() {
test(Socks5CommandStatus.SUCCESS, Socks5AddressType.IPv4, "1", 80);
}
});
}
/**
* Verifies that send socks messages are decoded correctly when bound host and port are set.
*/
@Test
public void testSocksCmdResponseDecoderIncludingHost() {
for (Socks5CommandStatus cmdStatus : STATUSES) {
test(cmdStatus, Socks5AddressType.IPv4,
"127.0.0.1", 80);
test(cmdStatus, Socks5AddressType.DOMAIN,
"testDomain.com", 80);
test(cmdStatus, Socks5AddressType.IPv6,
"2001:db8:85a3:42:1000:8a2e:370:7334", 80);
test(cmdStatus, Socks5AddressType.IPv6,
"1111:111:11:1::1", 80);
}
}
}
Defined In
Source
Frequently Asked Questions
What is the Socks5CommandResponseDecoderTest class?
Socks5CommandResponseDecoderTest is a class in the netty codebase, defined in codec-socks/src/test/java/io/netty/handler/codec/socksx/v5/Socks5CommandResponseDecoderTest.java.
Where is Socks5CommandResponseDecoderTest defined?
Socks5CommandResponseDecoderTest is defined in codec-socks/src/test/java/io/netty/handler/codec/socksx/v5/Socks5CommandResponseDecoderTest.java at line 30.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free