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

[tor-commits] [bridgedb/develop] Merge branch 'fix/13202-missing-pt-args' into develop



commit 60c0e8a7cac1273b8d5422f591bc1c84882fbeec
Merge: 6a1a935 3827008
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Fri Mar 27 00:01:03 2015 +0000

    Merge branch 'fix/13202-missing-pt-args' into develop
    
    Conflicts:
    	lib/bridgedb/test/test_bridges.py

 lib/bridgedb/bridges.py           |   52 ++++++++++++++----
 lib/bridgedb/test/test_bridges.py |  107 +++++++++++++++++++++++++++++++++++++
 2 files changed, 150 insertions(+), 9 deletions(-)

diff --cc lib/bridgedb/test/test_bridges.py
index 1755e6f,e9e0526..5a79d5e
--- a/lib/bridgedb/test/test_bridges.py
+++ b/lib/bridgedb/test/test_bridges.py
@@@ -1473,39 -1411,54 +1528,91 @@@ class BridgeTests(unittest.TestCase)
          self.assertTrue(self.bridge.addressIsBlockedIn('GB', '179.178.155.140', 36493))
          self.assertFalse(self.bridge.addressIsBlockedIn('gb', '179.178.155.140', 36488))
  
 +    def test_Bridge_updateFromExtraInfoDescriptor_changed_no_verify(self):
 +        """A changed extrainfo descriptor should log that a transport's
 +        IP and/or port changed.
 +        """
 +        self.bridge.updateFromNetworkStatus(self.networkstatus)
 +        self.bridge.updateFromServerDescriptor(self.serverdescriptor)
 +        self.bridge.updateFromExtraInfoDescriptor(self.extrainfo)
 +
 +        changedExtrainfo = BRIDGE_EXTRAINFO
 +        changedExtrainfo.replace('transport obfs3 179.178.155.140:36490',
 +                                 'transport obfs3 179.178.155.14:3649')
 +        self._writeExtrainfo(changedExtrainfo)
 +
 +        self.bridge.updateFromExtraInfoDescriptor(self.extrainfo, verify=False)
 +
 +    def test_Bridge_updateFromExtraInfoDescriptor_changed_verify(self):
 +        """A changed extrainfo descriptor with verify=True should raise an
 +        InvalidExtraInfoSignature exception.
 +        """
 +        self.bridge.updateFromNetworkStatus(self.networkstatus)
 +        self.bridge.updateFromServerDescriptor(self.serverdescriptor)
 +        self.bridge.updateFromExtraInfoDescriptor(self.extrainfo)
 +        self.bridge.updateFromExtraInfoDescriptor(self.extrainfoNew)
 +
 +        # We should have hit the return just after the
 +        # `except InvalidExtraInfoSignature` line, and so the
 +        # bridge.descriptors['extrainfo'] shouldn't have been updated.
 +        # Therefore, the one we stored should be older, that is, we shouldn't
 +        # have kept the new one.
 +        self.assertLess(self.bridge.descriptors['extrainfo'].published,
 +                        self.extrainfoNew.published)
 +        # And the one we stored should be the older one, with the same
 +        # published timestamp:
 +        self.assertEqual(self.bridge.descriptors['extrainfo'], self.extrainfo)
 +        self.assertEqual(self.bridge.descriptors['extrainfo'].published,
 +                         self.extrainfo.published)
++
+     def test_Bridge_updateFromExtraInfoDescriptor_obfs4_no_iatmode(self):
+         """An extrainfo descriptor with an obfs4 transport missing the
+         `iat-mode=[â?¦]` argument should not add the obfs4 transport.
+         """
+         self.bridge.updateFromNetworkStatus(self.networkstatus)
+         self.bridge.updateFromServerDescriptor(self.serverdescriptor)
+ 
+         obfs4 = self.extrainfo.transport['obfs4']
+         obfs4 = (u'1.1.1.1', 1111, obfs4[-1][-1].replace('iat-mode=0,', ''))
+ 
+         self.extrainfo.transport['obfs4'] = obfs4
+         self.bridge.updateFromExtraInfoDescriptor(self.extrainfo)
+ 
+         self.assertTrue(len(self.bridge.transports), 3)
+         self.assertNotIn('obfs4',
+                          [pt.methodname for pt in self.bridge.transports])
+ 
+     def test_Bridge_updateFromExtraInfoDescriptor_scramblesuit_no_password(self):
+         """An extrainfo descriptor with `transport scramblesuit 1.1.1.1:1111`
+         (i.e. missing the `password=[â?¦]` argument) should not add the
+         scramblesuit transport.
+         """
+         self.bridge.updateFromNetworkStatus(self.networkstatus)
+         self.bridge.updateFromServerDescriptor(self.serverdescriptor)
+ 
+         self.extrainfo.transport['scramblesuit'] = (u'1.1.1.1', 1111, [])
+         self.bridge.updateFromExtraInfoDescriptor(self.extrainfo)
+ 
+         self.assertTrue(len(self.bridge.transports), 3)
+         self.assertNotIn('scramblesuit',
+                          [pt.methodname for pt in self.bridge.transports])
+ 
+     def test_Bridge_updateFromExtraInfoDescriptor_changed_scramblesuit_no_password(self):
+         """An extrainfo descriptor whose scramblesuit transport was previously
+         valid and is now missing the `password=[â?¦]` argument should be removed
+         from the Bridge.transports list.
+         """
+         self.bridge.updateFromNetworkStatus(self.networkstatus)
+         self.bridge.updateFromServerDescriptor(self.serverdescriptor)
+         self.bridge.updateFromExtraInfoDescriptor(self.extrainfo)
+ 
+         self.assertTrue(len(self.bridge.transports), 4)
+         self.assertIn('scramblesuit',
+                       [pt.methodname for pt in self.bridge.transports])
+ 
+         self.extrainfo.transport['scramblesuit'] = (u'1.1.1.1', 1111, [])
+         self.bridge.updateFromExtraInfoDescriptor(self.extrainfo)
+ 
+         self.assertTrue(len(self.bridge.transports), 3)
+         self.assertNotIn('scramblesuit',
+                          [pt.methodname for pt in self.bridge.transports])



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