From dce8a2c11e8f600cc015b6cba9113cacd69aaa4d Mon Sep 17 00:00:00 2001 From: David Stanek Date: Fri, 27 Jan 2017 22:15:16 +0000 Subject: [PATCH] Fixes deprecations caused by latest oslo.context In oslo.context 2.12.0 a number of things used by keystone were deprecated. This causes the keystone tests to fail since we treat deprecation as errors. Change-Id: I885431ba957909e709648e03a05bc280441ffbf5 --- keystone/common/context.py | 12 ++++++------ keystone/tests/unit/test_v3.py | 11 ++++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/keystone/common/context.py b/keystone/common/context.py index 7ac997a39..6be3a6524 100644 --- a/keystone/common/context.py +++ b/keystone/common/context.py @@ -24,6 +24,12 @@ def _prop(name): class RequestContext(oslo_context.RequestContext): def __init__(self, **kwargs): + self.user_id = kwargs.pop('user_id ', None) + self.project_id = kwargs.pop('project_id ', None) + self.domain_id = kwargs.pop('domain_id ', None) + self.user_domain_id = kwargs.pop('user_domain_id ', None) + self.project_domain_id = kwargs.pop('project_domain_id ', None) + self.project_name = kwargs.pop('project_name', None) self.domain_name = kwargs.pop('domain_name', None) self.username = kwargs.pop('username', None) @@ -46,9 +52,3 @@ class RequestContext(oslo_context.RequestContext): def from_environ(cls, environ, **kwargs): kwargs.setdefault('request_id', environ.get('openstack.request_id')) return super(RequestContext, cls).from_environ(environ, **kwargs) - - user_id = _prop('user') - project_id = _prop('tenant') - domain_id = _prop('domain') - user_domain_id = _prop('user_domain') - project_domain_id = _prop('project_domain') diff --git a/keystone/tests/unit/test_v3.py b/keystone/tests/unit/test_v3.py index e446acb8b..4016b6675 100644 --- a/keystone/tests/unit/test_v3.py +++ b/keystone/tests/unit/test_v3.py @@ -1424,11 +1424,12 @@ class AuthContextMiddlewareTestCase(RestfulTestCase): req_context = oslo_context.context.get_current() self.assertEqual(request_id, req_context.request_id) self.assertEqual(token, req_context.auth_token) - self.assertEqual(self.user['id'], req_context.user) - self.assertEqual(self.project['id'], req_context.tenant) - self.assertIsNone(req_context.domain) - self.assertEqual(self.user['domain_id'], req_context.user_domain) - self.assertEqual(self.project['domain_id'], req_context.project_domain) + self.assertEqual(self.user['id'], req_context.user_id) + self.assertEqual(self.project['id'], req_context.project_id) + self.assertIsNone(req_context.domain_id) + self.assertEqual(self.user['domain_id'], req_context.user_domain_id) + self.assertEqual(self.project['domain_id'], + req_context.project_domain_id) self.assertFalse(req_context.is_admin)