[tor-commits] [stem/master] Check ONION_CLIENT_AUTH_ADD version

atagar at torproject.org atagar at torproject.org
Tue Sep 8 22:09:00 UTC 2020


commit a87bd9a0e2e9fdcd1ddf211e7deefd9a08dd5b48
Author: Damian Johnson <atagar at torproject.org>
Date:   Tue Sep 8 15:06:26 2020 -0700

    Check ONION_CLIENT_AUTH_ADD version
    
    Methods for new tor features (and their associated tests) should check tor's
    version. Caught thanks to asn.
---
 stem/control.py                  |  3 +++
 stem/version.py                  | 16 +++++++++-------
 test/integ/control/controller.py |  2 ++
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/stem/control.py b/stem/control.py
index 5ee9782e..a232f4db 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -3115,6 +3115,9 @@ class Controller(BaseController):
     :raises: :class:`stem.ControllerError` if the call fails
     """
 
+    if await self.get_version() < stem.version.Requirement.ONION_CLIENT_AUTH_ADD:
+      raise ValueError('ONION_CLIENT_AUTH_ADD requires tor %s or higher' % stem.version.Requirement.ONION_CLIENT_AUTH_ADD)
+
     request = 'ONION_CLIENT_AUTH_ADD %s %s:%s' % (service_id, key_type, private_key)
 
     if client_name:
diff --git a/stem/version.py b/stem/version.py
index cd2c3c39..6edf93ae 100644
--- a/stem/version.py
+++ b/stem/version.py
@@ -26,13 +26,14 @@ easily parsed and compared, for instance...
 
   Enumerations for the version requirements of features.
 
-  ===================== ===========
-  Requirement           Description
-  ===================== ===========
-  **DORMANT_MODE**      **DORMANT** and **ACTIVE** :data:`~stem.Signal`
-  **DROPTIMEOUTS**      **DROPTIMEOUTS** controller command
-  **HSFETCH_V3**        HSFETCH for version 3 hidden services
-  ===================== ===========
+  =========================== ===========
+  Requirement                 Description
+  =========================== ===========
+  **DORMANT_MODE**            **DORMANT** and **ACTIVE** :data:`~stem.Signal`
+  **DROPTIMEOUTS**            **DROPTIMEOUTS** controller command
+  **HSFETCH_V3**              HSFETCH for version 3 hidden services
+  **ONION_CLIENT_AUTH_ADD**   **ONION_CLIENT_AUTH_ADD** controller command
+  =========================== ===========
 """
 
 import functools
@@ -221,4 +222,5 @@ Requirement = stem.util.enum.Enum(
   ('DORMANT_MODE', Version('0.4.0.1-alpha')),
   ('DROPTIMEOUTS', Version('0.4.5.0-alpha')),
   ('HSFETCH_V3', Version('0.4.1.1-alpha')),
+  ('ONION_CLIENT_AUTH_ADD', Version('0.4.3.1-alpha')),
 )
diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index 6f5da0c4..553b1a4e 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -1627,6 +1627,7 @@ class TestController(unittest.TestCase):
         await controller.set_conf('OrPort', str(test.runner.ORPORT))
 
   @test.require.controller
+  @test.require.version(stem.version.Requirement.ONION_CLIENT_AUTH_ADD)
   @async_test
   async def test_hidden_service_auth(self):
     """
@@ -1665,6 +1666,7 @@ class TestController(unittest.TestCase):
       #   https://gitlab.torproject.org/tpo/core/tor/-/issues/40090
 
   @test.require.controller
+  @test.require.version(stem.version.Requirement.ONION_CLIENT_AUTH_ADD)
   @async_test
   async def test_hidden_service_auth_invalid(self):
     """



More information about the tor-commits mailing list