commit 777f2389fc6f1e7cb728966f5be204bf062ccf32 Author: Isis Lovecruft isis@torproject.org Date: Fri Feb 13 01:05:16 2015 +0000
Add two unittests for bridgedb.bridges.Bridge.assertOK().
* ADD test_Bridge_assertOK() which checks the case where everything is in fact okay. * ADD test_Bridge_assertOK_all_bad_values() which checks the case where everything is totes not okay. --- lib/bridgedb/test/test_bridges.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/lib/bridgedb/test/test_bridges.py b/lib/bridgedb/test/test_bridges.py index 8ff0557..e87ff8a 100644 --- a/lib/bridgedb/test/test_bridges.py +++ b/lib/bridgedb/test/test_bridges.py @@ -920,3 +920,23 @@ class BridgeTests(unittest.TestCase): self.assertRaises(bridges.ServerDescriptorDigestMismatch, self.bridge.updateFromServerDescriptor, self.serverdescriptor) + + def test_Bridge_assertOK(self): + """If all orAddresses are okay, then assertOK() should return None.""" + self.bridge.updateFromNetworkStatus(self.networkstatus) + self.bridge.updateFromServerDescriptor(self.serverdescriptor) + + self.assertIsNone(self.bridge.assertOK()) + + def test_Bridge_assertOK_all_bad_values(self): + """If an orAddress has an IP address of 999.999.999.999 and a port of + -1 and claims to be IPv5, then everything about it is bad and it should + fail all the checks in assertOK(), then a MalformedBridgeInfo should be + raised. + """ + self.bridge.updateFromNetworkStatus(self.networkstatus) + self.bridge.updateFromServerDescriptor(self.serverdescriptor) + + # All values are bad (even though IPv5 is a thing): + self.bridge.orAddresses.append(('999.999.999.999', -1, 5)) + self.assertRaises(bridges.MalformedBridgeInfo, self.bridge.assertOK)
tor-commits@lists.torproject.org