@@ -91,3 +91,92 @@ def test_it_works_with_ports():
91
91
assert (
92
92
find_hostname_in_userinput ("http://localhost:8080" , "localhost" , 4321 ) is False
93
93
)
94
+
95
+
96
+ def test_loopback_ipv6_found ():
97
+ assert find_hostname_in_userinput ("http://[::1]:8081" , "[::1]" ) is True
98
+
99
+
100
+ def test_loopback_ipv6_with_zeros_found ():
101
+ assert (
102
+ find_hostname_in_userinput (
103
+ "http://[0000:0000:0000:0000:0000:0000:0000:0001]:8081" ,
104
+ "[0000:0000:0000:0000:0000:0000:0000:0001]" ,
105
+ )
106
+ is True
107
+ )
108
+
109
+
110
+ def test_different_capitalization_found ():
111
+ assert find_hostname_in_userinput ("http://localHost:8081" , "localhost" ) is True
112
+
113
+
114
+ def test_2130706433_found ():
115
+ assert find_hostname_in_userinput ("http://2130706433:8081" , "2130706433" ) is True
116
+
117
+
118
+ def test_0x7f000001_found ():
119
+ assert find_hostname_in_userinput ("http://0x7f000001:8081" , "0x7f000001" ) is True
120
+
121
+
122
+ def test_0177_0_0_01_found ():
123
+ assert find_hostname_in_userinput ("http://0177.0.0.01:8081" , "0177.0.0.01" ) is True
124
+
125
+
126
+ def test_0x7f_0x0_0x0_0x1_found ():
127
+ assert (
128
+ find_hostname_in_userinput ("http://0x7f.0x0.0x0.0x1:8081" , "0x7f.0x0.0x0.0x1" )
129
+ is True
130
+ )
131
+
132
+
133
+ def test_ffff_127_0_0_1_found ():
134
+ assert (
135
+ find_hostname_in_userinput (
136
+ "http://[::ffff:127.0.0.1]:8081" , "[::ffff:127.0.0.1]"
137
+ )
138
+ is True
139
+ )
140
+
141
+
142
+ def test_loopback_ipv6_not_found ():
143
+ assert find_hostname_in_userinput ("http://[::1]:8081" , "localhost" ) is False
144
+
145
+
146
+ def test_loopback_ipv6_with_zeros_not_found ():
147
+ assert (
148
+ find_hostname_in_userinput (
149
+ "http://[0000:0000:0000:0000:0000:0000:0000:0001]:8081" , "localhost"
150
+ )
151
+ is False
152
+ )
153
+
154
+
155
+ def test_different_capitalization_not_found ():
156
+ assert find_hostname_in_userinput ("http://localHost:8081" , "example.com" ) is False
157
+
158
+
159
+ def test_2130706433_not_found ():
160
+ assert find_hostname_in_userinput ("http://2130706433:8081" , "example.com" ) is False
161
+
162
+
163
+ def test_0x7f000001_not_found ():
164
+ assert find_hostname_in_userinput ("http://0x7f000001:8081" , "example.com" ) is False
165
+
166
+
167
+ def test_0177_0_0_01_not_found ():
168
+ assert find_hostname_in_userinput ("http://0177.0.0.01:8081" , "example.com" ) is False
169
+
170
+
171
+ def test_0x7f_0x0_0x0_0x1_not_found ():
172
+ assert (
173
+ find_hostname_in_userinput ("http://0x7f.0x0.0x0.0x1:8081" , "example.com" )
174
+ is False
175
+ )
176
+
177
+
178
+ def test_ffff_127_0_0_1_not_found ():
179
+ assert (
180
+ find_hostname_in_userinput ("http://[::ffff:127.0.0.1]:8081" , "example.com" )
181
+ is False
182
+ )
0 commit comments