[tor-commits] [stem/master] Fix stem.descriptor.remote vote fetching
atagar at torproject.org
atagar at torproject.org
Sun Jun 23 00:48:16 UTC 2019
commit 0d0f6e306a518a3989415b80542af3572bd2486d
Author: Damian Johnson <atagar at torproject.org>
Date: Sat Jun 22 17:45:52 2019 -0700
Fix stem.descriptor.remote vote fetching
Commit a4ecadb broke our ability to download consensus votes...
https://trac.torproject.org/projects/tor/ticket/30930
======================================================================
ERROR: test_each_getter
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/mock/mock.py", line 1305, in patched
return func(*args, **keywargs)
File "/home/atagar/Desktop/stem/test/unit/descriptor/remote.py", line 286, in test_each_getter
downloader.get_vote(stem.directory.Authority.from_cache()['moria1'])
File "/home/atagar/Desktop/stem/stem/descriptor/remote.py", line 871, in get_vote
return self.query(resource, **query_args)
File "/home/atagar/Desktop/stem/stem/descriptor/remote.py", line 999, in query
return Query(resource, **args)
File "/home/atagar/Desktop/stem/stem/descriptor/remote.py", line 460, in __init__
self.descriptor_type = _guess_descriptor_type(resource)
File "/home/atagar/Desktop/stem/stem/descriptor/remote.py", line 1143, in _guess_descriptor_type
raise ValueError("Unable to determine the descriptor type for '%s'" % resource)
ValueError: Unable to determine the descriptor type for '/tor/status-vote/current/authority'
---
stem/descriptor/remote.py | 5 +++--
test/unit/descriptor/remote.py | 17 +++++++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/stem/descriptor/remote.py b/stem/descriptor/remote.py
index 7f1f44fa..e76181fa 100644
--- a/stem/descriptor/remote.py
+++ b/stem/descriptor/remote.py
@@ -61,9 +61,10 @@ content. For example...
|- get_extrainfo_descriptors - provides present extrainfo descriptors
|- get_microdescriptors - provides present microdescriptors with the given digests
|- get_consensus - provides the present consensus or router status entries
+ |- get_vote - provides an authority's vote for the next consensus
+ |- get_key_certificates - provides present authority key certificates
|- get_bandwidth_file - provies bandwidth heuristics used to make the next consensus
|- get_detached_signatures - authority signatures used to make the next consensus
- |- get_key_certificates - provides present authority key certificates
+- query - request an arbitrary descriptor resource
.. versionadded:: 1.1.0
@@ -1119,7 +1120,7 @@ def _guess_descriptor_type(resource):
# The following resource urls can be for the present consensus
# (/tor/status-vote/current/*) or the next (/tor/status-vote/next/*).
- if resource.endswith('/consensus'):
+ if resource.endswith('/consensus') or resource.endswith('/authority'):
return 'network-status-consensus-3 1.0'
elif resource.endswith('/consensus-microdesc'):
return 'network-status-microdesc-consensus-3 1.0'
diff --git a/test/unit/descriptor/remote.py b/test/unit/descriptor/remote.py
index e26934b3..8c5e835b 100644
--- a/test/unit/descriptor/remote.py
+++ b/test/unit/descriptor/remote.py
@@ -270,6 +270,23 @@ class TestDescriptorDownloader(unittest.TestCase):
self.assertEqual(1, len(descriptors))
self.assertEqual('moria1', descriptors[0].nickname)
+ @patch(URL_OPEN)
+ def test_each_getter(self, dirport_mock):
+ """
+ Surface level exercising of each getter method for downloading descriptors.
+ """
+
+ downloader = stem.descriptor.remote.get_instance()
+
+ downloader.get_server_descriptors()
+ downloader.get_extrainfo_descriptors()
+ downloader.get_microdescriptors('test-hash')
+ downloader.get_consensus()
+ downloader.get_vote(stem.directory.Authority.from_cache()['moria1'])
+ downloader.get_key_certificates()
+ downloader.get_bandwidth_file()
+ downloader.get_detached_signatures()
+
@patch(URL_OPEN, _dirport_mock(TEST_DESCRIPTOR))
def test_reply_headers(self):
query = stem.descriptor.remote.get_server_descriptors('9695DFC35FFEB861329B9F1AB04C46397020CE31', start = False)
More information about the tor-commits
mailing list