@@ -860,6 +860,8 @@ def test_is_HDN(self):
860860 self .assertTrue (is_HDN ("foo.bar.com" ))
861861 self .assertTrue (is_HDN ("1foo2.3bar4.5com" ))
862862 self .assertFalse (is_HDN ("192.168.1.1" ))
863+ self .assertFalse (is_HDN ("[::1]" ))
864+ self .assertFalse (is_HDN ("[2001:db8:85a3::8a2e:370:7334]" ))
863865 self .assertFalse (is_HDN ("" ))
864866 self .assertFalse (is_HDN ("." ))
865867 self .assertFalse (is_HDN (".foo.bar.com" ))
@@ -875,9 +877,14 @@ def test_reach(self):
875877 self .assertEqual (reach ("." ), "." )
876878 self .assertEqual (reach ("" ), "" )
877879 self .assertEqual (reach ("192.168.0.1" ), "192.168.0.1" )
880+ self .assertEqual (reach ("[::1]" ), "[::1]" )
881+ self .assertEqual (reach ("[2001:db8:85a3::8a2e:370:7334]" ), "[2001:db8:85a3::8a2e:370:7334]" )
878882
879883 def test_domain_match (self ):
880884 self .assertTrue (domain_match ("192.168.1.1" , "192.168.1.1" ))
885+ self .assertTrue (domain_match ("[::1]" , "[::1]" ))
886+ self .assertFalse (domain_match ("[::1]" , "::1" ))
887+ self .assertTrue (domain_match ("[2001:db8:85a3::8a2e:370:7334]" , "[2001:db8:85a3::8a2e:370:7334]" ))
881888 self .assertFalse (domain_match ("192.168.1.1" , ".168.1.1" ))
882889 self .assertTrue (domain_match ("x.y.com" , "x.Y.com" ))
883890 self .assertTrue (domain_match ("x.y.com" , ".Y.com" ))
@@ -906,6 +913,9 @@ def test_domain_match(self):
906913 self .assertFalse (user_domain_match ("x.y.com" , "" ))
907914 self .assertFalse (user_domain_match ("x.y.com" , "." ))
908915 self .assertTrue (user_domain_match ("192.168.1.1" , "192.168.1.1" ))
916+ self .assertTrue (user_domain_match ("[::1]" , "[::1]" ))
917+ self .assertFalse (user_domain_match ("[::1]" , "::1" ))
918+ self .assertTrue (domain_match ("[2001:db8:85a3::8a2e:370:7334]" , "[2001:db8:85a3::8a2e:370:7334]" ))
909919 # not both HDNs, so must string-compare equal to match
910920 self .assertFalse (user_domain_match ("192.168.1.1" , ".168.1.1" ))
911921 self .assertFalse (user_domain_match ("192.168.1.1" , "." ))
@@ -1168,12 +1178,30 @@ def test_domain_block(self):
11681178 c .add_cookie_header (req )
11691179 self .assertFalse (req .has_header ("Cookie" ))
11701180
1181+ c .clear ()
1182+
11711183 pol .set_blocked_domains (["[::1]" ])
11721184 req = urllib .request .Request ("http://[::1]:8080" )
11731185 res = FakeResponse (headers , "http://[::1]:8080" )
11741186 c .extract_cookies (res , req )
11751187 self .assertEqual (len (c ), 0 )
11761188
1189+ pol .set_blocked_domains (["[2001:db8:85a3::8a2e:370:7334]" ])
1190+ req = urllib .request .Request ("http://[2001:db8:85a3::8a2e:370:7334]:8080" )
1191+ res = FakeResponse (headers , "http://[2001:db8:85a3::8a2e:370:7334]:8080" )
1192+ c .extract_cookies (res , req )
1193+ self .assertEqual (len (c ), 0 )
1194+
1195+ pol .set_blocked_domains (["" ])
1196+ req = urllib .request .Request ("http://[::1]:8080" )
1197+ res = FakeResponse (headers , "http://[::1]:8080" )
1198+ c .extract_cookies (res , req )
1199+ self .assertEqual (len (c ), 1 )
1200+
1201+ c .clear ()
1202+
1203+
1204+
11771205 def test_secure (self ):
11781206 for ns in True , False :
11791207 for whitespace in " " , "" :
0 commit comments