Merge "Don't use 'user' and 'tenant' args in context"

This commit is contained in:
Zuul 2019-02-02 20:56:26 +00:00 committed by Gerrit Code Review
commit 0df360559a
2 changed files with 18 additions and 11 deletions

View File

@ -134,8 +134,7 @@ class RequestContext(context.RequestContext):
self._object_cache[cache_cls] = cache
return cache
user_id = _moved_attr('user')
tenant_id = _moved_attr('tenant')
tenant_id = _moved_attr('project_id')
@property
def session(self):
@ -157,7 +156,7 @@ class RequestContext(context.RequestContext):
def to_dict(self):
user_idt = u'{user} {tenant}'.format(user=self.user_id or '-',
tenant=self.tenant_id or '-')
tenant=self.project_id or '-')
return {'auth_token': self.auth_token,
'username': self.username,
@ -165,7 +164,9 @@ class RequestContext(context.RequestContext):
'password': self.password,
'aws_creds': self.aws_creds,
'tenant': self.project_name,
'tenant_id': self.tenant_id,
'tenant_id': self.project_id,
'project_name': self.project_name,
'project_id': self.project_id,
'trust_id': self.trust_id,
'trustor_user_id': self.trustor_user_id,
'auth_token_info': self.auth_token_info,
@ -186,11 +187,11 @@ class RequestContext(context.RequestContext):
return cls(
auth_token=values.get('auth_token'),
username=values.get('username'),
user=values.get('user_id'),
user_id=values.get('user_id'),
password=values.get('password'),
aws_creds=values.get('aws_creds'),
project_name=values.get('tenant'),
tenant=values.get('tenant_id'),
project_name=values.get('project_name', values.get('tenant')),
project_id=values.get('project_id', values.get('tenant_id')),
trust_id=values.get('trust_id'),
trustor_user_id=values.get('trustor_user_id'),
auth_token_info=values.get('auth_token_info'),
@ -212,7 +213,7 @@ class RequestContext(context.RequestContext):
# what should be used when writing policy but are maintained for
# compatibility.
policy['user'] = self.user_id
policy['tenant'] = self.tenant_id
policy['tenant'] = self.project_id
policy['is_admin'] = self.is_admin
policy['auth_token_info'] = self.auth_token_info
@ -256,7 +257,7 @@ class RequestContext(context.RequestContext):
if self.password:
return generic.Password(username=self.username,
password=self.password,
project_id=self.tenant_id,
project_id=self.project_id,
user_domain_id=self.user_domain,
auth_url=self.keystone_v3_endpoint)

View File

@ -76,7 +76,9 @@ class TestRequestContext(common.HeatTestCase):
user_domain_id=self.ctx.get('user_domain'),
project_domain_id=self.ctx.get('project_domain'))
ctx_dict = ctx.to_dict()
del(ctx_dict['request_id'])
del ctx_dict['request_id']
del ctx_dict['project_id']
del ctx_dict['project_name']
self.assertEqual(self.ctx, ctx_dict)
def test_request_context_to_dict_unicode(self):
@ -93,8 +95,10 @@ class TestRequestContext(common.HeatTestCase):
'show_deleted': False,
'roles': ['arole', 'notadmin'],
'tenant_id': '456tenant',
'project_id': '456tenant',
'user_id': u'Gāo',
'tenant': u'\u5218\u80dc',
'project_name': u'\u5218\u80dc',
'auth_url': 'http://xyz',
'aws_creds': 'blah',
'region_name': 'RegionOne',
@ -127,7 +131,9 @@ class TestRequestContext(common.HeatTestCase):
def test_request_context_from_dict(self):
ctx = context.RequestContext.from_dict(self.ctx)
ctx_dict = ctx.to_dict()
del(ctx_dict['request_id'])
del ctx_dict['request_id']
del ctx_dict['project_id']
del ctx_dict['project_name']
self.assertEqual(self.ctx, ctx_dict)
def test_request_context_update(self):