[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/develop] Rewrite commented out testDistWithPortRestrictions() in legacy_Tests.
commit 003165e7875412944b91785431ee1b749fda2a0d
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date: Mon Apr 20 03:34:40 2015 +0000
Rewrite commented out testDistWithPortRestrictions() in legacy_Tests.
---
lib/bridgedb/test/legacy_Tests.py | 22 ----------------------
lib/bridgedb/test/test_Dist.py | 25 +++++++++++++++++++++++++
2 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/lib/bridgedb/test/legacy_Tests.py b/lib/bridgedb/test/legacy_Tests.py
index 85ba722..2f1da67 100644
--- a/lib/bridgedb/test/legacy_Tests.py
+++ b/lib/bridgedb/test/legacy_Tests.py
@@ -185,28 +185,6 @@ class EmailBridgeDistTests(unittest.TestCase):
class IPBridgeDistTests(unittest.TestCase):
- #XXX: #6175 breaks this test!
- #def testDistWithPortRestrictions(self):
- # param = bridgedb.Bridges.BridgeRingParameters(needPorts=[(443, 1)])
- # d = bridgedb.Dist.HTTPSDistributor(3, "Baz",
- # answerParameters=param)
- # for _ in xrange(32):
- # d.insert(fakeBridge(443))
- # for _ in range(256):
- # d.insert(fakeBridge())
- # for _ in xrange(32):
- # i = randomIP()
- # n = d.getBridges(i, "x")
- # count = 0
- # fps = {}
- # for b in n:
- # fps[b.getID()] = 1
- # if b.orport == 443:
- # count += 1
- # self.assertEquals(len(fps), len(n))
- # self.assertEquals(len(fps), 5)
- # self.assertTrue(count >= 1)
-
def testDistWithFilterBlockedCountriesAdvanced(self):
d = bridgedb.Dist.HTTPSDistributor(3, "Foo")
for _ in xrange(250):
diff --git a/lib/bridgedb/test/test_Dist.py b/lib/bridgedb/test/test_Dist.py
index 18b3e79..e8a17e4 100644
--- a/lib/bridgedb/test/test_Dist.py
+++ b/lib/bridgedb/test/test_Dist.py
@@ -23,6 +23,7 @@ from bridgedb import Dist
from bridgedb.bridges import Bridge
from bridgedb.bridges import PluggableTransport
from bridgedb.Bridges import BridgeRing
+from bridgedb.Bridges import BridgeRingParameters
from bridgedb.Filters import filterBridgesByNotBlockedIn
from bridgedb.Filters import filterBridgesByIP4
from bridgedb.Filters import filterBridgesByIP6
@@ -282,6 +283,30 @@ class HTTPSDistributorTests(unittest.TestCase):
for i in range(4):
self.assertItemsEqual(responses[i], responses[i+1])
+ def test_HTTPSDistributor_getBridges_with_BridgeRingParameters(self):
+ param = BridgeRingParameters(needPorts=[(443, 1)])
+ dist = Dist.HTTPSDistributor(3, self.key, answerParameters=param)
+
+ bridges = self.bridges[:32]
+ for b in self.bridges:
+ b.orPort = 443
+
+ [dist.insert(bridge) for bridge in bridges]
+ [dist.insert(bridge) for bridge in self.bridges[:250]]
+
+ for _ in xrange(32):
+ bridgeRequest = self.randomClientRequest()
+ answer = dist.getBridges(bridgeRequest, 1)
+ count = 0
+ fingerprints = {}
+ for bridge in answer:
+ fingerprints[bridge.identity] = 1
+ if bridge.orPort == 443:
+ count += 1
+ self.assertEquals(len(fingerprints), len(answer))
+ self.assertGreater(len(fingerprints), 0)
+ self.assertTrue(count >= 1)
+
def test_HTTPSDistributor_getBridges_ipv4_ipv6(self):
"""Asking for bridge addresses which are simultaneously IPv4 and IPv6
(in that order) should return IPv4 bridges.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits