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
This commit is contained in:
David Shrewsbury 2013-04-18 16:25:14 -04:00
parent 2d97609a52
commit 9aa52eecb5

@ -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