Allow specify tenant:user in user.
We allow having the syntax tenant:user in user since this would make things easier when switching from auth 1.0 to auth 2.0 and not having to specify a tenant_name. In the feature we should use the auth functions from keystoneclient and be done with those changes, we could then auth by user/tenant-ID. Change-Id: Ie49748105a678fb9369494e77d41d934d57a39a7
This commit is contained in:
parent
8396e3a4cb
commit
2bcfe0b4c8
@ -282,6 +282,8 @@ def get_auth(url, user, key, snet=False, tenant_name=None, auth_version="1.0"):
|
|||||||
if auth_version in ["1.0", "1"]:
|
if auth_version in ["1.0", "1"]:
|
||||||
return _get_auth_v1_0(url, user, key, snet)
|
return _get_auth_v1_0(url, user, key, snet)
|
||||||
elif auth_version in ["2.0", "2"]:
|
elif auth_version in ["2.0", "2"]:
|
||||||
|
if not tenant_name and ':' in user:
|
||||||
|
(tenant_name, user) = user.split(':')
|
||||||
if not tenant_name:
|
if not tenant_name:
|
||||||
raise ClientException('No tenant specified')
|
raise ClientException('No tenant specified')
|
||||||
return _get_auth_v2_0(url, user, tenant_name, key, snet)
|
return _get_auth_v2_0(url, user, tenant_name, key, snet)
|
||||||
|
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
@ -201,6 +201,20 @@ class TestGetAuth(MockHttpTest):
|
|||||||
'http://www.tests.com', 'asdf', 'asdf',
|
'http://www.tests.com', 'asdf', 'asdf',
|
||||||
auth_version='2.0')
|
auth_version='2.0')
|
||||||
|
|
||||||
|
def test_auth_v2_with_tenant_user_in_user(self):
|
||||||
|
def read(*args, **kwargs):
|
||||||
|
acct_url = 'http://127.0.01/AUTH_FOO'
|
||||||
|
body = {'access': {'serviceCatalog':
|
||||||
|
[{u'endpoints': [{'publicURL': acct_url}],
|
||||||
|
'type': 'object-store'}],
|
||||||
|
'token': {'id': 'XXXXXXX'}}}
|
||||||
|
return c.json_dumps(body)
|
||||||
|
c.http_connection = self.fake_http_connection(200, return_read=read)
|
||||||
|
url, token = c.get_auth('http://www.test.com', 'foo:bar', 'asdf',
|
||||||
|
auth_version="2.0")
|
||||||
|
self.assertTrue(url.startswith("http"))
|
||||||
|
self.assertTrue(token)
|
||||||
|
|
||||||
|
|
||||||
class TestGetAccount(MockHttpTest):
|
class TestGetAccount(MockHttpTest):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user