pep8 cleanups after the rebase
This commit is contained in:
parent
39291fe0e8
commit
2d785404ed
@ -134,7 +134,7 @@ class HTTPClient(httplib2.Http):
|
||||
self.version = part
|
||||
break
|
||||
|
||||
if not self.version == "v2.0": #FIXME(chris): This should be better.
|
||||
if not self.version == "v2.0": # FIXME(chris): This should be better.
|
||||
headers = {'X-Auth-User': self.user,
|
||||
'X-Auth-Key': self.apikey}
|
||||
if self.projectid:
|
||||
@ -158,7 +158,7 @@ class HTTPClient(httplib2.Http):
|
||||
["nova"][0]["publicURL"]
|
||||
self.auth_token = body["auth"]["token"]["id"]
|
||||
|
||||
#TODO(chris): Implement service_catalog
|
||||
#TODO(chris): Implement service_catalog
|
||||
self.service_catalog = None
|
||||
|
||||
def _munge_get_url(self, url):
|
||||
|
@ -12,27 +12,30 @@ from tests import utils
|
||||
class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
||||
def test_authenticate_success(self):
|
||||
cs = client.Client("username", "apikey", "project_id", "auth_url/v2.0")
|
||||
resp = {"auth": {"token": {"expires": "12345", "id": "FAKE_ID"},
|
||||
"serviceCatalog": {
|
||||
"nova": [{"adminURL": "http://localhost:8774/v1.1",
|
||||
"region": "RegionOne",
|
||||
"internalURL": "http://localhost:8774/v1.1",
|
||||
"publicURL": "http://localhost:8774/v1.1/"}]}}}
|
||||
resp = {"auth":
|
||||
{"token": {"expires": "12345", "id": "FAKE_ID"},
|
||||
"serviceCatalog": {
|
||||
"nova": [
|
||||
{"adminURL": "http://localhost:8774/v1.1",
|
||||
"region": "RegionOne",
|
||||
"internalURL": "http://localhost:8774/v1.1",
|
||||
"publicURL": "http://localhost:8774/v1.1/"}]}}}
|
||||
auth_response = httplib2.Response({
|
||||
"status": 204,
|
||||
"status": 204,
|
||||
"body": json.dumps(resp),
|
||||
})
|
||||
|
||||
mock_request = mock.Mock(return_value=(auth_response, json.dumps(resp)))
|
||||
mock_request = mock.Mock(return_value=(auth_response,
|
||||
json.dumps(resp)))
|
||||
|
||||
@mock.patch.object(httplib2.Http, "request", mock_request)
|
||||
def test_auth_call():
|
||||
cs.client.authenticate()
|
||||
headers = {'User-Agent': cs.client.USER_AGENT,
|
||||
'Content-Type': 'application/json',}
|
||||
'Content-Type': 'application/json', }
|
||||
body = {'passwordCredentials': {'username': cs.client.user,
|
||||
'password': cs.client.apikey,
|
||||
'tenantId': cs.client.projectid,}}
|
||||
'tenantId': cs.client.projectid, }}
|
||||
|
||||
token_url = urlparse.urljoin(cs.client.auth_url, "tokens")
|
||||
mock_request.assert_called_with(token_url, "POST",
|
||||
@ -40,12 +43,11 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
||||
body=json.dumps(body))
|
||||
|
||||
self.assertEqual(cs.client.management_url,
|
||||
resp["auth"]["serviceCatalog"]["nova"][0]["publicURL"])
|
||||
resp["auth"]["serviceCatalog"]["nova"][0]["publicURL"])
|
||||
self.assertEqual(cs.client.auth_token, resp["auth"]["token"]["id"])
|
||||
|
||||
test_auth_call()
|
||||
|
||||
|
||||
def test_authenticate_failure(self):
|
||||
cs = client.Client("username", "apikey", "project_id", "auth_url/v2.0")
|
||||
resp = {"unauthorized": {"message": "Unauthorized", "code": "401"}}
|
||||
@ -54,7 +56,8 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
|
||||
"body": json.dumps(resp),
|
||||
})
|
||||
|
||||
mock_request = mock.Mock(return_value=(auth_response, json.dumps(resp)))
|
||||
mock_request = mock.Mock(return_value=(auth_response,
|
||||
json.dumps(resp)))
|
||||
|
||||
@mock.patch.object(httplib2.Http, "request", mock_request)
|
||||
def test_auth_call():
|
||||
|
Loading…
Reference in New Issue
Block a user