[Pkg-privacy-commits] [txtorcon] 05/49: Generate valid_signals list dynamically
Ximin Luo
infinity0 at debian.org
Mon Oct 19 13:49:50 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository txtorcon.
commit dcd29e81982045e7fe3d929e898186dfb5a2238c
Author: Sambuddha Basu <sambuddhabasu1 at gmail.com>
Date: Sun May 3 03:40:36 2015 +0530
Generate valid_signals list dynamically
Handles specific exception
Removed RuntimeError and modified test
---
test/test_torcontrolprotocol.py | 9 +++++++++
test/test_torinfo.py | 3 +++
txtorcon/torcontrolprotocol.py | 13 ++++++-------
3 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/test/test_torcontrolprotocol.py b/test/test_torcontrolprotocol.py
index d249bc0..9a03bde 100644
--- a/test/test_torcontrolprotocol.py
+++ b/test/test_torcontrolprotocol.py
@@ -368,6 +368,9 @@ OK''' % cookietmp.name)
self.protocol._bootstrap()
# answer all the requests generated by boostrapping etc.
+ self.send("250-signal/names=")
+ self.send("250 OK")
+
self.send("250-version=foo")
self.send("250 OK")
@@ -378,6 +381,12 @@ OK''' % cookietmp.name)
return d
+ def test_bootstrap_tor_does_not_support_signal_names(self):
+ self.protocol._bootstrap()
+ self.send('552 Unrecognized key "signal/names"')
+ valid_signals = ["RELOAD", "DUMP", "DEBUG", "NEWNYM", "CLEARDNSCACHE"]
+ self.assertEqual(self.protocol.valid_signals, valid_signals)
+
def test_async(self):
"""
test the example from control-spec.txt to see that we
diff --git a/test/test_torinfo.py b/test/test_torinfo.py
index 573a2d1..a6a3019 100644
--- a/test/test_torinfo.py
+++ b/test/test_torinfo.py
@@ -80,6 +80,9 @@ class ProtocolIntegrationTests(unittest.TestCase):
self.send('250 OK')
# now we're in _bootstrap() in TorControlProtocol()
+ self.send("250-signal/names=")
+ self.send("250 OK")
+
self.send("250-version=foo")
self.send("250 OK")
diff --git a/txtorcon/torcontrolprotocol.py b/txtorcon/torcontrolprotocol.py
index fb4c921..eec7d13 100644
--- a/txtorcon/torcontrolprotocol.py
+++ b/txtorcon/torcontrolprotocol.py
@@ -716,13 +716,12 @@ class TorControlProtocol(LineOnlyReceiver):
callback.
"""
- # unfortunately I don't see a way to get this from the runing
- # tor like the events...so this was taken from some version
- # of the control-spec and must be kept up-to-date (or accpet
- # any signal name and just wait for the reply?
- # FIXME XXX there is now "GETINFO signal/names"
- self.valid_signals = ["RELOAD", "DUMP", "DEBUG", "NEWNYM",
- "CLEARDNSCACHE"]
+ try:
+ self.valid_signals = yield self.get_info('signal/names')
+ self.valid_signals = self.valid_signals['signal/names']
+ except TorProtocolError:
+ self.valid_signals = ["RELOAD", "DUMP", "DEBUG", "NEWNYM",
+ "CLEARDNSCACHE"]
self.version = yield self.get_info('version')
self.version = self.version['version']
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/txtorcon.git
More information about the Pkg-privacy-commits
mailing list