[tor-commits] [stem/master] Test when ADD_ONION uses basic auth but no clients

atagar at torproject.org atagar at torproject.org
Thu Jun 16 17:33:34 UTC 2016


commit 98e66f8191a47934ea7f65ef4c58fff63fe2fc46
Author: Damian Johnson <atagar at torproject.org>
Date:   Thu Jun 16 10:34:37 2016 -0700

    Test when ADD_ONION uses basic auth but no clients
    
    Interesting edge case. If you specify the basic auth flag but don't provide any
    clients then tor balks.
---
 test/integ/control/controller.py | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index 2bd06a6..7aa8a83 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -674,7 +674,7 @@ class TestController(unittest.TestCase):
 
   @require_controller
   @require_version(Requirement.ADD_ONION_BASIC_AUTH)
-  def test_with_ephemeral_hidden_services_with_basic_auth(self):
+  def test_with_ephemeral_hidden_services_basic_auth(self):
     """
     Exercises creating ephemeral hidden services that uses basic authentication.
     """
@@ -693,6 +693,23 @@ class TestController(unittest.TestCase):
       self.assertEqual([], controller.list_ephemeral_hidden_services())
 
   @require_controller
+  @require_version(Requirement.ADD_ONION_BASIC_AUTH)
+  def test_with_ephemeral_hidden_services_basic_auth_without_credentials(self):
+    """
+    Exercises creating ephemeral hidden services when attempting to use basic
+    auth but not including any credentials.
+    """
+
+    runner = test.runner.get_runner()
+
+    with runner.get_tor_controller() as controller:
+      try:
+        response = controller.create_ephemeral_hidden_service(4567, basic_auth = {})
+        self.fail('ADD_ONION should fail when using basic auth without any clients')
+      except stem.ProtocolError as exc:
+        self.assertEqual("ADD_ONION response didn't have an OK status: No auth clients specified", str(exc))
+
+  @require_controller
   @require_version(Requirement.ADD_ONION)
   def test_with_detached_ephemeral_hidden_services(self):
     """



More information about the tor-commits mailing list