diff options
| author | Bastien Gérard <bastien.gerard@cluepoints.com> | 2017-03-17 22:59:47 +0100 |
|---|---|---|
| committer | Bastien Gérard <bastien.gerard@cluepoints.com> | 2017-03-22 21:28:38 +0100 |
| commit | 7d8b87c37f3a5fb993fd83eda6888ac217cd108e (patch) | |
| tree | 2e155138aea9e8c288a41a0af7866abc0e2fcd73 /tests/test_requests.py | |
| parent | b60c5a5ed46d75c56e36db5a58a98a50d880141d (diff) | |
| download | python-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-x | tests/test_requests.py | 16 |
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: |
