mirror of
https://github.com/ansible/awx.git
synced 2026-03-26 05:15:02 -02:30
Merge pull request #4485 from ryanpetrello/more-cred-failure-cleanup-372
properly obfuscate connection errors for credential lookup failure
This commit is contained in:
@@ -14,6 +14,8 @@ import time
|
|||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
from collections import OrderedDict, Iterable
|
from collections import OrderedDict, Iterable
|
||||||
|
|
||||||
|
from urllib3.exceptions import ConnectTimeoutError
|
||||||
|
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -1409,7 +1411,15 @@ class CredentialExternalTest(SubDetailAPIView):
|
|||||||
message = 'HTTP {}'.format(exc.response.status_code)
|
message = 'HTTP {}'.format(exc.response.status_code)
|
||||||
return Response({'inputs': message}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'inputs': message}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
return Response({'inputs': str(exc)}, status=status.HTTP_400_BAD_REQUEST)
|
message = exc.__class__.__name__
|
||||||
|
args = getattr(exc, 'args', [])
|
||||||
|
for a in args:
|
||||||
|
if isinstance(
|
||||||
|
getattr(a, 'reason', None),
|
||||||
|
ConnectTimeoutError
|
||||||
|
):
|
||||||
|
message = str(a.reason)
|
||||||
|
return Response({'inputs': message}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
class CredentialInputSourceDetail(RetrieveUpdateDestroyAPIView):
|
class CredentialInputSourceDetail(RetrieveUpdateDestroyAPIView):
|
||||||
@@ -1458,10 +1468,18 @@ class CredentialTypeExternalTest(SubDetailAPIView):
|
|||||||
obj.plugin.backend(**backend_kwargs)
|
obj.plugin.backend(**backend_kwargs)
|
||||||
return Response({}, status=status.HTTP_202_ACCEPTED)
|
return Response({}, status=status.HTTP_202_ACCEPTED)
|
||||||
except requests.exceptions.HTTPError as exc:
|
except requests.exceptions.HTTPError as exc:
|
||||||
message = 'HTTP {}\n{}'.format(exc.response.status_code, exc.response.text)
|
message = 'HTTP {}'.format(exc.response.status_code)
|
||||||
return Response({'inputs': message}, status=status.HTTP_400_BAD_REQUEST)
|
return Response({'inputs': message}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
return Response({'inputs': str(exc)}, status=status.HTTP_400_BAD_REQUEST)
|
message = exc.__class__.__name__
|
||||||
|
args = getattr(exc, 'args', [])
|
||||||
|
for a in args:
|
||||||
|
if isinstance(
|
||||||
|
getattr(a, 'reason', None),
|
||||||
|
ConnectTimeoutError
|
||||||
|
):
|
||||||
|
message = str(a.reason)
|
||||||
|
return Response({'inputs': message}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
class HostRelatedSearchMixin(object):
|
class HostRelatedSearchMixin(object):
|
||||||
|
|||||||
Reference in New Issue
Block a user