[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/master] BridgeRequest.notBlockedIn country codes should be lowercased.



commit c712736cc04b0423a18fb9582e8d11c0bf663057
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Thu Apr 16 07:02:44 2015 +0000

    BridgeRequest.notBlockedIn country codes should be lowercased.
---
 lib/bridgedb/bridgerequest.py           |    4 ++--
 lib/bridgedb/https/request.py           |    4 ++--
 lib/bridgedb/test/test_bridgerequest.py |    2 +-
 lib/bridgedb/test/test_https_request.py |   12 ++++++------
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/lib/bridgedb/bridgerequest.py b/lib/bridgedb/bridgerequest.py
index f7aa031..f4eaaa4 100644
--- a/lib/bridgedb/bridgerequest.py
+++ b/lib/bridgedb/bridgerequest.py
@@ -150,7 +150,7 @@ class BridgeRequestBase(object):
         self.addressClass = ipaddr.IPv6Address
 
     def withoutBlockInCountry(self, country):
-        self.notBlockedIn.append(country)
+        self.notBlockedIn.append(country.lower())
 
     def withPluggableTransportType(self, pt):
         self.transports.append(pt)
@@ -182,6 +182,6 @@ class BridgeRequestBase(object):
             self.addFilter(Filters.filterBridgesByTransport(transport,
                                                             self.addressClass))
         for country in self.notBlockedIn:
-            self.addFilter(Filters.filterBridgesByNotBlockedIn(country,
+            self.addFilter(Filters.filterBridgesByNotBlockedIn(country.lower(),
                                                                self.addressClass,
                                                                transport))
diff --git a/lib/bridgedb/https/request.py b/lib/bridgedb/https/request.py
index 37b3ed6..0ae52c7 100644
--- a/lib/bridgedb/https/request.py
+++ b/lib/bridgedb/https/request.py
@@ -106,7 +106,7 @@ class HTTPSBridgeRequest(bridgerequest.BridgeRequestBase):
                 pass
             else:
                 if country:
-                    self.notBlockedIn.append(country)
+                    self.notBlockedIn.append(country.lower())
                     logging.info("HTTPS request for bridges not blocked in: %r"
                                  % country)
 
@@ -116,7 +116,7 @@ class HTTPSBridgeRequest(bridgerequest.BridgeRequestBase):
             if addr.isIPAddress(self.client):
                 country = geo.getCountryCode(ipaddr.IPAddress(self.client))
                 if country:
-                    self.notBlockedIn.append(country)
+                    self.notBlockedIn.append(country.lower())
                     logging.info(
                         ("HTTPS client's bridges also shouldn't be blocked "
                          "in their GeoIP country code: %s") % country)
diff --git a/lib/bridgedb/test/test_bridgerequest.py b/lib/bridgedb/test/test_bridgerequest.py
index 3392a4e..ccbf406 100644
--- a/lib/bridgedb/test/test_bridgerequest.py
+++ b/lib/bridgedb/test/test_bridgerequest.py
@@ -34,7 +34,7 @@ class BridgeRequestBaseTests(unittest.TestCase):
         to the ``notBlockedIn`` attribute.
         """
         self.request.withoutBlockInCountry('US')
-        self.assertIn('US', self.request.notBlockedIn)
+        self.assertIn('us', self.request.notBlockedIn)
 
     def test_BridgeRequestBase_withPluggableTransportType(self):
         """BridgeRequestBase.withPluggableTransportType() should add the
diff --git a/lib/bridgedb/test/test_https_request.py b/lib/bridgedb/test/test_https_request.py
index 286e6eb..c39662f 100644
--- a/lib/bridgedb/test/test_https_request.py
+++ b/lib/bridgedb/test/test_https_request.py
@@ -43,28 +43,28 @@ class HTTPSBridgeRequestTests(unittest.TestCase):
         """HTTPSBridgeRequest.withoutBlockInCountry() should add the country CC
         to the ``notBlockedIn`` attribute.
         """
-        httprequest = MockRequest({'unblocked': ['IR']})
+        httprequest = MockRequest({'unblocked': ['ir']})
         self.request.withoutBlockInCountry(httprequest)
-        self.assertIn('IR', self.request.notBlockedIn)
+        self.assertIn('ir', self.request.notBlockedIn)
 
     def test_HTTPSBridgeRequest_withoutBlockInCountry_US(self):
         """HTTPSBridgeRequest.withoutBlockInCountry() should add the country CC
         to the ``notBlockedIn`` attribute (and not any other countries).
         """
-        httprequest = MockRequest({'unblocked': ['US']})
+        httprequest = MockRequest({'unblocked': ['us']})
         self.request.withoutBlockInCountry(httprequest)
-        self.assertNotIn('IR', self.request.notBlockedIn)
+        self.assertNotIn('ir', self.request.notBlockedIn)
 
     def test_HTTPSBridgeRequest_withoutBlockInCountry_no_addClientCountryCode(self):
         """HTTPSBridgeRequest.withoutBlockInCountry(), when
         addClientCountryCode=False, shouldn't add the client's country code to the
         ``notBlockedIn`` attribute.
         """
-        httprequest = MockRequest({'unblocked': ['NL']})
+        httprequest = MockRequest({'unblocked': ['nl']})
         self.request = request.HTTPSBridgeRequest(addClientCountryCode=False)
         self.request.client = '5.5.5.5'
         self.request.withoutBlockInCountry(httprequest)
-        self.assertItemsEqual(['NL'], self.request.notBlockedIn)
+        self.assertItemsEqual(['nl'], self.request.notBlockedIn)
 
     def test_HTTPSBridgeRequest_withoutBlockInCountry_bad_params(self):
         """HTTPSBridgeRequest.withoutBlockInCountry() should stop processing if



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits