[tor-commits] [stem/master] Drop obsolete version constants

atagar at torproject.org atagar at torproject.org
Mon Feb 10 03:14:50 UTC 2020


commit 7a4357b2c21d0af5088c1cafce0800fc63cebbb4
Author: Damian Johnson <atagar at torproject.org>
Date:   Thu Feb 6 16:36:02 2020 -0800

    Drop obsolete version constants
    
    Removing the constants and version checks for obsolete tor versions. As of
    2/6/20 our consensus has...
    
      client-versions 0.3.5.7,0.3.5.8,0.3.5.9,0.4.1.2-alpha,0.4.1.3-alpha,0.4.1.4-rc,0.4.1.5,0.4.1.6,0.4.1.7,0.4.1.8,0.4.2.1-alpha,0.4.2.2-alpha,0.4.2.3-alpha,0.4.2.4-rc,0.4.2.5,0.4.2.6,0.4.3.1-alpha
      server-versions 0.3.5.8,0.3.5.9,0.4.1.2-alpha,0.4.1.3-alpha,0.4.1.4-rc,0.4.1.5,0.4.1.6,0.4.1.7,0.4.1.8,0.4.2.1-alpha,0.4.2.2-alpha,0.4.2.3-alpha,0.4.2.4-rc,0.4.2.5,0.4.2.6,0.4.3.1-alpha
    
    Stem won't have another release for several months so picked 0.3.5.7 as the
    minimum version to keep. That narrows us down to HSv3 support for HSFETCH and
    tor's new dormant mode.
---
 stem/control.py                         | 184 +++++++-------------------------
 stem/process.py                         |  28 +----
 stem/version.py                         |  63 +----------
 test/integ/connection/authentication.py |  19 +---
 test/integ/control/controller.py        |  28 +----
 test/integ/process.py                   |  21 +---
 test/integ/response/protocolinfo.py     |   4 +-
 test/integ/socket/control_message.py    |   1 -
 test/require.py                         |   6 +-
 test/unit/control/controller.py         |  13 ---
 10 files changed, 51 insertions(+), 316 deletions(-)

diff --git a/stem/control.py b/stem/control.py
index 271a67ec..ff984b57 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -1615,14 +1615,13 @@ class Controller(BaseController):
     if start_time:
       return start_time
 
-    if self.get_version() >= stem.version.Requirement.GETINFO_UPTIME:
-      uptime = self.get_info('uptime', None)
+    uptime = self.get_info('uptime', None)
 
-      if uptime:
-        if not uptime.isdigit():
-          raise ValueError("'GETINFO uptime' did not provide a valid numeric response: %s" % uptime)
+    if uptime:
+      if not uptime.isdigit():
+        raise ValueError("'GETINFO uptime' did not provide a valid numeric response: %s" % uptime)
 
-        start_time = time.time() - float(uptime)
+      start_time = time.time() - float(uptime)
 
     if not start_time and self.is_localhost():
       # Tor doesn't yet support this GETINFO option, attempt to determine the
@@ -1785,45 +1784,13 @@ class Controller(BaseController):
       default was provided
     """
 
-    if self.get_version() >= stem.version.Requirement.GETINFO_MICRODESCRIPTORS:
-      desc_content = self.get_info('md/all', get_bytes = True)
+    desc_content = self.get_info('md/all', get_bytes = True)
 
-      if not desc_content:
-        raise stem.DescriptorUnavailable('Descriptor information is unavailable, tor might still be downloading it')
-
-      for desc in stem.descriptor.microdescriptor._parse_file(io.BytesIO(desc_content)):
-        yield desc
-    else:
-      # TODO: remove when tor versions that require this are obsolete
-
-      data_directory = self.get_conf('DataDirectory', None)
-
-      if data_directory is None:
-        raise stem.OperationFailed(message = "Unable to determine tor's data directory")
-
-      if not os.path.exists(data_directory):
-        raise stem.OperationFailed(message = "Data directory reported by tor doesn't exist (%s)" % data_directory)
-
-      microdescriptor_file = None
-
-      for filename in ('cached-microdescs', 'cached-microdescs.new'):
-        cached_descriptors = os.path.join(data_directory, filename)
-
-        if os.path.exists(cached_descriptors):
-          microdescriptor_file = cached_descriptors
-          break
-
-      if microdescriptor_file is None:
-        raise stem.OperationFailed(message = "Data directory doesn't contain cached microdescriptors (%s)" % data_directory)
-
-      for desc in stem.descriptor.parse_file(microdescriptor_file):
-        # It shouldn't be possible for these to be something other than
-        # microdescriptors but as the saying goes: trust but verify.
-
-        if not isinstance(desc, stem.descriptor.microdescriptor.Microdescriptor):
-          raise stem.OperationFailed(message = 'BUG: Descriptor reader provided non-microdescriptor content (%s)' % type(desc))
+    if not desc_content:
+      raise stem.DescriptorUnavailable('Descriptor information is unavailable, tor might still be downloading it')
 
-        yield desc
+    for desc in stem.descriptor.microdescriptor._parse_file(io.BytesIO(desc_content)):
+      yield desc
 
   @with_default()
   def get_server_descriptor(self, relay = None, default = UNDEFINED):
@@ -1862,37 +1829,31 @@ class Controller(BaseController):
       An exception is only raised if we weren't provided a default response.
     """
 
