Merge "Add domain attributes to accessinfo"
This commit is contained in:
@@ -134,10 +134,23 @@ class AccessInfo(dict):
|
||||
@property
|
||||
def user_domain_id(self):
|
||||
"""Returns the domain id of the user associated with the authentication
|
||||
request.
|
||||
request.
|
||||
|
||||
For v2, it always returns 'default' which may be different from the
|
||||
Keystone configuration.
|
||||
|
||||
:returns: str
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@property
|
||||
def user_domain_name(self):
|
||||
"""Returns the domain name of the user associated with the
|
||||
authentication request.
|
||||
|
||||
For v2, it always returns 'Default' which may be different from the
|
||||
Keystone configuration.
|
||||
|
||||
For v2, it always returns 'default' which maybe different from the
|
||||
Keystone configuration.
|
||||
:returns: str
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
@@ -234,10 +247,23 @@ class AccessInfo(dict):
|
||||
@property
|
||||
def project_domain_id(self):
|
||||
"""Returns the domain id of the project associated with the
|
||||
authentication request.
|
||||
authentication request.
|
||||
|
||||
For v2, it returns 'default' if a project is scoped or None which may
|
||||
be different from the keystone configuration.
|
||||
|
||||
:returns: str
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@property
|
||||
def project_domain_name(self):
|
||||
"""Returns the domain name of the project associated with the
|
||||
authentication request.
|
||||
|
||||
For v2, it returns 'Default' if a project is scoped or None which may
|
||||
be different from the keystone configuration.
|
||||
|
||||
For v2, it always returns 'default' which maybe different from the
|
||||
keystone configuration.
|
||||
:returns: str
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
@@ -317,6 +343,10 @@ class AccessInfoV2(AccessInfo):
|
||||
def user_domain_id(self):
|
||||
return 'default'
|
||||
|
||||
@property
|
||||
def user_domain_name(self):
|
||||
return 'Default'
|
||||
|
||||
@property
|
||||
def domain_name(self):
|
||||
return None
|
||||
@@ -396,6 +426,11 @@ class AccessInfoV2(AccessInfo):
|
||||
if self.project_id:
|
||||
return 'default'
|
||||
|
||||
@property
|
||||
def project_domain_name(self):
|
||||
if self.project_id:
|
||||
return 'Default'
|
||||
|
||||
@property
|
||||
def auth_url(self):
|
||||
if self.service_catalog:
|
||||
@@ -456,6 +491,10 @@ class AccessInfoV3(AccessInfo):
|
||||
def user_domain_id(self):
|
||||
return self['user']['domain']['id']
|
||||
|
||||
@property
|
||||
def user_domain_name(self):
|
||||
return self['user']['domain']['name']
|
||||
|
||||
@property
|
||||
def username(self):
|
||||
return self['user']['name']
|
||||
@@ -484,6 +523,12 @@ class AccessInfoV3(AccessInfo):
|
||||
if project:
|
||||
return project['domain']['id']
|
||||
|
||||
@property
|
||||
def project_domain_name(self):
|
||||
project = self.get('project')
|
||||
if project:
|
||||
return project['domain']['name']
|
||||
|
||||
@property
|
||||
def project_name(self):
|
||||
project = self.get('project')
|
||||
|
@@ -37,6 +37,11 @@ class AccessInfoTest(utils.TestCase):
|
||||
self.assertFalse(auth_ref.project_scoped)
|
||||
self.assertFalse(auth_ref.trust_scoped)
|
||||
|
||||
self.assertIsNone(auth_ref.project_domain_id)
|
||||
self.assertIsNone(auth_ref.project_domain_name)
|
||||
self.assertEqual(auth_ref.user_domain_id, 'default')
|
||||
self.assertEqual(auth_ref.user_domain_name, 'Default')
|
||||
|
||||
self.assertEquals(auth_ref.expires, timeutils.parse_isotime(
|
||||
UNSCOPED_TOKEN['access']['token']['expires']))
|
||||
|
||||
@@ -73,6 +78,11 @@ class AccessInfoTest(utils.TestCase):
|
||||
self.assertEquals(auth_ref.management_url,
|
||||
('http://admin:35357/v2.0',))
|
||||
|
||||
self.assertEqual(auth_ref.project_domain_id, 'default')
|
||||
self.assertEqual(auth_ref.project_domain_name, 'Default')
|
||||
self.assertEqual(auth_ref.user_domain_id, 'default')
|
||||
self.assertEqual(auth_ref.user_domain_name, 'Default')
|
||||
|
||||
self.assertTrue(auth_ref.scoped)
|
||||
self.assertTrue(auth_ref.project_scoped)
|
||||
self.assertFalse(auth_ref.domain_scoped)
|
||||
@@ -84,6 +94,10 @@ class AccessInfoTest(utils.TestCase):
|
||||
self.assertEquals(auth_ref.username, 'user_name1')
|
||||
self.assertEquals(auth_ref.project_id, 'tenant_id1')
|
||||
self.assertEquals(auth_ref.project_name, 'tenant_id1')
|
||||
self.assertEquals(auth_ref.project_domain_id, 'default')
|
||||
self.assertEquals(auth_ref.project_domain_name, 'Default')
|
||||
self.assertEquals(auth_ref.user_domain_id, 'default')
|
||||
self.assertEquals(auth_ref.user_domain_name, 'Default')
|
||||
self.assertFalse(auth_ref.scoped)
|
||||
|
||||
def test_grizzly_token(self):
|
||||
@@ -91,3 +105,7 @@ class AccessInfoTest(utils.TestCase):
|
||||
|
||||
self.assertEquals(auth_ref.project_id, 'tenant_id1')
|
||||
self.assertEquals(auth_ref.project_name, 'tenant_name1')
|
||||
self.assertEquals(auth_ref.project_domain_id, 'default')
|
||||
self.assertEquals(auth_ref.project_domain_name, 'Default')
|
||||
self.assertEquals(auth_ref.user_domain_id, 'default')
|
||||
self.assertEquals(auth_ref.user_domain_name, 'Default')
|
||||
|
@@ -37,6 +37,13 @@ class AccessInfoTest(utils.TestCase):
|
||||
self.assertFalse(auth_ref.domain_scoped)
|
||||
self.assertFalse(auth_ref.project_scoped)
|
||||
|
||||
self.assertEquals(auth_ref.user_domain_id,
|
||||
'4e6893b7ba0b4006840c3845660b86ed')
|
||||
self.assertEquals(auth_ref.user_domain_name, 'exampledomain')
|
||||
|
||||
self.assertIsNone(auth_ref.project_domain_id)
|
||||
self.assertIsNone(auth_ref.project_domain_name)
|
||||
|
||||
self.assertEquals(auth_ref.expires, timeutils.parse_isotime(
|
||||
UNSCOPED_TOKEN['token']['expires_at']))
|
||||
|
||||
@@ -70,6 +77,13 @@ class AccessInfoTest(utils.TestCase):
|
||||
self.assertEquals(auth_ref.project_name, None)
|
||||
self.assertEquals(auth_ref.project_id, None)
|
||||
|
||||
self.assertEquals(auth_ref.user_domain_id,
|
||||
'4e6893b7ba0b4006840c3845660b86ed')
|
||||
self.assertEquals(auth_ref.user_domain_name, 'exampledomain')
|
||||
|
||||
self.assertIsNone(auth_ref.project_domain_id)
|
||||
self.assertIsNone(auth_ref.project_domain_name)
|
||||
|
||||
self.assertTrue(auth_ref.domain_scoped)
|
||||
self.assertFalse(auth_ref.project_scoped)
|
||||
|
||||
@@ -102,5 +116,13 @@ class AccessInfoTest(utils.TestCase):
|
||||
self.assertEquals(auth_ref.management_url,
|
||||
('http://admin:35357/v3',))
|
||||
|
||||
self.assertEquals(auth_ref.project_domain_id,
|
||||
'4e6893b7ba0b4006840c3845660b86ed')
|
||||
self.assertEquals(auth_ref.project_domain_name, 'exampledomain')
|
||||
|
||||
self.assertEquals(auth_ref.user_domain_id,
|
||||
'4e6893b7ba0b4006840c3845660b86ed')
|
||||
self.assertEquals(auth_ref.user_domain_name, 'exampledomain')
|
||||
|
||||
self.assertFalse(auth_ref.domain_scoped)
|
||||
self.assertTrue(auth_ref.project_scoped)
|
||||
|
Reference in New Issue
Block a user