Merge "Improve feedback message in SSL error"
This commit is contained in:
@@ -414,8 +414,9 @@ class Session(object):
|
|||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
resp = self.session.request(method, url, **kwargs)
|
resp = self.session.request(method, url, **kwargs)
|
||||||
except requests.exceptions.SSLError:
|
except requests.exceptions.SSLError as e:
|
||||||
msg = _('SSL exception connecting to %s') % url
|
msg = _('SSL exception connecting to %(url)s: '
|
||||||
|
'%(error)s') % {'url': url, 'error': e}
|
||||||
raise exceptions.SSLError(msg)
|
raise exceptions.SSLError(msg)
|
||||||
except requests.exceptions.Timeout:
|
except requests.exceptions.Timeout:
|
||||||
msg = _('Request to %s timed out') % url
|
msg = _('Request to %s timed out') % url
|
||||||
|
@@ -26,6 +26,7 @@ from testtools import matchers
|
|||||||
from keystoneclient import adapter
|
from keystoneclient import adapter
|
||||||
from keystoneclient.auth import base
|
from keystoneclient.auth import base
|
||||||
from keystoneclient import exceptions
|
from keystoneclient import exceptions
|
||||||
|
from keystoneclient.i18n import _
|
||||||
from keystoneclient import session as client_session
|
from keystoneclient import session as client_session
|
||||||
from keystoneclient.tests.unit import utils
|
from keystoneclient.tests.unit import utils
|
||||||
|
|
||||||
@@ -219,6 +220,23 @@ class SessionTests(utils.TestCase):
|
|||||||
client_session.Session(session=mock_session)
|
client_session.Session(session=mock_session)
|
||||||
self.assertFalse(mock_session.mount.called)
|
self.assertFalse(mock_session.mount.called)
|
||||||
|
|
||||||
|
def test_ssl_error_message(self):
|
||||||
|
error = uuid.uuid4().hex
|
||||||
|
|
||||||
|
def _ssl_error(request, context):
|
||||||
|
raise requests.exceptions.SSLError(error)
|
||||||
|
|
||||||
|
self.stub_url('GET', text=_ssl_error)
|
||||||
|
session = client_session.Session()
|
||||||
|
|
||||||
|
# The exception should contain the URL and details about the SSL error
|
||||||
|
msg = _('SSL exception connecting to %(url)s: %(error)s') % {
|
||||||
|
'url': self.TEST_URL, 'error': error}
|
||||||
|
self.assertRaisesRegexp(exceptions.SSLError,
|
||||||
|
msg,
|
||||||
|
session.get,
|
||||||
|
self.TEST_URL)
|
||||||
|
|
||||||
|
|
||||||
class RedirectTests(utils.TestCase):
|
class RedirectTests(utils.TestCase):
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user