-    try:
-      if relay is None:
-        try:
-          relay = self.get_info('fingerprint')
-        except stem.ControllerError as exc:
-          raise stem.ControllerError('Unable to determine our own fingerprint: %s' % exc)
-
-      if stem.util.tor_tools.is_valid_fingerprint(relay):
-        query = 'desc/id/%s' % relay
-      elif stem.util.tor_tools.is_valid_nickname(relay):
-        query = 'desc/name/%s' % relay
-      else:
-        raise ValueError("'%s' isn't a valid fingerprint or nickname" % relay)
-
+    if relay is None:
       try:
-        desc_content = self.get_info(query, get_bytes = True)
-      except stem.InvalidArguments as exc:
-        if str(exc).startswith('GETINFO request contained unrecognized keywords:'):
-          raise stem.DescriptorUnavailable("Tor was unable to provide the descriptor for '%s'" % relay)
-        else:
-          raise
+        relay = self.get_info('fingerprint')
+      except stem.ControllerError as exc:
+        raise stem.ControllerError('Unable to determine our own fingerprint: %s' % exc)
+
+    if stem.util.tor_tools.is_valid_fingerprint(relay):
+      query = 'desc/id/%s' % relay
+    elif stem.util.tor_tools.is_valid_nickname(relay):
+      query = 'desc/name/%s' % relay
+    else:
+      raise ValueError("'%s' isn't a valid fingerprint or nickname" % relay)
 
-      if not desc_content:
-        raise stem.DescriptorUnavailable('Descriptor information is unavailable, tor might still be downloading it')
+    try:
+      desc_content = self.get_info(query, get_bytes = True)
+    except stem.InvalidArguments as exc:
+      if str(exc).startswith('GETINFO request contained unrecognized keywords:'):
+        raise stem.DescriptorUnavailable("Tor was unable to provide the descriptor for '%s'" % relay)
+      else:
+        raise
 
-      return stem.descriptor.server_descriptor.RelayDescriptor(desc_content)
-    except:
-      if not self._is_server_descriptors_available():
-        raise ValueError(SERVER_DESCRIPTORS_UNSUPPORTED)
+    if not desc_content:
+      raise stem.DescriptorUnavailable('Descriptor information is unavailable, tor might still be downloading it')
 
-      raise
+    return stem.descriptor.server_descriptor.RelayDescriptor(desc_content)
 
   @with_default(yields = True)
   def get_server_descriptors(self, default = UNDEFINED):
@@ -1925,27 +1886,11 @@ class Controller(BaseController):
     desc_content = self.get_info('desc/all-recent', get_bytes = True)
 
     if not desc_content:
-      if not self._is_server_descriptors_available():
-        raise stem.ControllerError(SERVER_DESCRIPTORS_UNSUPPORTED)
-      else:
-        raise stem.DescriptorUnavailable('Descriptor information is unavailable, tor might still be downloading it')
+      raise stem.DescriptorUnavailable('Descriptor information is unavailable, tor might still be downloading it')
 
     for desc in stem.descriptor.server_descriptor._parse_file(io.BytesIO(desc_content)):
       yield desc
 
-  def _is_server_descriptors_available(self):
-    """
-    Checks to see if tor server descriptors should be available or not.
-    """
-
-    # TODO: Replace with a 'GETINFO desc/download-enabled' request when they're
-    # widely available...
-    #
-    #   https://gitweb.torproject.org/torspec.git/commit/?id=378699c
-
-    return self.get_version() < stem.version.Requirement.MICRODESCRIPTOR_IS_DEFAULT or \
-           self.get_conf('UseMicrodescriptors', None) == '0'
-
   @with_default()
   def get_network_status(self, relay = None, default = UNDEFINED):
     """
@@ -2086,9 +2031,6 @@ class Controller(BaseController):
     if not stem.util.tor_tools.is_valid_hidden_service_address(address):
       raise ValueError("'%s.onion' isn't a valid hidden service address" % address)
 
-    if self.get_version() < stem.version.Requirement.HSFETCH:
-      raise stem.UnsatisfiableRequest(message = 'HSFETCH was added in tor version %s' % stem.version.Requirement.HSFETCH)
-
     hs_desc_queue, hs_desc_listener = queue.Queue(), None
     hs_desc_content_queue, hs_desc_content_listener = queue.Queue(), None
     start_time = time.time()
@@ -2843,9 +2785,6 @@ class Controller(BaseController):
       provided a default response
     """
 
-    if self.get_version() < stem.version.Requirement.ADD_ONION:
-      raise stem.UnsatisfiableRequest(message = 'Ephemeral hidden services were added in tor version %s' % stem.version.Requirement.ADD_ONION)
-
     result = []
 
     if our_services:
@@ -2971,9 +2910,6 @@ class Controller(BaseController):
       * :class:`stem.Timeout` if **timeout** was reached
     """
 
-    if self.get_version() < stem.version.Requirement.ADD_ONION:
-      raise stem.UnsatisfiableRequest(message = 'Ephemeral hidden services were added in tor version %s' % stem.version.Requirement.ADD_ONION)
-
     hs_desc_queue, hs_desc_listener = queue.Queue(), None
     start_time = time.time()
 
@@ -2994,20 +2930,13 @@ class Controller(BaseController):
       flags.append('Detach')
 
     if basic_auth is not None:
-      if self.get_version() < stem.version.Requirement.ADD_ONION_BASIC_AUTH:
-        raise stem.UnsatisfiableRequest(message = 'Basic authentication support was added to ADD_ONION in tor version %s' % stem.version.Requirement.ADD_ONION_BASIC_AUTH)
-
       flags.append('BasicAuth')
 
     if max_streams is not None:
-      if self.get_version() < stem.version.Requirement.ADD_ONION_MAX_STREAMS:
-        raise stem.UnsatisfiableRequest(message = 'Limitation of the maximum number of streams to accept was added to ADD_ONION in tor version %s' % stem.version.Requirement.ADD_ONION_MAX_STREAMS)
-
       flags.append('MaxStreamsCloseCircuit')
 
-    if self.get_version() >= stem.version.Requirement.ADD_ONION_NON_ANONYMOUS:
-      if self.get_conf('HiddenServiceSingleHopMode', None) == '1' and self.get_conf('HiddenServiceNonAnonymousMode', None) == '1':
-        flags.append('NonAnonymous')
+    if self.get_conf('HiddenServiceSingleHopMode', None) == '1' and self.get_conf('HiddenServiceNonAnonymousMode', None) == '1':
+      flags.append('NonAnonymous')
 
     if flags:
       request += ' Flags=%s' % ','.join(flags)
@@ -3078,9 +3007,6 @@ class Controller(BaseController):
     :raises: :class:`stem.ControllerError` if the call fails
     """
 
