summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichaeltchapman <woppin@gmail.com>2020-07-06 14:10:04 +1000
committerErik Olof Gunnar Andersson <eandersson@blizzard.com>2022-01-13 05:00:35 +0000
commit6c80f6161aa01a1eb7da419f5d396ed60ab08066 (patch)
tree99489976bb88f1a587a36687a1644aaf7521bf0c
parentbff3d5f6e31fe595a77143ec4ac779c187bf72a8 (diff)
downloaddesignate-6c80f6161aa01a1eb7da419f5d396ed60ab08066.tar.gz
Move context from tenant to project_id
in the sudo context unit test: DeprecationWarning: Property 'tenant' has moved to 'project_id' in version '2.6' and will be removed in version '3.0' oslo_context is deprecating the tenant field, so move to using project_id. This does leave a less than ideal state where both project_id and tenant are referenced (since all_tenants remains untouched) but replacing 'tenant' with 'project' across the entire codebase is a much larger task. Change-Id: Id78112b49d5c0e99064fcb271aaded871da3f633
-rw-r--r--designate/context.py20
-rw-r--r--designate/tests/unit/test_context.py8
2 files changed, 14 insertions, 14 deletions
diff --git a/designate/context.py b/designate/context.py
index 22a0c2d4..13e56697 100644
--- a/designate/context.py
+++ b/designate/context.py
@@ -31,16 +31,16 @@ class DesignateContext(context.RequestContext):
_all_tenants = False
_hide_counts = False
_abandon = None
- original_tenant = None
+ original_project_id = None
_edit_managed_records = False
_client_addr = None
FROM_DICT_EXTRA_KEYS = [
- 'original_tenant', 'service_catalog', 'all_tenants', 'abandon',
+ 'original_project_id', 'service_catalog', 'all_tenants', 'abandon',
'edit_managed_records', 'tsigkey_id', 'hide_counts', 'client_addr',
]
def __init__(self, service_catalog=None, all_tenants=False, abandon=None,
- tsigkey_id=None, original_tenant=None,
+ tsigkey_id=None, original_project_id=None,
edit_managed_records=False, hide_counts=False,
client_addr=None, user_auth_plugin=None, **kwargs):
super(DesignateContext, self).__init__(**kwargs)
@@ -49,7 +49,7 @@ class DesignateContext(context.RequestContext):
self.service_catalog = service_catalog
self.tsigkey_id = tsigkey_id
- self.original_tenant = original_tenant
+ self.original_project_id = original_project_id
self.all_tenants = all_tenants
self.abandon = abandon
@@ -85,7 +85,7 @@ class DesignateContext(context.RequestContext):
# Update the dict with Designate specific extensions and overrides
d.update({
'user_identity': user_idt,
- 'original_tenant': self.original_tenant,
+ 'original_project_id': self.original_project_id,
'service_catalog': self.service_catalog,
'all_tenants': self.all_tenants,
'abandon': self.abandon,
@@ -121,14 +121,14 @@ class DesignateContext(context.RequestContext):
return context
- def sudo(self, tenant):
+ def sudo(self, project_id):
policy.check('use_sudo', self)
- LOG.info('Accepted sudo from user %(user)s to tenant %(tenant)s',
- {'user': self.user_id, 'tenant': tenant})
- self.original_tenant = self.tenant
- self.tenant = tenant
+ LOG.info('Accepted sudo from user %(user)s to project_id %(project)s',
+ {'user': self.user_id, 'project': project_id})
+ self.original_project_id = self.project_id
+ self.project_id = project_id
@classmethod
def get_admin_context(cls, **kwargs):
diff --git a/designate/tests/unit/test_context.py b/designate/tests/unit/test_context.py
index ad1d9022..2a296c1f 100644
--- a/designate/tests/unit/test_context.py
+++ b/designate/tests/unit/test_context.py
@@ -99,10 +99,10 @@ class TestDesignateContext(designate.tests.TestCase):
@mock.patch.object(policy, 'check')
def test_sudo(self, mock_policy_check):
ctxt = context.DesignateContext(
- user_id='12345', project_id='old_tenant'
+ user_id='12345', project_id='old_project'
)
- ctxt.sudo('new_tenant')
+ ctxt.sudo('new_project')
self.assertTrue(mock_policy_check.called)
- self.assertEqual('new_tenant', ctxt.tenant)
- self.assertEqual('old_tenant', ctxt.original_tenant)
+ self.assertEqual('new_project', ctxt.project_id)
+ self.assertEqual('old_project', ctxt.original_project_id)