Fix compatibility with oslo.context >= 4.0.0

The tenant argument of RequestContext is no longer available since
oslo.context >= 4.0.0 . This change fixes the compatibility issue
caused by that removal.

Note that this still keeps reference to 'tenant' argument to make
the code compatible with older oslo.context, but that can be removed
once oslo.context >= 4.0.0 becomes available in upper-constraints.

Change-Id: Ie671f50e5ff5a7c746f9e95691eaf4dd19937b52
This commit is contained in:
Takashi Kajinami 2022-03-05 00:05:06 +09:00
parent e82c4ca08b
commit 3e07dcc424
3 changed files with 10 additions and 1 deletions

View File

@ -153,7 +153,10 @@ def _extract_mistral_auth_params(headers):
'insecure': insecure,
'auth_token': headers.get('X-Target-Auth-Token'),
'auth_uri': headers.get('X-Target-Auth-Uri'),
# TODO(tkajinam): Remove this once oslo.context >= 4.0.0 becomes
# avaialble
'tenant': headers.get('X-Target-Project-Id'),
'project_id': headers.get('X-Target-Project-Id'),
'user': headers.get('X-Target-User-Id'),
'user_name': headers.get('X-Target-User-Name'),
'region_name': headers.get('X-Target-Region-Name'),

View File

@ -51,7 +51,10 @@ def get_context(default=True, admin=False):
return auth_context.MistralContext.from_dict({
'user_name': 'test-user',
'user': '1-2-3-4',
# TODO(tkajinam): Remove this once oslo.context >= 4.0.0 becomes
# avaialble
'tenant': security.DEFAULT_PROJECT_ID,
'project_id': security.DEFAULT_PROJECT_ID,
'project_name': 'test-project',
'is_admin': admin
})
@ -59,7 +62,10 @@ def get_context(default=True, admin=False):
return auth_context.MistralContext.from_dict({
'user_name': 'test-user',
'user': '9-0-44-5',
# TODO(tkajinam): Remove this once oslo.context >= 4.0.0 becomes
# avaialble
'tenant': '99-88-33',
'project_id': '99-88-33',
'project_name': 'test-another',
'is_admin': admin
})

View File

@ -104,7 +104,7 @@ class EventEngineTest(base.DbTestCase):
auth_context.set_ctx(self.ctx)
t['scope'] = 'public'
t['project_id'] = self.ctx.tenant
t['project_id'] = self.ctx.project_id
trigger = db_api.create_event_trigger(t)
# Switch to the user.