Merge "make Connection.get_auth set url and token attributes on self"
This commit is contained in:
@@ -1258,13 +1258,14 @@ class Connection(object):
|
|||||||
self.http_conn = None
|
self.http_conn = None
|
||||||
|
|
||||||
def get_auth(self):
|
def get_auth(self):
|
||||||
return get_auth(self.authurl, self.user, self.key,
|
self.url, self.token = get_auth(self.authurl, self.user, self.key,
|
||||||
snet=self.snet,
|
snet=self.snet,
|
||||||
auth_version=self.auth_version,
|
auth_version=self.auth_version,
|
||||||
os_options=self.os_options,
|
os_options=self.os_options,
|
||||||
cacert=self.cacert,
|
cacert=self.cacert,
|
||||||
insecure=self.insecure,
|
insecure=self.insecure,
|
||||||
timeout=self.timeout)
|
timeout=self.timeout)
|
||||||
|
return self.url, self.token
|
||||||
|
|
||||||
def http_connection(self, url=None):
|
def http_connection(self, url=None):
|
||||||
return http_connection(url if url else self.url,
|
return http_connection(url if url else self.url,
|
||||||
|
@@ -1481,6 +1481,17 @@ class TestConnection(MockHttpTest):
|
|||||||
('HEAD', '/v1/AUTH_pre_url', '', {'x-auth-token': 'post_token'}),
|
('HEAD', '/v1/AUTH_pre_url', '', {'x-auth-token': 'post_token'}),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def test_get_auth_sets_url_and_token(self):
|
||||||
|
with mock.patch('swiftclient.client.get_auth') as mock_get_auth:
|
||||||
|
mock_get_auth.return_value = (
|
||||||
|
"https://storage.url/v1/AUTH_storage_acct", "AUTH_token"
|
||||||
|
)
|
||||||
|
conn = c.Connection("https://auth.url/auth/v2.0", "user", "passkey",
|
||||||
|
tenant_name="tenant")
|
||||||
|
conn.get_auth()
|
||||||
|
self.assertEqual("https://storage.url/v1/AUTH_storage_acct", conn.url)
|
||||||
|
self.assertEqual("AUTH_token", conn.token)
|
||||||
|
|
||||||
def test_timeout_passed_down(self):
|
def test_timeout_passed_down(self):
|
||||||
# We want to avoid mocking http_connection(), and most especially
|
# We want to avoid mocking http_connection(), and most especially
|
||||||
# avoid passing it down in argument. However, we cannot simply
|
# avoid passing it down in argument. However, we cannot simply
|
||||||
|
Reference in New Issue
Block a user