pyopenssl
pyopenssl copied to clipboard
OpenSSL.test.test_ssl.ContextTests.test_set_default_verify_paths() error with absent network connection
OpenSSL.test.test_ssl.ContextTests.test_set_default_verify_paths() triggers error when network connection is absent. It is the only test in pyOpenSSL test suite with this problem.
======================================================================
ERROR: test_set_default_verify_paths (OpenSSL.test.test_ssl.ContextTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/pyopenssl/OpenSSL/test/test_ssl.py", line 930, in test_set_default_verify_paths
client.connect(('verisign.com', 443))
socket.gaierror: [Errno -3] Temporary failure in name resolution
======================================================================
Possible fix:
--- OpenSSL/test/test_ssl.py
+++ OpenSSL/test/test_ssl.py
@@ -8,7 +8,7 @@
from gc import collect, get_referrers
from errno import ECONNREFUSED, EINPROGRESS, EWOULDBLOCK, EPIPE, ESHUTDOWN
from sys import platform, version_info
-from socket import SHUT_RDWR, error, socket
+from socket import SHUT_RDWR, error, gaierror, socket
from os import makedirs
from os.path import join
from unittest import main
@@ -927,7 +927,11 @@
lambda conn, cert, errno, depth, preverify_ok: preverify_ok)
client = socket()
- client.connect(('verisign.com', 443))
+ try:
+ client.connect(('verisign.com', 443))
+ except gaierror:
+ # Absent network connection or verisign.com inaccessible.
+ return
clientSSL = Connection(context, client)
clientSSL.set_connect_state()
clientSSL.do_handshake()
Thanks. I'd suggest that raising SkipTest with an error message (probably something including the gaierror to aid in tracking down the cause, should anyone be surprised) would be appropriate in this case.
SkipTest was introduced in Python 2.7, but pyOpenSSL supports Python >=2.6.
SkipTest was introduced in Python 2.7, but pyOpenSSL supports Python >=2.6.
I don’t think it matters, tests are dependent on pytest anyway, so you can use pytest.mark.skip, but really … supporting Python 2.6? RHEL-6 is EOS, so what platform you run your tests on?
Anyway, at OpenSUSE we have patch, which doesn’t add Python 2.7 requirement (only requires pytest).
My previous comment was from over 6 years ago, when pyOpenSSL still supported Python 2.6.
Currently classifiers in setup.py say that Python 2.7 is minimal supported version.
Sorry, yes, I missed that this issues is so old considering that it has not been fixed so far.