[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/master] Add test for Bridge.updateFromExtraInfoDescriptor() with a changed PT.
commit d1909c8a0aa52168d9456df7b0a06f432c61dce5
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date: Sat Feb 14 00:50:29 2015 +0000
Add test for Bridge.updateFromExtraInfoDescriptor() with a changed PT.
This tests what happens if we receive an updated extrainfo descriptor
for a Bridge where one of its PTs has changed its port number.
---
lib/bridgedb/test/test_bridges.py | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/lib/bridgedb/test/test_bridges.py b/lib/bridgedb/test/test_bridges.py
index bae418a..ae9aa92 100644
--- a/lib/bridgedb/test/test_bridges.py
+++ b/lib/bridgedb/test/test_bridges.py
@@ -904,6 +904,34 @@ class BridgeTests(unittest.TestCase):
self.assertEqual(len(self.bridge.transports), 0)
self.assertIsNone(self.bridge.descriptors['extrainfo'])
+ def test_Bridge_updateFromExtraInfoDescriptor_pt_changed_port(self):
+ """Calling updateFromExtraInfoDescriptor() with a descriptor which
+ includes a different port for a known bridge with a known pluggable
+ transport should update that transport.
+ """
+ self.bridge.updateFromNetworkStatus(self.networkstatus)
+ self.bridge.updateFromServerDescriptor(self.serverdescriptor)
+ self.bridge.updateFromExtraInfoDescriptor(self.extrainfo)
+
+ self.assertEqual(len(self.bridge.transports), 4)
+
+ for pt in self.bridge.transports:
+ if pt.methodname == 'obfs4':
+ self.assertEqual(pt.address, ipaddr.IPv4Address('179.178.155.140'))
+ self.assertEqual(pt.port, 36493)
+
+ # Change the port of obfs4 transport in the extrainfo descriptor:
+ transportline = self.extrainfo.transport['obfs4']
+ self.extrainfo.transport['obfs4'] = (transportline[0],
+ 31337,
+ transportline[2])
+ self.bridge.updateFromExtraInfoDescriptor(self.extrainfo)
+
+ for pt in self.bridge.transports:
+ if pt.methodname == 'obfs4':
+ self.assertEqual(pt.address, ipaddr.IPv4Address('179.178.155.140'))
+ self.assertEqual(pt.port, 31337)
+
def test_Bridge_updateFromExtraInfoDescriptor_pt_changed_args(self):
"""Calling updateFromExtraInfoDescriptor() with a descriptor which
includes different PT args for a known bridge with a known pluggable
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits