summaryrefslogtreecommitdiff
path: root/swiftclient/client.py
diff options
context:
space:
mode:
authorDavid Shrewsbury <shrewsbury.dave@gmail.com>2013-04-18 16:25:14 -0400
committerDavid Shrewsbury <shrewsbury.dave@gmail.com>2013-04-25 07:43:43 -0400
commit9aa52eecb5193e145ec9b396f105b085fb87a456 (patch)
tree71deb4450aacd85c10ade11866436d033102a77d /swiftclient/client.py
parent2d97609a52bef2f437c15ff72dced29663c570ff (diff)
downloadpython-swiftclient-9aa52eecb5193e145ec9b396f105b085fb87a456.tar.gz
Confirm we have auth creds before clearing preauth
If you use the API and supply only preauth values (preauthurl and preauthtoken), and if either of these are incorrect, a non-descriptive AttributeError will be thrown and uncaught: 'NoneType' object has no attribute 'find' The _retry() will fail on the first pass (getting 401), then try to reauthenticate with non-preauth values. If those are not given, particularly the auth url, then the urlparse() call will be supplied None for the url in http_connection() causing the exception above. This change makes sure that we have an auth url, user and key before retrying authentication. Given the situation above, a '401 Unauthorized' ClientException will now be thrown instead of the AttributeError. Change-Id: Ie1b5bde1e8ff321aa18c0f23dbd2960d6e482236
Diffstat (limited to 'swiftclient/client.py')
-rw-r--r--swiftclient/client.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py
index a607898..bfd794c 100644
--- a/swiftclient/client.py
+++ b/swiftclient/client.py
@@ -1035,7 +1035,9 @@ class Connection(object):
raise
if err.http_status == 401:
self.url = self.token = None
- if self.attempts > 1:
+ if self.attempts > 1 or not all((self.authurl,
+ self.user,
+ self.key)):
raise
elif err.http_status == 408:
self.http_conn = None