-    if self.get_version() < stem.version.Requirement.ADD_ONION:
-      raise stem.UnsatisfiableRequest(message = 'Ephemeral hidden services were added in tor version %s' % stem.version.Requirement.ADD_ONION)
-
     response = self.msg('DEL_ONION %s' % service_id)
     stem.response.convert('SINGLELINE', response)
 
@@ -3346,9 +3272,6 @@ class Controller(BaseController):
         the configuration file
     """
 
-    if self.get_version() < stem.version.Requirement.SAVECONF_FORCE:
-      force = False
-
     response = self.msg('SAVECONF FORCE' if force else 'SAVECONF')
     stem.response.convert('SINGLELINE', response)
 
@@ -3371,24 +3294,10 @@ class Controller(BaseController):
 
     feature = feature.upper()
 
-    if feature in self._enabled_features:
-      return True
-    else:
-      # check if this feature is on by default
-      defaulted_version = None
-
-      if feature == 'EXTENDED_EVENTS':
-        defaulted_version = stem.version.Requirement.FEATURE_EXTENDED_EVENTS
-      elif feature == 'VERBOSE_NAMES':
-        defaulted_version = stem.version.Requirement.FEATURE_VERBOSE_NAMES
+    if feature in ('EXTENDED_EVENTS', 'VERBOSE_NAMES'):
+      return True  # EXTENDED_EVENTS and VERBOSE_NAMES are always on as of 0.2.2.1
 
-      if defaulted_version:
-        our_version = self.get_version(None)
-
-        if our_version and our_version >= defaulted_version:
-          self._enabled_features.append(feature)
-
-      return feature in self._enabled_features
+    return feature in self._enabled_features
 
   def enable_feature(self, features):
     """
@@ -3397,11 +3306,6 @@ class Controller(BaseController):
     control connection must be opened to get a connection with the feature
     disabled. Feature names are case-insensitive.
 
-    The following features are currently accepted:
-
-      * EXTENDED_EVENTS - Requests the extended event syntax
-      * VERBOSE_NAMES - Replaces ServerID with LongName in events and GETINFO results
-
     :param str,list features: a single feature or a list of features to be enabled
 
     :raises:
@@ -3553,16 +3457,7 @@ class Controller(BaseController):
       self.add_event_listener(circ_listener, EventType.CIRC)
 
     try:
-      # we might accidently get integer circuit ids
-      circuit_id = str(circuit_id)
-
-      if path is None and circuit_id == '0':
-        path_opt_version = stem.version.Requirement.EXTENDCIRCUIT_PATH_OPTIONAL
-
-        if not self.get_version() >= path_opt_version:
-          raise stem.InvalidRequest(512, 'EXTENDCIRCUIT requires the path prior to version %s' % path_opt_version)
-
-      args = [circuit_id]
+      args = [str(circuit_id)]
 
       if isinstance(path, (bytes, str)):
         path = [path]
@@ -3862,9 +3757,6 @@ class Controller(BaseController):
     :raises: :class:`stem.ControllerError` if Tor couldn't fulfill the request
     """
 
-    if self.get_version() < stem.version.Requirement.DROPGUARDS:
-      raise stem.UnsatisfiableRequest(message = 'DROPGUARDS was added in tor version %s' % stem.version.Requirement.DROPGUARDS)
-
     self.msg('DROPGUARDS')
 
   def _post_authentication(self):
diff --git a/stem/process.py b/stem/process.py
index 3f1a0e19..913a9be7 100644
--- a/stem/process.py
+++ b/stem/process.py
@@ -242,14 +242,6 @@ def launch_tor_with_config(config, tor_cmd = 'tor', completion_percent = 100, in
     timeout without success
   """
 
-  # TODO: Drop this version check when tor 0.2.6.3 or higher is the only game
-  # in town.
-
-  try:
-    use_stdin = stem.version.get_system_tor_version(tor_cmd) >= stem.version.Requirement.TORRC_VIA_STDIN
-  except IOError:
-    use_stdin = False
-
   # we need to be sure that we're logging to stdout to figure out when we're
   # done bootstrapping
 
