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

[tor-commits] [bridgedb/develop] Remove Bridges.getDescriptorDigests().



commit 016815deee25cfb27e474bb8f5be24af68ce0058
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Wed Feb 11 01:22:33 2015 +0000

    Remove Bridges.getDescriptorDigests().
    
    The functionality for checking the server-descriptor digest is now in
    bridgedb.bridges.Bridge.updateFromServerDescriptor(), which calls
    bridgedb.bridges.Bridge._checkServerDescriptor(). The digests are
    retrieved per-descriptor, during
    bridgedb.bridges.updateFromNetworkStatus().
    
     * REMOVE bridgedb.Bridges.getDescriptorDigests() function.
---
 lib/bridgedb/Bridges.py           |   34 ----------------------------------
 lib/bridgedb/test/test_bridges.py |   22 ----------------------
 2 files changed, 56 deletions(-)

diff --git a/lib/bridgedb/Bridges.py b/lib/bridgedb/Bridges.py
index 9e7c292..a8b0a4f 100644
--- a/lib/bridgedb/Bridges.py
+++ b/lib/bridgedb/Bridges.py
@@ -42,40 +42,6 @@ DIGEST_LEN = 20
 PORTSPEC_LEN = 16
 
 
-def getDescriptorDigests(desc):
-    """Return the SHA-1 hash hexdigests of all descriptor descs
-
-    :param File desc: A string containing the contents of one
-                      or more bridge descriptors concatenated
-                      together.
-    :returns: A dict indexed by the SHA-1 hexdigest of the bridge
-              descriptor, equivalent to that which was published
-              on the 'r' line of the networkstatus for this bridge.
-              The value is the bridge's extra-info document digest,
-              or None, if not provided.
-    """
-    if not desc: return None
-
-    descriptors = {}
-    sha1hash = hashlib.sha1()
-    ei_digest = None
-
-    for line in desc:
-        if line != '-----BEGIN SIGNATURE-----\n':
-            sha1hash.update(line)
-            if line.startswith('extra-info-digest'):
-                parts = line.split()
-                if len(parts) == 2:
-                    ei_digest = parts[1].lower()
-        else:
-            digest = sha1hash.hexdigest().lower()
-            descriptors[digest] = ei_digest
-            while line != '-----END SIGNATURE-----\n':
-                line = next(desc)
-            sha1hash = hashlib.sha1()
-            ei_digest = None
-    return descriptors
-
 def getExtraInfoDigests(doc):
     """Return the SHA-1 hash hexdigests of all extra-info documents
 
diff --git a/lib/bridgedb/test/test_bridges.py b/lib/bridgedb/test/test_bridges.py
index c481578..aff6e65 100644
--- a/lib/bridgedb/test/test_bridges.py
+++ b/lib/bridgedb/test/test_bridges.py
@@ -134,7 +134,6 @@ class BridgeIntegrationTests(unittest.TestCase):
     test_getConfigLine_vanilla_withoutFingerprint   test_integration_getConfigLine_vanilla_withoutFingerprint
     test_getConfigLine_vanilla_withFingerprint      test_integration_getConfigLine_vanilla_withFingerprint
     test_getConfigLine_scramblesuit_withFingeprint  test_integration_getConfigLine_scramblesuit_withFingerprint
-    test_getDescriptorDigests                       test_integration_getDescriptorDigests
     test_getExtraInfoDigests                        test_integration_getExtraInfoDigests
     test_splitterBridgeInsertion                    test_integration_splitterBridgeInsertion
     ==============================================  ========================
@@ -287,27 +286,6 @@ class BridgeIntegrationTests(unittest.TestCase):
                          % (self.fingerprint, ptArgsList),
                          bridgeLine)
 
-    def test_integration_getDescriptorDigests(self):
-        raise unittest.SkipTest(
-            ("The functions getDescriptorDigests() and getExtraInfoDigests() "
-             "have not been refactored into the new bridgedb.bridges module "
-             "because it's not clear yet if they're necessary. Skip these "
-             "tests for now."))
-
-        sha1hash = hashlib.sha1()
-        ei_digest = 'abcdefghijklmno'
-
-        test = "this is a test line\nFollowed by another\n"
-        test += "extra-info-digest %s\n" % ei_digest
-        sha1hash.update(test)
-        digest = sha1hash.hexdigest()
-        test += "-----BEGIN SIGNATURE-----\n"
-        test += "This is a test line that should be skipped\n"
-        test += "-----END SIGNATURE-----\n"
-        digests = bridges.getDescriptorDigests(io.StringIO(test))
-        self.failUnlessIn(digest, digests)
-        self.failUnlessEqual(ei_digest, digests[digest])
-
     def test_integration_getExtraInfoDigests(self):
         raise unittest.SkipTest(
             ("The functions getDescriptorDigests() and getExtraInfoDigests() "



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