diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/HostPortTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/HostPortTest.java index a700262cb90..703a81da065 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/HostPortTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/HostPortTest.java @@ -42,7 +42,28 @@ public class HostPortTest Arguments.of("10.10.10.1:80", "10.10.10.1", "80"), Arguments.of("[0::0::0::1]", "[0::0::0::1]", null), Arguments.of("[0::0::0::1]:80", "[0::0::0::1]", "80"), - Arguments.of("0:1:2:3:4:5:6","[0:1:2:3:4:5:6]",null) + Arguments.of("0:1:2:3:4:5:6","[0:1:2:3:4:5:6]",null), + // Localhost tests + Arguments.of("localhost:80", "localhost", "80"), + Arguments.of("127.0.0.1:80", "127.0.0.1", "80"), + Arguments.of("::1","[::1]",null), + Arguments.of("[::1]:443","[::1]","443"), + // Examples from https://tools.ietf.org/html/rfc2732#section-2 + Arguments.of("[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80", "[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", "80"), + Arguments.of("[1080:0:0:0:8:800:200C:417A]", "[1080:0:0:0:8:800:200C:417A]", null), + Arguments.of("[3ffe:2a00:100:7031::1]", "[3ffe:2a00:100:7031::1]", null), + Arguments.of("[1080::8:800:200C:417A]", "[1080::8:800:200C:417A]", null), + Arguments.of("[::192.9.5.5]", "[::192.9.5.5]", null), + Arguments.of("[::FFFF:129.144.52.38]:80", "[::FFFF:129.144.52.38]", "80"), + Arguments.of("[2010:836B:4179::836B:4179]", "[2010:836B:4179::836B:4179]", null), + // Modified Examples from above, not using square brackets (valid, but should never have a port) + Arguments.of("FEDC:BA98:7654:3210:FEDC:BA98:7654:3210", "[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]", null), + Arguments.of("1080:0:0:0:8:800:200C:417A", "[1080:0:0:0:8:800:200C:417A]", null), + Arguments.of("3ffe:2a00:100:7031::1", "[3ffe:2a00:100:7031::1]", null), + Arguments.of("1080::8:800:200C:417A", "[1080::8:800:200C:417A]", null), + Arguments.of("::192.9.5.5", "[::192.9.5.5]", null), + Arguments.of("::FFFF:129.144.52.38", "[::FFFF:129.144.52.38]", null), + Arguments.of("2010:836B:4179::836B:4179", "[2010:836B:4179::836B:4179]", null) ); }