@@ -278,22 +270,4 @@ def launch_tor_with_config(config, tor_cmd = 'tor', completion_percent = 100, in
       for value in values:
         config_str += '%s %s\n' % (key, value)
 
-  if use_stdin:
-    return launch_tor(tor_cmd, ['-f', '-'], None, completion_percent, init_msg_handler, timeout, take_ownership, close_output, stdin = config_str)
-  else:
-    torrc_descriptor, torrc_path = tempfile.mkstemp(prefix = 'torrc-', text = True)
-
-    try:
-      with open(torrc_path, 'w') as torrc_file:
-        torrc_file.write(config_str)
-
-      # prevents tor from erroring out due to a missing torrc if it gets a sighup
-      args = ['__ReloadTorrcOnSIGHUP', '0']
-
-      return launch_tor(tor_cmd, args, torrc_path, completion_percent, init_msg_handler, timeout, take_ownership)
-    finally:
-      try:
-        os.close(torrc_descriptor)
-        os.remove(torrc_path)
-      except:
-        pass
+  return launch_tor(tor_cmd, ['-f', '-'], None, completion_percent, init_msg_handler, timeout, take_ownership, close_output, stdin = config_str)
diff --git a/stem/version.py b/stem/version.py
index 71f16e2c..4f873f47 100644
--- a/stem/version.py
+++ b/stem/version.py
@@ -11,8 +11,8 @@ easily parsed and compared, for instance...
   >>> my_version = get_system_tor_version()
   >>> print(my_version)
   0.2.1.30
-  >>> my_version >= Requirement.TORRC_CONTROL_SOCKET
-  True
+  >>> my_version >= Requirement.DORMANT_MODE
+  False
 
 **Module Overview:**
 
@@ -26,18 +26,10 @@ easily parsed and compared, for instance...
 
   Enumerations for the version requirements of features.
 
-  .. deprecated:: 1.6.0
-     Requirement entries belonging to tor versions which have been obsolete for
-     at least six months will be removed when we break backward compatibility
-     in the 2.x stem release.
-
   ===================================== ===========
   Requirement                           Description
   ===================================== ===========
-  **AUTH_SAFECOOKIE**                   SAFECOOKIE authentication method
-  **DESCRIPTOR_COMPRESSION**            `Expanded compression support for ZSTD and LZMA <https://gitweb.torproject.org/torspec.git/commit/?id=1cb56afdc1e55e303e3e6b69e90d983ee217d93f>`_
   **DORMANT_MODE**                      **DORMANT** and **ACTIVE** :data:`~stem.Signal`
-  **DROPGUARDS**                        DROPGUARDS requests
   **EVENT_AUTHDIR_NEWDESCS**            AUTHDIR_NEWDESC events
   **EVENT_BUILDTIMEOUT_SET**            BUILDTIMEOUT_SET events
   **EVENT_CIRC_MINOR**                  CIRC_MINOR events
@@ -58,29 +50,7 @@ easily parsed and compared, for instance...
   **EVENT_CELL_STATS**                  CELL_STATS events
   **EVENT_TB_EMPTY**                    TB_EMPTY events
   **EVENT_HS_DESC**                     HS_DESC events
-  **EXTENDCIRCUIT_PATH_OPTIONAL**       EXTENDCIRCUIT queries can omit the path if the circuit is zero
-  **FEATURE_EXTENDED_EVENTS**           'EXTENDED_EVENTS' optional feature
-  **FEATURE_VERBOSE_NAMES**             'VERBOSE_NAMES' optional feature
-  **GETINFO_CONFIG_TEXT**               'GETINFO config-text' query
-  **GETINFO_GEOIP_AVAILABLE**           'GETINFO ip-to-country/ipv4-available' query and its ipv6 counterpart
-  **GETINFO_MICRODESCRIPTORS**          'GETINFO md/all' query
-  **GETINFO_UPTIME**                    'GETINFO uptime' query
-  **HIDDEN_SERVICE_V3**                 Support for v3 hidden services
-  **HSFETCH**                           HSFETCH requests
   **HSFETCH_V3**                        HSFETCH for version 3 hidden services
-  **HSPOST**                            HSPOST requests
-  **ADD_ONION**                         ADD_ONION and DEL_ONION requests
-  **ADD_ONION_BASIC_AUTH**              ADD_ONION supports basic authentication
-  **ADD_ONION_NON_ANONYMOUS**           ADD_ONION supports non-anonymous mode
-  **ADD_ONION_MAX_STREAMS**             ADD_ONION support for MaxStreamsCloseCircuit
-  **LOADCONF**                          LOADCONF requests
-  **MICRODESCRIPTOR_IS_DEFAULT**        Tor gets microdescriptors by default rather than server descriptors
-  **SAVECONF_FORCE**                    Added the 'FORCE' flag to SAVECONF
-  **TAKEOWNERSHIP**                     TAKEOWNERSHIP requests
-  **TORRC_CONTROL_SOCKET**              'ControlSocket <path>' config option
-  **TORRC_PORT_FORWARDING**             'PortForwarding' config option
-  **TORRC_DISABLE_DEBUGGER_ATTACHMENT** 'DisableDebuggerAttachment' config option
-  **TORRC_VIA_STDIN**                   Allow torrc options via 'tor -f -' (:trac:`13865`)
   ===================================== ===========
 """
 
@@ -341,15 +311,8 @@ class _VersionRequirements(object):
     self.rules.append(new_rule)
 
 
-safecookie_req = _VersionRequirements()
-safecookie_req.in_range(Version('0.2.2.36'), Version('0.2.3.0'))
-safecookie_req.greater_than(Version('0.2.3.13'))
-
 Requirement = stem.util.enum.Enum(
-  ('AUTH_SAFECOOKIE', safecookie_req),
-  ('DESCRIPTOR_COMPRESSION', Version('0.3.1.1-alpha')),
   ('DORMANT_MODE', Version('0.4.0.1-alpha')),
-  ('DROPGUARDS', Version('0.2.5.1-alpha')),
   ('EVENT_AUTHDIR_NEWDESCS', Version('0.1.1.10-alpha')),
   ('EVENT_BUILDTIMEOUT_SET', Version('0.2.2.7-alpha')),
   ('EVENT_CIRC_MINOR', Version('0.2.3.11-alpha')),
@@ -370,27 +333,5 @@ Requirement = stem.util.enum.Enum(
   ('EVENT_CELL_STATS', Version('0.2.5.2-alpha')),
   ('EVENT_TB_EMPTY', Version('0.2.5.2-alpha')),
   ('EVENT_HS_DESC', Version('0.2.5.2-alpha')),
-  ('EXTENDCIRCUIT_PATH_OPTIONAL', Version('0.2.2.9')),
-  ('FEATURE_EXTENDED_EVENTS', Version('0.2.2.1-alpha')),
-  ('FEATURE_VERBOSE_NAMES', Version('0.2.2.1-alpha')),
-  ('GETINFO_CONFIG_TEXT', Version('0.2.2.7-alpha')),
-  ('GETINFO_GEOIP_AVAILABLE', Version('0.3.2.1-alpha')),
-  ('GETINFO_MICRODESCRIPTORS', Version('0.3.5.1-alpha')),
-  ('GETINFO_UPTIME', Version('0.3.5.1-alpha')),
-  ('HIDDEN_SERVICE_V3', Version('0.3.3.1-alpha')),
-  ('HSFETCH', Version('0.2.7.1-alpha')),
   ('HSFETCH_V3', Version('0.4.1.1-alpha')),
-  ('HSPOST', Version('0.2.7.1-alpha')),
-  ('ADD_ONION', Version('0.2.7.1-alpha')),
-  ('ADD_ONION_BASIC_AUTH', Version('0.2.9.1-alpha')),
-  ('ADD_ONION_NON_ANONYMOUS', Version('0.2.9.3-alpha')),
-  ('ADD_ONION_MAX_STREAMS', Version('0.2.7.2-alpha')),
-  ('LOADCONF', Version('0.2.1.1')),
-  ('MICRODESCRIPTOR_IS_DEFAULT', Version('0.2.3.3')),
-  ('SAVECONF_FORCE', Version('0.3.1.1-alpha')),
-  ('TAKEOWNERSHIP', Version('0.2.2.28-beta')),
-  ('TORRC_CONTROL_SOCKET', Version('0.2.0.30')),
-  ('TORRC_PORT_FORWARDING', Version('0.2.3.1-alpha')),
-  ('TORRC_DISABLE_DEBUGGER_ATTACHMENT', Version('0.2.3.9')),
-  ('TORRC_VIA_STDIN', Version('0.2.6.3-alpha')),
 )
diff --git a/test/integ/connection/authentication.py b/test/integ/connection/authentication.py
index cd562e7b..d07c20b2 100644
--- a/test/integ/connection/authentication.py
+++ b/test/integ/connection/authentication.py
@@ -43,17 +43,14 @@ def _can_authenticate(auth_type):
   tor_options = runner.get_options()
   password_auth = test.runner.Torrc.PASSWORD in tor_options
   cookie_auth = test.runner.Torrc.COOKIE in tor_options
-  safecookie_auth = cookie_auth and test.tor_version() >= stem.version.Requirement.AUTH_SAFECOOKIE
 
   if not password_auth and not cookie_auth:
     # open socket, anything but safecookie will work
     return auth_type != stem.connection.AuthMethod.SAFECOOKIE
   elif auth_type == stem.connection.AuthMethod.PASSWORD:
     return password_auth
-  elif auth_type == stem.connection.AuthMethod.COOKIE:
+  elif auth_type in (stem.connection.AuthMethod.COOKIE, stem.connection.AuthMethod.SAFECOOKIE):
     return cookie_auth
-  elif auth_type == stem.connection.AuthMethod.SAFECOOKIE:
-    return safecookie_auth
   else:
     return False
 
@@ -100,12 +97,6 @@ def _get_auth_failure_message(auth_type):
 
 
 class TestAuthenticate(unittest.TestCase):
-  def setUp(self):
-    self.cookie_auth_methods = [stem.connection.AuthMethod.COOKIE]
-
-    if test.tor_version() >= stem.version.Requirement.AUTH_SAFECOOKIE:
-      self.cookie_auth_methods.append(stem.connection.AuthMethod.SAFECOOKIE)
-
   @test.require.controller
   def test_authenticate_general_socket(self):
     """
@@ -293,7 +284,7 @@ class TestAuthenticate(unittest.TestCase):
 
     auth_value = test.runner.get_runner().get_auth_cookie_path()
 
-    for auth_type in self.cookie_auth_methods:
+    for auth_type in (stem.connection.AuthMethod.COOKIE, stem.connection.AuthMethod.SAFECOOKIE):
       if not os.path.exists(auth_value):
         # If the authentication cookie doesn't exist then we'll be getting an
         # error for that rather than rejection. This will even fail if
@@ -321,7 +312,7 @@ class TestAuthenticate(unittest.TestCase):
     fake_cookie.write('0' * 32)
     fake_cookie.close()
 
-    for auth_type in self.cookie_auth_methods:
+    for auth_type in (stem.connection.AuthMethod.COOKIE, stem.connection.AuthMethod.SAFECOOKIE):
       if _can_authenticate(stem.connection.AuthMethod.NONE):
         # authentication will work anyway unless this is safecookie
         if auth_type == stem.connection.AuthMethod.COOKIE:
@@ -351,7 +342,7 @@ class TestAuthenticate(unittest.TestCase):
     shouldn't exist.
     """
 
-    for auth_type in self.cookie_auth_methods:
+    for auth_type in (stem.connection.AuthMethod.COOKIE, stem.connection.AuthMethod.SAFECOOKIE):
       auth_value = "/if/this/exists/then/they're/asking/for/a/failure"
       self.assertRaises(stem.connection.UnreadableCookieFile, self._check_auth, auth_type, auth_value, False)
 
@@ -365,7 +356,7 @@ class TestAuthenticate(unittest.TestCase):
 
     auth_value = test.runner.get_runner().get_torrc_path(True)
 
-    for auth_type in self.cookie_auth_methods:
+    for auth_type in (stem.connection.AuthMethod.COOKIE, stem.connection.AuthMethod.SAFECOOKIE):
       if os.path.getsize(auth_value) == 32:
         # Weird coincidence? Fail so we can pick another file to check against.
         self.fail('Our torrc is 32 bytes, preventing the test_authenticate_cookie_wrong_size test from running.')
diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index 7113ea67..239e0bd7 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -81,7 +81,6 @@ class TestController(unittest.TestCase):
       self.assertRaises(stem.SocketError, stem.control.Controller.from_socket_file, test.runner.CONTROL_SOCKET_PATH)
 
   @test.require.controller
-  @test.require.version(Requirement.EVENT_SIGNAL)
   def test_reset_notification(self):
     """
     Checks that a notificiation listener is... well, notified of SIGHUPs.
@@ -342,9 +341,7 @@ class TestController(unittest.TestCase):
 
       if test.runner.Torrc.COOKIE in tor_options:
         auth_methods.append(stem.response.protocolinfo.AuthMethod.COOKIE)
-
-        if test.tor_version() >= stem.version.Requirement.AUTH_SAFECOOKIE:
-          auth_methods.append(stem.response.protocolinfo.AuthMethod.SAFECOOKIE)
+        auth_methods.append(stem.response.protocolinfo.AuthMethod.SAFECOOKIE)
 
       if test.runner.Torrc.PASSWORD in tor_options:
         auth_methods.append(stem.response.protocolinfo.AuthMethod.PASSWORD)
@@ -553,7 +550,6 @@ class TestController(unittest.TestCase):
             pass
 
   @test.require.controller
-  @test.require.version(Requirement.ADD_ONION)
   def test_without_ephemeral_hidden_services(self):
     """
     Exercises ephemeral hidden service methods when none are present.
@@ -565,7 +561,6 @@ class TestController(unittest.TestCase):
       self.assertEqual(False, controller.remove_ephemeral_hidden_service('gfzprpioee3hoppz'))
 
   @test.require.controller
-  @test.require.version(Requirement.ADD_ONION)
   def test_with_invalid_ephemeral_hidden_service_port(self):
     with test.runner.get_runner().get_tor_controller() as controller:
       for ports in (4567890, [4567, 4567890], {4567: '-:4567'}):
@@ -573,7 +568,6 @@ class TestController(unittest.TestCase):
         self.assertRaisesWith(stem.ProtocolError, exc_msg, controller.create_ephemeral_hidden_service, ports)
 
   @test.require.controller
-  @test.require.version(Requirement.ADD_ONION)
   def test_ephemeral_hidden_services_v2(self):
     """
     Exercises creating v2 ephemeral hidden services.
@@ -618,7 +612,6 @@ class TestController(unittest.TestCase):
         self.assertEqual(0, len(second_controller.list_ephemeral_hidden_services()))
 
   @test.require.controller
-  @test.require.version(Requirement.HIDDEN_SERVICE_V3)
   def test_ephemeral_hidden_services_v3(self):
     """
     Exercises creating v3 ephemeral hidden services.
@@ -663,7 +656,6 @@ class TestController(unittest.TestCase):
         self.assertEqual(0, len(second_controller.list_ephemeral_hidden_services()))
 
   @test.require.controller
-  @test.require.version(Requirement.ADD_ONION_BASIC_AUTH)
   def test_with_ephemeral_hidden_services_basic_auth(self):
     """
     Exercises creating ephemeral hidden services that uses basic authentication.
@@ -683,7 +675,6 @@ class TestController(unittest.TestCase):
       self.assertEqual([], controller.list_ephemeral_hidden_services())
 
   @test.require.controller
-  @test.require.version(Requirement.ADD_ONION_BASIC_AUTH)
   def test_with_ephemeral_hidden_services_basic_auth_no_credentials(self):
     """
     Exercises creating ephemeral hidden services when attempting to use basic
@@ -697,7 +688,6 @@ class TestController(unittest.TestCase):
       self.assertRaisesWith(stem.ProtocolError, exc_msg, controller.create_ephemeral_hidden_service, 4567, basic_auth = {})
 
   @test.require.controller
-  @test.require.version(Requirement.ADD_ONION)
   def test_with_detached_ephemeral_hidden_services(self):
     """
     Exercises creating detached ephemeral hidden services and methods when
@@ -733,7 +723,6 @@ class TestController(unittest.TestCase):
       controller.remove_ephemeral_hidden_service(response.service_id)
 
   @test.require.controller
-  @test.require.version(Requirement.ADD_ONION)
   def test_rejecting_unanonymous_hidden_services_creation(self):
     """
     Attempt to create a non-anonymous hidden service despite not setting
@@ -852,7 +841,6 @@ class TestController(unittest.TestCase):
       self.assertRaisesWith(stem.InvalidArguments, "DisableAllSwap, User cannot be changed while tor's running", controller.set_options, {'User': 'atagar', 'DisableAllSwap': '1'})
 
   @test.require.controller
-  @test.require.version(Requirement.LOADCONF)
   def test_loadconf(self):
     """
     Exercises Controller.load_conf with valid and invalid requests.
@@ -1004,7 +992,6 @@ class TestController(unittest.TestCase):
 
   @test.require.controller
   @test.require.online
-  @test.require.version(Requirement.EXTENDCIRCUIT_PATH_OPTIONAL)
   def test_extendcircuit(self):
     with test.runner.get_runner().get_tor_controller() as controller:
       circuit_id = controller.extend_circuit('0')
@@ -1020,7 +1007,6 @@ class TestController(unittest.TestCase):
 
   @test.require.controller
   @test.require.online
-  @test.require.version(Requirement.EXTENDCIRCUIT_PATH_OPTIONAL)
   def test_repurpose_circuit(self):
     """
     Tests Controller.repurpose_circuit with valid and invalid input.
@@ -1043,7 +1029,6 @@ class TestController(unittest.TestCase):
 
   @test.require.controller
   @test.require.online
-  @test.require.version(Requirement.EXTENDCIRCUIT_PATH_OPTIONAL)
   def test_close_circuit(self):
     """
     Tests Controller.close_circuit with valid and invalid input.
@@ -1251,7 +1236,6 @@ class TestController(unittest.TestCase):
 
   @test.require.controller
   @test.require.online
-  @test.require.version(Requirement.MICRODESCRIPTOR_IS_DEFAULT)
   def test_get_microdescriptor(self):
     """
     Basic checks for get_microdescriptor().
@@ -1304,12 +1288,8 @@ class TestController(unittest.TestCase):
 
     runner = test.runner.get_runner()
 
-    if test.tor_version() >= Requirement.MICRODESCRIPTOR_IS_DEFAULT:
-      self.skipTest('(requires server descriptors)')
-
     with runner.get_tor_controller() as controller:
       # we should balk at invalid content
-      self.assertRaises(ValueError, controller.get_server_descriptor, None)
       self.assertRaises(ValueError, controller.get_server_descriptor, '')
       self.assertRaises(ValueError, controller.get_server_descriptor, 5)
       self.assertRaises(ValueError, controller.get_server_descriptor, 'z' * 30)
@@ -1334,9 +1314,6 @@ class TestController(unittest.TestCase):
 
     runner = test.runner.get_runner()
 
-    if test.tor_version() >= Requirement.MICRODESCRIPTOR_IS_DEFAULT:
-      self.skipTest('(requires server descriptors)')
-
     with runner.get_tor_controller() as controller:
       count = 0
 
@@ -1402,7 +1379,6 @@ class TestController(unittest.TestCase):
 
   @test.require.controller
   @test.require.online
-  @test.require.version(Requirement.HSFETCH)
   def test_get_hidden_service_descriptor(self):
     """
     Fetches a few descriptors via the get_hidden_service_descriptor() method.
@@ -1428,7 +1404,6 @@ class TestController(unittest.TestCase):
 
   @test.require.controller
   @test.require.online
-  @test.require.version(Requirement.EXTENDCIRCUIT_PATH_OPTIONAL)
   def test_attachstream(self):
     host = socket.gethostbyname('www.torproject.org')
     port = 80
@@ -1469,7 +1444,6 @@ class TestController(unittest.TestCase):
 
   @test.require.controller
   @test.require.online
-  @test.require.version(Requirement.EXTENDCIRCUIT_PATH_OPTIONAL)
   def test_get_circuits(self):
     """
     Fetches circuits via the get_circuits() method.
diff --git a/test/integ/process.py b/test/integ/process.py
index e26a22c0..430ed484 100644
--- a/test/integ/process.py
+++ b/test/integ/process.py
@@ -310,9 +310,6 @@ class TestProcess(unittest.TestCase):
     Pass configuration options via stdin.
     """
 
-    if test.tor_version() < stem.version.Requirement.TORRC_VIA_STDIN:
-      skip('(requires %s)' % stem.version.Requirement.TORRC_VIA_STDIN)
-
     with tempfile.TemporaryDirectory() as data_directory:
       torrc = BASIC_RELAY_TORRC % data_directory
       output = run_tor(tor_cmd, '-f', '-', '--dump-config', 'short', stdin = torrc)
@@ -345,10 +342,7 @@ class TestProcess(unittest.TestCase):
 
       raise AssertionError("Tor shouldn't start with 'HiddenServiceNonAnonymousMode' set but not 'HiddenServiceSingleHopMode'")
     except OSError as exc:
-      if test.tor_version() >= stem.version.Requirement.ADD_ONION_NON_ANONYMOUS:
-        assert_equal('Process terminated: HiddenServiceNonAnonymousMode does not provide any server anonymity. It must be used with HiddenServiceSingleHopMode set to 1.', str(exc))
-      else:
-        assert_equal("Process terminated: Unknown option 'HiddenServiceNonAnonymousMode'.  Failing.", str(exc))
+      assert_equal('Process terminated: HiddenServiceNonAnonymousMode does not provide any server anonymity. It must be used with HiddenServiceSingleHopMode set to 1.', str(exc))
 
     try:
       stem.process.launch_tor_with_config(
@@ -358,10 +352,7 @@ class TestProcess(unittest.TestCase):
 
       raise AssertionError("Tor shouldn't start with 'HiddenServiceSingleHopMode' set but not 'HiddenServiceNonAnonymousMode'")
     except OSError as exc:
-      if test.tor_version() >= stem.version.Requirement.ADD_ONION_NON_ANONYMOUS:
-        assert_equal('Process terminated: HiddenServiceSingleHopMode does not provide any server anonymity. It must be used with HiddenServiceNonAnonymousMode set to 1.', str(exc))
-      else:
-        assert_equal("Process terminated: Unknown option 'HiddenServiceSingleHopMode'.  Failing.", str(exc))
+      assert_equal('Process terminated: HiddenServiceSingleHopMode does not provide any server anonymity. It must be used with HiddenServiceNonAnonymousMode set to 1.', str(exc))
 
   @asynchronous
   def test_can_run_multithreaded(tor_cmd):
@@ -465,9 +456,6 @@ class TestProcess(unittest.TestCase):
     Exercises launch_tor_with_config when we provide our torrc via stdin.
     """
 
-    if test.tor_version() < stem.version.Requirement.TORRC_VIA_STDIN:
-      skip('(requires %s)' % stem.version.Requirement.TORRC_VIA_STDIN)
-
     with tempfile.TemporaryDirectory() as data_directory:
       control_port = random_port()
       control_socket, tor_process = None, None
@@ -561,8 +549,6 @@ class TestProcess(unittest.TestCase):
 
     if not stem.util.system.is_available('sleep'):
       skip('(sleep unavailable)')
-    elif test.tor_version() < stem.version.Requirement.TAKEOWNERSHIP:
-      skip('(requires %s)' % stem.version.Requirement.TAKEOWNERSHIP)
 
     with tempfile.TemporaryDirectory() as data_directory:
       sleep_process = subprocess.Popen(['sleep', '60'])
@@ -608,9 +594,6 @@ class TestProcess(unittest.TestCase):
     connects, then disconnects..
     """
 
-    if test.tor_version() < stem.version.Requirement.TAKEOWNERSHIP:
-      skip('(requires %s)' % stem.version.Requirement.TAKEOWNERSHIP)
-
     with tempfile.TemporaryDirectory() as data_directory:
       control_port = random_port()
 
diff --git a/test/integ/response/protocolinfo.py b/test/integ/response/protocolinfo.py
index 917b87c3..2fb060db 100644
--- a/test/integ/response/protocolinfo.py
+++ b/test/integ/response/protocolinfo.py
@@ -126,9 +126,7 @@ class TestProtocolInfo(unittest.TestCase):
 
     if test.runner.Torrc.COOKIE in tor_options:
       auth_methods.append(stem.response.protocolinfo.AuthMethod.COOKIE)
-
-      if test.tor_version() >= stem.version.Requirement.AUTH_SAFECOOKIE:
-        auth_methods.append(stem.response.protocolinfo.AuthMethod.SAFECOOKIE)
+      auth_methods.append(stem.response.protocolinfo.AuthMethod.SAFECOOKIE)
 
       chroot_path = runner.get_chroot()
       auth_cookie_path = runner.get_auth_cookie_path()
diff --git a/test/integ/socket/control_message.py b/test/integ/socket/control_message.py
index 6c044647..e0a4cca2 100644
--- a/test/integ/socket/control_message.py
+++ b/test/integ/socket/control_message.py
@@ -99,7 +99,6 @@ class TestControlMessage(unittest.TestCase):
       self.assertEqual([('250', '-', 'config-file=%s' % torrc_dst), ('250', ' ', 'OK')], config_file_response.content())
 
   @test.require.controller
-  @test.require.version(stem.version.Requirement.GETINFO_CONFIG_TEXT)
   def test_getinfo_config_text(self):
     """
     Parses the 'GETINFO config-text' response.
diff --git a/test/require.py b/test/require.py
index 8bdea06b..12b3adf5 100644
--- a/test/require.py
+++ b/test/require.py
@@ -69,11 +69,7 @@ def _can_access_controller():
 
 
 def _can_ptrace():
-  # If we're running a tor version where ptrace is disabled and we didn't
-  # set 'DisableDebuggerAttachment=1' then we can infer that it's disabled.
-
-  has_option = test.tor_version() >= stem.version.Requirement.TORRC_DISABLE_DEBUGGER_ATTACHMENT
-  return not has_option or test.runner.Torrc.PTRACE in test.runner.get_runner().get_options()
+  return test.runner.Torrc.PTRACE in test.runner.get_runner().get_options()
 
 
 def _is_online():
diff --git a/test/unit/control/controller.py b/test/unit/control/controller.py
index 1ba3001a..37e252b9 100644
--- a/test/unit/control/controller.py
+++ b/test/unit/control/controller.py
@@ -694,19 +694,6 @@ class TestControl(unittest.TestCase):
     self.assertRaises(ControllerError, self.controller.get_effective_rate)
     self.assertEqual('my_default', self.controller.get_effective_rate('my_default'))
 
-  @patch('stem.control.Controller.get_version')
-  def test_drop_guards(self, get_version_mock):
-    """
-    Exercises the drop_guards() method.
-    """
-
-    get_version_mock.return_value = stem.version.Version('0.1.0.14')
-    self.assertRaises(UnsatisfiableRequest, self.controller.drop_guards)
-
-    with patch('stem.control.Controller.msg', Mock(return_value = None)):
-      get_version_mock.return_value = stem.version.Version('0.2.5.2')
-      self.controller.drop_guards()
-
   def _emit_event(self, event):
     # Spins up our Controller's thread pool, emits an event, then shuts it
     # down. This last part is important for a couple reasons...





More information about the tor-commits mailing list