@@ -368,6 +368,7 @@ def test_domain_return_ok(self):
368
368
("http://foo.bar.com/" , ".foo.bar.com" , True ),
369
369
("http://foo.bar.com/" , "foo.bar.com" , True ),
370
370
("http://foo.bar.com/" , ".bar.com" , True ),
371
+ ("http://foo.bar.com/" , "bar.com" , True ),
371
372
("http://foo.bar.com/" , "com" , True ),
372
373
("http://foo.com/" , "rhubarb.foo.com" , False ),
373
374
("http://foo.com/" , ".foo.com" , True ),
@@ -378,6 +379,8 @@ def test_domain_return_ok(self):
378
379
("http://foo/" , "foo" , True ),
379
380
("http://foo/" , "foo.local" , True ),
380
381
("http://foo/" , ".local" , True ),
382
+ ("http://barfoo.com" , ".foo.com" , False ),
383
+ ("http://barfoo.com" , "foo.com" , False ),
381
384
]:
382
385
request = urllib2 .Request (url )
383
386
r = pol .domain_return_ok (domain , request )
@@ -938,6 +941,31 @@ def test_domain_block(self):
938
941
c .add_cookie_header (req )
939
942
self .assertFalse (req .has_header ("Cookie" ))
940
943
944
+ c .clear ()
945
+
946
+ pol .set_blocked_domains ([])
947
+ req = Request ("http://acme.com/" )
948
+ res = FakeResponse (headers , "http://acme.com/" )
949
+ c .extract_cookies (res , req )
950
+ self .assertEqual (len (c ), 1 )
951
+
952
+ req = Request ("http://acme.com/" )
953
+ c .add_cookie_header (req )
954
+ self .assertTrue (req .has_header ("Cookie" ))
955
+
956
+ req = Request ("http://badacme.com/" )
957
+ c .add_cookie_header (req )
958
+ self .assertFalse (req .has_header ("Cookie" ))
959
+
960
+ p = pol .set_blocked_domains (["acme.com" ])
961
+ req = Request ("http://acme.com/" )
962
+ c .add_cookie_header (req )
963
+ self .assertFalse (req .has_header ("Cookie" ))
964
+
965
+ req = Request ("http://badacme.com/" )
966
+ c .add_cookie_header (req )
967
+ self .assertFalse (req .has_header ("Cookie" ))
968
+
941
969
def test_secure (self ):
942
970
from cookielib import CookieJar , DefaultCookiePolicy
943
971
0 commit comments