summaryrefslogtreecommitdiff
path: root/heat
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-06-25 10:40:21 +0000
committerGerrit Code Review <review@openstack.org>2021-06-25 10:40:21 +0000
commitcdabffd002a838ce0653d6a6c0f36a2974caafac (patch)
tree2a40d2da5c2299c2aca308d97a6b99a147de0424 /heat
parent8a5a18322feb5867f0b877712007a1cc90f31bf6 (diff)
parent3cf6c575db764741e729e41d87efdd555dc4400d (diff)
downloadheat-cdabffd002a838ce0653d6a6c0f36a2974caafac.tar.gz
Merge "Switch to use <user/project>_domain_id in context"
Diffstat (limited to 'heat')
-rw-r--r--heat/common/context.py58
-rw-r--r--heat/tests/test_auth_password.py1
-rw-r--r--heat/tests/test_common_context.py16
3 files changed, 35 insertions, 40 deletions
diff --git a/heat/common/context.py b/heat/common/context.py
index 64eef397a..a30b1e26b 100644
--- a/heat/common/context.py
+++ b/heat/common/context.py
@@ -91,18 +91,12 @@ class RequestContext(context.RequestContext):
:param overwrite: Set to False to ensure that the greenthread local
copy of the index is not overwritten.
"""
- if user_domain_id:
- kwargs['user_domain'] = user_domain_id
- if project_domain_id:
- kwargs['project_domain'] = project_domain_id
-
- super(RequestContext, self).__init__(is_admin=is_admin,
- read_only=read_only,
- show_deleted=show_deleted,
- request_id=request_id,
- roles=roles,
- overwrite=overwrite,
- **kwargs)
+ super(RequestContext, self).__init__(
+ is_admin=is_admin, read_only=read_only,
+ show_deleted=show_deleted, request_id=request_id,
+ roles=roles, user_domain_id=user_domain_id,
+ project_domain_id=project_domain_id,
+ overwrite=overwrite, **kwargs)
self.username = username
self.password = password
@@ -185,8 +179,8 @@ class RequestContext(context.RequestContext):
'show_deleted': self.show_deleted,
'region_name': self.region_name,
'user_identity': user_idt,
- 'user_domain': self.user_domain,
- 'project_domain': self.project_domain}
+ 'user_domain_id': self.user_domain_id,
+ 'project_domain_id': self.project_domain_id}
@classmethod
def from_dict(cls, values):
@@ -207,8 +201,8 @@ class RequestContext(context.RequestContext):
request_id=values.get('request_id'),
show_deleted=values.get('show_deleted', False),
region_name=values.get('region_name'),
- user_domain_id=values.get('user_domain'),
- project_domain_id=values.get('project_domain')
+ user_domain_id=values.get('user_domain_id'),
+ project_domain_id=values.get('project_domain_id')
)
def to_policy_values(self):
@@ -299,8 +293,8 @@ class StoredContext(RequestContext):
auth_ref = self.auth_plugin.get_access(self.keystone_session)
self.roles = auth_ref.role_names
- self.user_domain = auth_ref.user_domain_id
- self.project_domain = auth_ref.project_domain_id
+ self.user_domain_id = auth_ref.user_domain_id
+ self.project_domain_id = auth_ref.project_domain_id
@property
def roles(self):
@@ -313,24 +307,24 @@ class StoredContext(RequestContext):
self._roles = roles
@property
- def user_domain(self):
+ def user_domain_id(self):
if not getattr(self, '_keystone_loaded', False):
self._load_keystone_data()
return self._user_domain_id
- @user_domain.setter
- def user_domain(self, user_domain):
- self._user_domain_id = user_domain
+ @user_domain_id.setter
+ def user_domain_id(self, user_domain_id):
+ self._user_domain_id = user_domain_id
@property
- def project_domain(self):
+ def project_domain_id(self):
if not getattr(self, '_keystone_loaded', False):
self._load_keystone_data()
return self._project_domain_id
- @project_domain.setter
- def project_domain(self, project_domain):
- self._project_domain_id = project_domain
+ @project_domain_id.setter
+ def project_domain_id(self, project_domain_id):
+ self._project_domain_id = project_domain_id
def get_admin_context(show_deleted=False):
@@ -359,8 +353,8 @@ class ContextMiddleware(wsgi.Middleware):
username = None
password = None
aws_creds = None
- user_domain = None
- project_domain = None
+ user_domain_id = None
+ project_domain_id = None
if headers.get('X-Auth-User') is not None:
username = headers.get('X-Auth-User')
@@ -369,10 +363,10 @@ class ContextMiddleware(wsgi.Middleware):
aws_creds = headers.get('X-Auth-EC2-Creds')
if headers.get('X-User-Domain-Id') is not None:
- user_domain = headers.get('X-User-Domain-Id')
+ user_domain_id = headers.get('X-User-Domain-Id')
if headers.get('X-Project-Domain-Id') is not None:
- project_domain = headers.get('X-Project-Domain-Id')
+ project_domain_id = headers.get('X-Project-Domain-Id')
project_name = headers.get('X-Project-Name')
region_name = headers.get('X-Region-Name')
@@ -390,8 +384,8 @@ class ContextMiddleware(wsgi.Middleware):
password=password,
auth_url=auth_url,
request_id=req_id,
- user_domain=user_domain,
- project_domain=project_domain,
+ user_domain_id=user_domain_id,
+ project_domain_id=project_domain_id,
auth_token_info=token_info,
region_name=region_name,
auth_plugin=auth_plugin,
diff --git a/heat/tests/test_auth_password.py b/heat/tests/test_auth_password.py
index ee06d8b1e..db147532e 100644
--- a/heat/tests/test_auth_password.py
+++ b/heat/tests/test_auth_password.py
@@ -33,6 +33,7 @@ EXPECTED_ENV_RESPONSE = {
'HTTP_X_PROJECT_ID': 'tenant_id1',
'HTTP_X_PROJECT_NAME': 'tenant_name1',
'HTTP_X_USER_ID': 'user_id1',
+ 'HTTP_X_USER_DOMAIN_ID': 'domain1',
'HTTP_X_USER_NAME': 'user_name1',
'HTTP_X_ROLES': 'role1,role2',
'HTTP_X_AUTH_TOKEN': 'lalalalalala',
diff --git a/heat/tests/test_common_context.py b/heat/tests/test_common_context.py
index 31f5bb736..a9e392605 100644
--- a/heat/tests/test_common_context.py
+++ b/heat/tests/test_common_context.py
@@ -51,8 +51,8 @@ class TestRequestContext(common.HeatTestCase):
'aws_creds': 'blah',
'region_name': 'RegionOne',
'user_identity': 'fooUser 456tenant',
- 'user_domain': None,
- 'project_domain': None}
+ 'user_domain_id': None,
+ 'project_domain_id': None}
super(TestRequestContext, self).setUp()
@@ -73,8 +73,8 @@ class TestRequestContext(common.HeatTestCase):
trustor_user_id=self.ctx.get('trustor_user_id'),
trust_id=self.ctx.get('trust_id'),
region_name=self.ctx.get('region_name'),
- user_domain_id=self.ctx.get('user_domain'),
- project_domain_id=self.ctx.get('project_domain'))
+ user_domain_id=self.ctx.get('user_domain_id'),
+ project_domain_id=self.ctx.get('project_domain_id'))
ctx_dict = ctx.to_dict()
del ctx_dict['request_id']
del ctx_dict['project_id']
@@ -103,8 +103,8 @@ class TestRequestContext(common.HeatTestCase):
'aws_creds': 'blah',
'region_name': 'RegionOne',
'user_identity': u'Gāo 456tenant',
- 'user_domain': None,
- 'project_domain': None}
+ 'user_domain_id': None,
+ 'project_domain_id': None}
ctx = context.RequestContext(
auth_token=ctx_origin.get('auth_token'),
@@ -122,8 +122,8 @@ class TestRequestContext(common.HeatTestCase):
trustor_user_id=ctx_origin.get('trustor_user_id'),
trust_id=ctx_origin.get('trust_id'),
region_name=ctx_origin.get('region_name'),
- user_domain_id=ctx_origin.get('user_domain'),
- project_domain_id=ctx_origin.get('project_domain'))
+ user_domain_id=ctx_origin.get('user_domain_id'),
+ project_domain_id=ctx_origin.get('project_domain_id'))
ctx_dict = ctx.to_dict()
del(ctx_dict['request_id'])
self.assertEqual(ctx_origin, ctx_dict)