Merge "Enforce usage of oslo.context's project_id"
This commit is contained in:
commit
89d7ec684e
@ -25,11 +25,8 @@ class RequestContext(oslo_context.context.RequestContext):
|
||||
accesses the system, as well as additional request information.
|
||||
"""
|
||||
|
||||
def __init__(self, policy_enforcer=None, project=None, **kwargs):
|
||||
def __init__(self, policy_enforcer=None, **kwargs):
|
||||
# prefer usage of 'project' instead of 'tenant'
|
||||
if project:
|
||||
kwargs['tenant'] = project
|
||||
self.project = project
|
||||
if policy_enforcer:
|
||||
self.policy_enforcer = policy_enforcer
|
||||
else:
|
||||
@ -41,12 +38,6 @@ class RequestContext(oslo_context.context.RequestContext):
|
||||
out_dict = super(RequestContext, self).to_dict()
|
||||
out_dict['roles'] = self.roles
|
||||
|
||||
# NOTE(jaosorior): For now, the oslo_context library uses 'tenant'
|
||||
# instead of project. But in case this changes, this will still issue
|
||||
# the dict we expect, which would contain 'project'.
|
||||
if out_dict.get('tenant'):
|
||||
out_dict['project'] = out_dict['tenant']
|
||||
out_dict.pop('tenant')
|
||||
return out_dict
|
||||
|
||||
@classmethod
|
||||
|
@ -42,8 +42,8 @@ def get_barbican_env(external_project_id):
|
||||
Injects the provided external_project_id.
|
||||
"""
|
||||
kwargs = {'roles': None,
|
||||
'user': None,
|
||||
'project': external_project_id,
|
||||
'user_id': None,
|
||||
'project_id': external_project_id,
|
||||
'is_admin': True}
|
||||
ctx = barbican.context.RequestContext(**kwargs)
|
||||
ctx.policy_enforcer = None
|
||||
|
@ -131,8 +131,8 @@ class BaseTestCase(utils.BaseTestCase, utils.MockModelRepositoryMixin):
|
||||
req.get_param.return_value = None
|
||||
|
||||
kwargs = {
|
||||
'user': user_id,
|
||||
'project': project_id,
|
||||
'user_id': user_id,
|
||||
'project_id': project_id,
|
||||
'roles': roles or [],
|
||||
'policy_enforcer': self.policy_enforcer,
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ def get_barbican_env(external_project_id):
|
||||
return
|
||||
|
||||
kwargs = {'roles': None,
|
||||
'user': None,
|
||||
'project': external_project_id,
|
||||
'user_id': None,
|
||||
'project_id': external_project_id,
|
||||
'is_admin': True,
|
||||
'policy_enforcer': NoopPolicyEnforcer()}
|
||||
barbican_env = {'barbican.context':
|
||||
|
Loading…
Reference in New Issue
Block a user