[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Older ssl versions caused test_not_orport to fail



commit 0e08db7c18d732acb8cea100598d66720cb0d729
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Thu Oct 4 10:00:11 2018 -0700

    Older ssl versions caused test_not_orport to fail
    
    Our integ tests fail on an older system of mine due to lacking tor's version of ssl...
    
      ======================================================================
      FAIL: test_not_orport
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/home/atagar/Desktop/stem/test/integ/client/connection.py", line 34, in test_not_orport
          self.assertRaisesWith(stem.SocketError, "Failed to SSL authenticate to 127.0.0.1:1111. Maybe it isn't an ORPort?", Relay.connect, '127.0.0.1', test.runner.CONTROL_PORT)
        File "/home/atagar/Desktop/stem/stem/util/test_tools.py", line 288, in assertRaisesWith
          return self.assertRaisesRegexp(exc_type, '^%s$' % re.escape(exc_msg), func, *args, **kwargs)
        File "/home/atagar/Desktop/stem/stem/util/test_tools.py", line 298, in assertRaisesRegexp
          return super(original_type, self).assertRaisesRegexp(exc_type, exc_msg, func, *args, **kwargs)
      AssertionError: "^Failed\ to\ SSL\ authenticate\ to\ 127\.0\.0\.1\:1111\.\ Maybe\ it\ isn\'t\ an\ ORPort\?$" does not match "[Errno 1] _ssl.c:504: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol"
    
    That's fine. This test is supposed to error, just a different message than what
    we expected.
---
 test/integ/client/connection.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/test/integ/client/connection.py b/test/integ/client/connection.py
index a43283b9..ca8853c7 100644
--- a/test/integ/client/connection.py
+++ b/test/integ/client/connection.py
@@ -31,7 +31,21 @@ class TestConnection(unittest.TestCase):
     # connect to our ControlPort like it's an ORPort
 
     if test.runner.Torrc.PORT in test.runner.get_runner().get_options():
-      self.assertRaisesWith(stem.SocketError, "Failed to SSL authenticate to 127.0.0.1:1111. Maybe it isn't an ORPort?", Relay.connect, '127.0.0.1', test.runner.CONTROL_PORT)
+      try:
+        Relay.connect('127.0.0.1', test.runner.CONTROL_PORT)
+        self.fail('Connecting to a non-ORPort should raise a stem.SocketError')
+      except stem.SocketError as exc:
+        if str(exc) == "Failed to SSL authenticate to 127.0.0.1:1111. Maybe it isn't an ORPort?":
+          pass  # good, this is the usual response
+        elif 'SSL23_GET_SERVER_HELLO:unknown protocol' in str(exc):
+          # Less common, but still ok. This arises on older systems that do not
+          # support tor's ssl version. The full response is...
+          #
+          #   [Errno 1] _ssl.c:504: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
+
+          pass
+        else:
+          self.fail('Unexpected response when connecting to a non-ORPort: %s' % exc)
 
   def test_no_common_link_protocol(self):
     """

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits