Merge "Fixes deprecations caused by latest oslo.context"

This commit is contained in:
Jenkins 2017-01-28 03:06:17 +00:00 committed by Gerrit Code Review
commit 5958b3b0d2
2 changed files with 12 additions and 11 deletions

View File

@ -24,6 +24,12 @@ def _prop(name):
class RequestContext(oslo_context.RequestContext): class RequestContext(oslo_context.RequestContext):
def __init__(self, **kwargs): 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.project_name = kwargs.pop('project_name', None)
self.domain_name = kwargs.pop('domain_name', None) self.domain_name = kwargs.pop('domain_name', None)
self.username = kwargs.pop('username', None) self.username = kwargs.pop('username', None)
@ -46,9 +52,3 @@ class RequestContext(oslo_context.RequestContext):
def from_environ(cls, environ, **kwargs): def from_environ(cls, environ, **kwargs):
kwargs.setdefault('request_id', environ.get('openstack.request_id')) kwargs.setdefault('request_id', environ.get('openstack.request_id'))
return super(RequestContext, cls).from_environ(environ, **kwargs) 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')

View File

@ -1424,11 +1424,12 @@ class AuthContextMiddlewareTestCase(RestfulTestCase):
req_context = oslo_context.context.get_current() req_context = oslo_context.context.get_current()
self.assertEqual(request_id, req_context.request_id) self.assertEqual(request_id, req_context.request_id)
self.assertEqual(token, req_context.auth_token) self.assertEqual(token, req_context.auth_token)
self.assertEqual(self.user['id'], req_context.user) self.assertEqual(self.user['id'], req_context.user_id)
self.assertEqual(self.project['id'], req_context.tenant) self.assertEqual(self.project['id'], req_context.project_id)
self.assertIsNone(req_context.domain) self.assertIsNone(req_context.domain_id)
self.assertEqual(self.user['domain_id'], req_context.user_domain) self.assertEqual(self.user['domain_id'], req_context.user_domain_id)
self.assertEqual(self.project['domain_id'], req_context.project_domain) self.assertEqual(self.project['domain_id'],
req_context.project_domain_id)
self.assertFalse(req_context.is_admin) self.assertFalse(req_context.is_admin)