From eee53a69e1af019da18635d6974f893308db0ada Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Mon, 16 Mar 2020 22:05:06 +0400 Subject: Ensure load_verify_locations raises SSLError for all backends (#1812) * Ensure load_verify_locations raises SSLError for all backends This also adds TestSSL to the classes tested in SecureTransport and PyOpenSSL, since: 1. TestSSL was the most natural place for this test. 2. The test only makes sense when run against all SSL backends. Co-authored-by: Pierre-Louis Bonicoli * Remove redundant check in test pytest.raises() already checks this. * Update test_socketlevel.py Co-authored-by: Pierre-Louis Bonicoli Co-authored-by: Seth Michael Larson --- test/with_dummyserver/test_socketlevel.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/with_dummyserver/test_socketlevel.py') diff --git a/test/with_dummyserver/test_socketlevel.py b/test/with_dummyserver/test_socketlevel.py index 71495bcd..dab353e1 100644 --- a/test/with_dummyserver/test_socketlevel.py +++ b/test/with_dummyserver/test_socketlevel.py @@ -10,6 +10,7 @@ from urllib3.exceptions import ( ProtocolError, ) from urllib3.response import httplib +from urllib3.util import ssl_wrap_socket from urllib3.util.ssl_ import HAS_SNI from urllib3.util import ssl_ from urllib3.util.timeout import Timeout @@ -37,6 +38,7 @@ except ImportError: from collections import OrderedDict import os.path from threading import Event +import os import select import socket import shutil @@ -1387,6 +1389,13 @@ class TestSSL(SocketDummyServerTestCase): pool.request("GET", "/", timeout=SHORT_TIMEOUT) context.load_default_certs.assert_not_called() + def test_load_verify_locations_exception(self): + """ + Ensure that load_verify_locations raises SSLError for all backends + """ + with pytest.raises(SSLError): + ssl_wrap_socket(None, ca_certs=os.devnull) + class TestErrorWrapping(SocketDummyServerTestCase): def test_bad_statusline(self): -- cgit v1.2.1