Removes the deprecated argument tenant from TroveContext

The tenant argument of RequestContext in oslo.context had been
deprecated long time ago and it was finally removed in
oslo.context-4.0.0. We should remove the tenant argument of
TroveContext that derives from RequestContext and we should also
update the requirements.txt in the master branch.

Task: 44723
Story: 2009906
Change-Id: I69c7098cc0d61fbbba1dbf2eca87df0dd6fd70ba
This commit is contained in:
Hirotaka Wakabayashi 2022-03-09 21:17:11 +09:00
parent 39322f5ad8
commit 559d6255e5
6 changed files with 8 additions and 8 deletions

View File

@ -28,7 +28,7 @@ jsonschema>=3.2.0 # MIT
Jinja2>=2.10 # BSD License (3 clause)
pexpect!=3.3,>=3.1 # ISC License
oslo.config>=6.8.0 # Apache-2.0
oslo.context>=2.22.0 # Apache-2.0
oslo.context>=4.0.0 # Apache-2.0
oslo.i18n>=3.15.3 # Apache-2.0
oslo.middleware>=3.31.0 # Apache-2.0
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0

View File

@ -57,7 +57,7 @@ rules = [
description='Must be an administrator.'),
policy.RuleDefault(
'admin_or_owner',
'rule:admin or tenant:%(tenant)s',
'rule:admin or project_id:%(tenant)s',
description='Must be an administrator or owner of the object.'),
policy.RuleDefault(
'default',

View File

@ -548,7 +548,7 @@ class ContextMiddleware(base_wsgi.Middleware):
break
limits = self._extract_limits(request.params)
context = rd_context.TroveContext(auth_token=auth_token,
tenant=tenant_id,
project_id=tenant_id,
user=user_id,
is_admin=is_admin,
limit=limits.get('limit'),

View File

@ -45,7 +45,7 @@ class Manager(periodic_task.PeriodicTasks):
super(Manager, self).__init__(CONF)
self.admin_context = TroveContext(
user=CONF.service_credentials.username,
tenant=CONF.service_credentials.project_id,
project_id=CONF.service_credentials.project_id,
user_domain_name=CONF.service_credentials.user_domain_name)
if CONF.exists_notification_transformer:
self.exists_transformer = importutils.import_object(

View File

@ -33,7 +33,7 @@ from trove.tests.unittests.util import util
def _prep_conf(current_time):
current_time = str(current_time)
_context = context.TroveContext(tenant='TENANT-' + current_time)
_context = context.TroveContext(project_id='TENANT-' + current_time)
instance_id = 'INSTANCE-' + current_time
return _context, instance_id

View File

@ -51,7 +51,7 @@ class TestTroveContext(trove_testtools.TestCase):
def test_to_dict_with_notification(self):
ctx = context.TroveContext(user='test_user_id',
tenant='the_tenant',
project_id='the_tenant',
request_id='test_req_id')
ctx.notification = DBaaSInstanceCreate(ctx,
request=Mock())
@ -68,11 +68,11 @@ class TestTroveContext(trove_testtools.TestCase):
ctx = context.TroveContext.from_dict(
{'user': 'test_user_id',
'request_id': 'test_req_id',
'tenant': 'abc',
'project_id': 'abc',
'blah_blah': 'blah blah'})
self.assertThat(ctx.user, Equals('test_user_id'))
self.assertThat(ctx.request_id, Equals('test_req_id'))
self.assertThat(ctx.tenant, Equals('abc'))
self.assertThat(ctx.project_id, Equals('abc'))
self.assertThat(ctx.limit, Is(None))
self.assertThat(ctx.marker, Is(None))
self.assertThat(ctx.service_catalog, Is(None))