[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/develop] Remove Bridges.getExtraInfoDigests().
commit 0e8200f0352865ea3eb3ce235bf431677a835598
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date: Wed Feb 11 01:29:04 2015 +0000
Remove Bridges.getExtraInfoDigests().
This functionality is now built into the bridgedb.bridges.Bridge class,
and the retrieval of the digest values is done per-descriptor.
* REMOVE bridgedb.Bridges.getExtraInfoDigests() function.
---
lib/bridgedb/Bridges.py | 31 -------------------------------
lib/bridgedb/test/test_bridges.py | 24 ------------------------
2 files changed, 55 deletions(-)
diff --git a/lib/bridgedb/Bridges.py b/lib/bridgedb/Bridges.py
index a8b0a4f..e92e23e 100644
--- a/lib/bridgedb/Bridges.py
+++ b/lib/bridgedb/Bridges.py
@@ -42,37 +42,6 @@ DIGEST_LEN = 20
PORTSPEC_LEN = 16
-def getExtraInfoDigests(doc):
- """Return the SHA-1 hash hexdigests of all extra-info documents
-
- :param File doc: A string containing the contents of one
- or more bridge extra-info documents concatenated
- together.
- :returns: A dict indexed by the SHA-1 hexdigest of the bridge
- extra-info doc, equivalent to that which was published
- on the 'extra-info-digest' line of the bridge's
- descriptor. The value is the bridge's extra-info document
- digest, or None, if not provided.
- """
- if not doc: return None
-
- documents = {}
- sha1hash = hashlib.sha1()
- document_content = ''
-
- for line in doc:
- if line != '-----BEGIN SIGNATURE-----\n':
- sha1hash.update(line)
- document_content += line
- else:
- digest = sha1hash.hexdigest().lower()
- documents[digest] = StringIO(document_content)
- while line != '-----END SIGNATURE-----\n':
- line = next(doc)
- sha1hash = hashlib.sha1()
- document_content = ''
- return documents
-
def parseDescFile(f, bridge_purpose='bridge'):
"""Generator. Parses a cached-descriptors file 'f' and yeilds a Bridge object
for every entry whose purpose matches bridge_purpose.
diff --git a/lib/bridgedb/test/test_bridges.py b/lib/bridgedb/test/test_bridges.py
index aff6e65..8ff0557 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_getExtraInfoDigests test_integration_getExtraInfoDigests
test_splitterBridgeInsertion test_integration_splitterBridgeInsertion
============================================== ========================
..
@@ -286,29 +285,6 @@ class BridgeIntegrationTests(unittest.TestCase):
% (self.fingerprint, ptArgsList),
bridgeLine)
- def test_integration_getExtraInfoDigests(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()
-
- test = "Many words and line all together\n"
- test += "extra info is nothing like weather\n"
- test += "it's certain to come, like the key in a hum\n"
- test += "but sometimes without a transport and rum\n"
- content = test
- sha1hash.update(test)
- digest = sha1hash.hexdigest()
- test += "-----BEGIN SIGNATURE-----\n"
- test += "But the rum can't save the world like you\n"
- test += "-----END SIGNATURE-----\n"
- digests = bridges.getExtraInfoDigests(io.StringIO(test))
- self.failUnlessIn(digest, digests)
- self.failUnlessEqual(content, digests[digest].read())
-
def test_integration_splitterBridgeInsertion(self):
key = "Testing-Bridges-To-Rings"
splitter = FilteredBridgeSplitter(key)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits