commit dcafe58630f9048b7829184675a9a93deda2f0a3 Author: Isis Lovecruft isis@torproject.org Date: Sun Apr 19 05:43:39 2015 +0000
Rewrite testDistWithProxies() in legacy_Tests. --- lib/bridgedb/test/legacy_Tests.py | 21 --------------------- lib/bridgedb/test/test_Dist.py | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/lib/bridgedb/test/legacy_Tests.py b/lib/bridgedb/test/legacy_Tests.py index fd6a739..85ba722 100644 --- a/lib/bridgedb/test/legacy_Tests.py +++ b/lib/bridgedb/test/legacy_Tests.py @@ -185,27 +185,6 @@ class EmailBridgeDistTests(unittest.TestCase):
class IPBridgeDistTests(unittest.TestCase):
- def testDistWithProxies(self): - d = bridgedb.Dist.HTTPSDistributor(3, "Foo", [RhymesWith255ProxySet()]) - for _ in xrange(256): - d.insert(fakeBridge()) - - for _ in xrange(256): - # Make sure that the ProxySets do not overlap - f = lambda: ".".join([str(random.randrange(1,255)) for _ in xrange(4)]) - g = lambda: ".".join([str(random.randrange(1,255)) for _ in xrange(3)] + ['255']) - n = d.getBridges(g(), "x") - n2 = d.getBridges(f(), "x") - - assert(len(n) > 0) - assert(len(n2) > 0) - - for b in n: - assert (b not in n2) - - for b in n2: - assert (b not in n) - #XXX: #6175 breaks this test! #def testDistWithPortRestrictions(self): # param = bridgedb.Bridges.BridgeRingParameters(needPorts=[(443, 1)]) diff --git a/lib/bridgedb/test/test_Dist.py b/lib/bridgedb/test/test_Dist.py index 23a6492..18b3e79 100644 --- a/lib/bridgedb/test/test_Dist.py +++ b/lib/bridgedb/test/test_Dist.py @@ -243,6 +243,30 @@ class HTTPSDistributorTests(unittest.TestCase): self.assertNotIn(b.fingerprint, blockedIR) self.assertGreater(len(bridges), 0)
+ def test_HTTPSDistributor_getBridges_with_proxy_and_nonproxy_users(self): + """An HTTPSDistributor should give separate bridges to proxy users.""" + proxies = ProxySet(['.'.join(['1.1.1', str(x)]) for x in range(1, 256)]) + dist = Dist.HTTPSDistributor(3, self.key, proxies) + [dist.insert(bridge) for bridge in self.bridges] + + for _ in range(10): + bridgeRequest1 = self.randomClientRequest() + bridgeRequest1.client = '.'.join(['1.1.1', str(random.randrange(1, 255))]) + + bridgeRequest2 = self.randomClientRequest() + bridgeRequest2.client = '.'.join(['9.9.9', str(random.randrange(1, 255))]) + + n1 = dist.getBridges(bridgeRequest1, 1) + n2 = dist.getBridges(bridgeRequest2, 1) + + self.assertGreater(len(n1), 0) + self.assertGreater(len(n2), 0) + + for b in n1: + self.assertNotIn(b, n2) + for b in n2: + self.assertNotIn(b, n1) + def test_HTTPSDistributor_getBridges_same_bridges_to_same_client(self): """The same client asking for bridges from the HTTPSDistributor multiple times in a row should get the same bridges in response each
tor-commits@lists.torproject.org