[tor-commits] [bridgedb/master] Add two tests for getBridgeLine() and _constructBridgeLine() for IPv6.

isis at torproject.org isis at torproject.org
Fri May 1 07:10:57 UTC 2015


commit 5dba09ae563a164a934003d73eaf6209f8d6bd55
Author: Isis Lovecruft <isis at torproject.org>
Date:   Thu Mar 26 23:52:12 2015 +0000

    Add two tests for getBridgeLine() and _constructBridgeLine() for IPv6.
---
 lib/bridgedb/test/test_bridges.py |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/lib/bridgedb/test/test_bridges.py b/lib/bridgedb/test/test_bridges.py
index 1592f00..86d0cf1 100644
--- a/lib/bridgedb/test/test_bridges.py
+++ b/lib/bridgedb/test/test_bridges.py
@@ -921,6 +921,18 @@ class BridgeTests(unittest.TestCase):
         identifier = str(bridge)
         self.assertEqual(identifier, ''.join(['$', '0'*40, '~', 'Unnamed']))
 
+    def test_Bridge_constructBridgeLine_IPv6(self):
+        """Bridge._constructBridgeLine() called with an IPv6 address should
+        wrap the IPv6 address in '[]' in the returned bridge line.
+        """
+        bridge = bridges.Bridge()
+        addrport = (u'6bf3:806b:78cd::4ced:cfad:dad4', 36488, 6)
+
+        bridgeline = bridge._constructBridgeLine(addrport,
+                                                 includeFingerprint=False,
+                                                 bridgePrefix=True)
+        self.assertEqual(bridgeline, 'Bridge [6bf3:806b:78cd::4ced:cfad:dad4]:36488')
+
     def test_Bridge_updateFromNetworkStatus_IPv4_ORAddress(self):
         """Calling updateFromNetworkStatus() with a descriptor which has an
         IPv4 address as an additional ORAddress should result in a
@@ -1259,6 +1271,25 @@ class BridgeTests(unittest.TestCase):
         self.assertNotIn('179.178.155.140:36493', line)
         self.assertIn('2C3225C4805331025E211F4B6E5BF45C333FDD2C', line)
 
+    def test_Bridge_getBridgeLine_IPv6_no_fingerprint(self):
+        """Calling getBridgeLine(includeFingerprint=False) with a valid request
+        for IPv6 bridges should return a bridge line without the fingerprint.
+        """
+        self.bridge.updateFromNetworkStatus(self.networkstatus)
+        self.bridge.updateFromServerDescriptor(self.serverdescriptor)
+        self.bridge.updateFromExtraInfoDescriptor(self.extrainfo)
+
+        request = BridgeRequestBase()
+        request.isValid(True)
+        request.withIPv6()
+        line = self.bridge.getBridgeLine(request, includeFingerprint=False)
+
+        self.assertIsNotNone(line)
+        self.assertTrue(
+            line.startswith('[6bf3:806b:78cd:d4b4:f6a7:4ced:cfad:dad4]:36488'))
+        self.assertNotIn('179.178.155.140:36493', line)
+        self.assertNotIn('2C3225C4805331025E211F4B6E5BF45C333FDD2C', line)
+
     def test_Bridge_getBridgeLine_obfs4(self):
         """ """
         self.bridge.updateFromNetworkStatus(self.networkstatus)





More information about the tor-commits mailing list