summaryrefslogtreecommitdiff
path: root/tests/test_requests.py
diff options
context:
space:
mode:
authorBastien Gérard <bastien.gerard@cluepoints.com>2017-03-17 22:59:47 +0100
committerBastien Gérard <bastien.gerard@cluepoints.com>2017-03-22 21:28:38 +0100
commit7d8b87c37f3a5fb993fd83eda6888ac217cd108e (patch)
tree2e155138aea9e8c288a41a0af7866abc0e2fcd73 /tests/test_requests.py
parentb60c5a5ed46d75c56e36db5a58a98a50d880141d (diff)
downloadpython-requests-7d8b87c37f3a5fb993fd83eda6888ac217cd108e.tar.gz
#3926 raise IOError when providing an invalid path to a CA bundle or certificate files
Diffstat (limited to 'tests/test_requests.py')
-rwxr-xr-xtests/test_requests.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_requests.py b/tests/test_requests.py
index 829ab3eb..65f85e03 100755
--- a/tests/test_requests.py
+++ b/tests/test_requests.py
@@ -769,6 +769,22 @@ class TestRequests:
def test_pyopenssl_redirect(self, httpbin_secure, httpbin_ca_bundle):
requests.get(httpbin_secure('status', '301'), verify=httpbin_ca_bundle)
+ def test_invalid_ca_certificate_path(self):
+ INVALID_PATH = '/garbage'
+ with pytest.raises(IOError) as e:
+ requests.get('http://github.com', verify=INVALID_PATH)
+ assert str(e.value) == 'Could not find a suitable SSL CA certificate bundle, invalid path: {0}'.format(INVALID_PATH)
+
+ def test_invalid_ssl_certificate_files(self):
+ INVALID_PATH = '/garbage'
+ with pytest.raises(IOError) as e:
+ requests.get('http://github.com', cert=INVALID_PATH)
+ assert str(e.value) == 'Could not find the SSL certificate file, invalid path: {0}'.format(INVALID_PATH)
+
+ with pytest.raises(IOError) as e:
+ requests.get('http://github.com', cert=('.', INVALID_PATH))
+ assert str(e.value) == 'Could not find the SSL key file, invalid path: {0}'.format(INVALID_PATH)
+
def test_https_warnings(self, httpbin_secure, httpbin_ca_bundle):
"""warnings are emitted with requests.get"""
if HAS_MODERN_SSL or HAS_PYOPENSSL: