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

[tor-commits] [bridgedb/develop] Add unittest for parseNetworkStatusFile() with a bad router nickname.



commit fe5a4a64db3a73127a2a6cba474b6f5a7a753962
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Sat Feb 14 00:41:00 2015 +0000

    Add unittest for parseNetworkStatusFile() with a bad router nickname.
---
 lib/bridgedb/test/test_parse_descriptors.py |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/lib/bridgedb/test/test_parse_descriptors.py b/lib/bridgedb/test/test_parse_descriptors.py
index 738360f..d67ff88 100644
--- a/lib/bridgedb/test/test_parse_descriptors.py
+++ b/lib/bridgedb/test/test_parse_descriptors.py
@@ -270,6 +270,22 @@ class ParseDescriptorsTests(unittest.TestCase):
         self.assertIn(bridge.address, expectedIPs)
         self.assertEqual(bridge.fingerprint, self.expectedFprBridge0)
 
+    def test_parse_descriptors_parseNetworkStatusFile_bad_nickname(self):
+        """``b.p.descriptors.parseNetworkStatusFile`` with a bridge
+        networkstatus descriptor which has a nickname that is too long should
+        raise InvalidRouterNickname.
+        """
+        unparseable = BRIDGE_NETWORKSTATUS_0.replace(
+            'MiserLandfalls',
+            'MiserLandfallsWaterfallsSnowfallsAvalanche')
+        # Write the descriptor to a file for testing. This is necessary
+        # because the function opens the networkstatus file to read it.
+        descFile = self.writeTestDescriptorsToFile('networkstatus-bridges',
+                                                   unparseable)
+        self.assertRaises(descriptors.InvalidRouterNickname,
+                          descriptors.parseNetworkStatusFile,
+                          descFile)
+
     def test_parse_descriptors_parseNetworkStatusFile_with_annotations(self):
         """Test ``b.p.descriptors.parseNetworkStatusFile`` with some document
         headers before the first 'r'-line.



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