diff --git a/cheroot/test/test_ssl.py b/cheroot/test/test_ssl.py index fa45f6fc21..9fa9341a48 100644 --- a/cheroot/test/test_ssl.py +++ b/cheroot/test/test_ssl.py @@ -27,10 +27,15 @@ EPHEMERAL_PORT, # get_server_client, _get_conn_data, + _probe_ipv6_sock, ) IS_LIBRESSL_BACKEND = ssl.OPENSSL_VERSION.startswith('LibreSSL') +IS_PYOPENSSL_SSL_VERSION_1_0 = ( + OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION). + startswith(b'OpenSSL 1.0.') +) PY27 = sys.version_info[:2] == (2, 7) @@ -54,6 +59,15 @@ ) +missing_ipv6 = pytest.mark.skipif( + not _probe_ipv6_sock('::1'), + reason='' + 'IPv6 is disabled ' + '(for example, under Travis CI ' + 'which runs under GCE supporting only IPv4)', +) + + class HelloWorldGateway(Gateway): """Gateway responding with Hello World to root URI.""" @@ -282,17 +296,24 @@ def test_tls_client_auth( if not test_cert_rejection: resp = make_https_request() - assert resp.status_code == 200 + is_req_successful = resp.status_code == 200 + if ( + not is_req_successful + and IS_PYOPENSSL_SSL_VERSION_1_0 + and adapter_type == 'builtin' + and tls_verify_mode == ssl.CERT_REQUIRED + and tls_client_identity == 'localhost' + and is_trusted_cert + ): + pytest.xfail( + 'OpenSSL 1.0 has problems with verifying client certs', + ) + assert is_req_successful assert resp.text == 'Hello world!' return with pytest.raises(requests.exceptions.SSLError) as ssl_err: - try: - make_https_request() - except OpenSSL.SSL.Error: - pytest.xfail( - reason='https://github.com/cherrypy/cheroot/issues/173', - ) + make_https_request() err_text = ssl_err.value.args[0].reason.args[0].args[0] @@ -334,14 +355,14 @@ def test_https_over_http_error(http_server, ip_addr): 'adapter_type', ( 'builtin', - pytest.param('pyopenssl', marks=fails_under_py3_in_pypy), + 'pyopenssl', ), ) @pytest.mark.parametrize( 'ip_addr', ( ANY_INTERFACE_IPV4, - ANY_INTERFACE_IPV6, + pytest.param(ANY_INTERFACE_IPV6, marks=missing_ipv6), ), ) def test_http_over_https_error( diff --git a/setup.cfg b/setup.cfg index 6a56c0e52f..fb3b7f4391 100644 --- a/setup.cfg +++ b/setup.cfg @@ -103,6 +103,10 @@ testing = # HTTP over UNIX socket requests-unixsocket + # This addresses https://github.com/cherrypy/cheroot/issues/173. + # It's a transitive dependency of requests library: + urllib3>=1.25 + [options.entry_points] console_scripts = cheroot = cheroot.cli:main