[tor-commits] [stem/master] Revert ORPort after new integ test

atagar at torproject.org atagar at torproject.org
Mon Dec 9 19:46:01 UTC 2019


commit cb61dfe74a0a4b87b115ed834624cf2c9c5d282c
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Dec 9 11:44:08 2019 -0800

    Revert ORPort after new integ test
    
    Nick's new test passes with flying colors, but does not revert the ORPort back
    to the value we previously had. This worked because this test coincidently was
    one of the last.
    
    Also fixing minor stylistic issues cited by pycodestyle...
    
      STATIC CHECKS
      * /home/atagar/Desktop/stem/test/integ/control/controller.py
        line 794  - use single rather than double quotes     | controller.set_conf("ORPort", "0")
        line 797  - use single rather than double quotes     | controller.set_options([("UseBridges", "1"),
        line 798  - use single rather than double quotes     | ("Bridge", "127.0.0.1:9999")])
        line 801  - use single rather than double quotes     | controller.set_conf("UseBridges", "0")
---
 stem/control.py                  |  2 ++
 test/integ/control/controller.py | 27 +++++++++++++++++----------
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/stem/control.py b/stem/control.py
index f0242b0d..42736486 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -299,6 +299,8 @@ MALFORMED_EVENTS = 'MALFORMED_EVENTS'
 
 State = stem.util.enum.Enum('INIT', 'RESET', 'CLOSED')
 
+# TODO: consider merging this with stem.response.event in stem 2.x? (#32689)
+
 EventType = stem.util.enum.UppercaseEnum(
   'ADDRMAP',
   'AUTHDIR_NEWDESCS',
diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index e7c979b2..6e45d0fa 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -773,6 +773,7 @@ class TestController(unittest.TestCase):
         self.assertEqual('17234 127.0.0.1:17235', controller.get_conf('HiddenServicePort'))
       finally:
         # reverts configuration changes
+
         controller.set_options((
           ('ExitPolicy', 'reject *:*'),
           ('ConnLimit', None),
@@ -784,21 +785,27 @@ class TestController(unittest.TestCase):
         shutil.rmtree(tmpdir)
 
   @test.require.controller
-  def test_set_conf_31495_regression(self):
+  def test_set_conf_for_usebridges(self):
     """
-    Make sure that we can set UseBridges=1 and set a Bridge, to
-    check for a regression in Tor bug 31945.
+    Ensure we can set UseBridges=1 and also set a Bridge. This is a tor
+    regression check (:trac:`31945`).
     """
+
     with test.runner.get_runner().get_tor_controller() as controller:
-      # Make sure we aren't a relay, so that we can set UseBridges.
-      controller.set_conf("ORPort", "0")
+      orport = controller.get_conf('ORPort')
 
-      # Try setting UseBridges, to make sure we don't reject the request.
-      controller.set_options([("UseBridges", "1"),
-                              ("Bridge", "127.0.0.1:9999")])
+      try:
+        controller.set_conf('ORPort', '0')  # ensure we're not a relay so UseBridges is usabe
+        controller.set_options([('UseBridges', '1'), ('Bridge', '127.0.0.1:9999')])
+        self.assertEqual('127.0.0.1:9999', controller.get_conf('Bridge'))
+      finally:
+        # reverts configuration changes
 
-      # Set UseBridges back again to avoid problems in later tests.
-      controller.set_conf("UseBridges", "0")
+        controller.set_options((
+          ('ORPort', orport),
+          ('UseBridges', None),
+          ('Bridge', None),
+        ), reset = True)
 
   @test.require.controller
   def test_set_conf_when_immutable(self):



More information about the tor-commits mailing list