Merge "Allow deprecated X-Tenant-Name in from_environ"

This commit is contained in:
Jenkins 2016-07-11 23:00:35 +00:00 committed by Gerrit Code Review
commit 6a9bc57a9b
2 changed files with 12 additions and 1 deletions

View File

@ -46,7 +46,8 @@ _ENVIRON_HEADERS = {'auth_token': ['HTTP_X_AUTH_TOKEN',
'user_domain': ['HTTP_X_USER_DOMAIN_ID'],
'project_domain': ['HTTP_X_PROJECT_DOMAIN_ID'],
'user_name': ['HTTP_X_USER_NAME'],
'project_name': ['HTTP_X_PROJECT_NAME'],
'project_name': ['HTTP_X_PROJECT_NAME',
'HTTP_X_TENANT_NAME'],
'user_domain_name': ['HTTP_X_USER_DOMAIN_NAME'],
'project_domain_name': ['HTTP_X_PROJECT_DOMAIN_NAME'],
'request_id': ['openstack.request_id'],

View File

@ -214,6 +214,10 @@ class ContextTest(test_base.BaseTestCase):
ctx = context.RequestContext.from_environ(environ=environ)
self.assertEqual([value], ctx.roles)
environ = {'HTTP_X_TENANT_NAME': value}
ctx = context.RequestContext.from_environ(environ=environ)
self.assertEqual(value, ctx.project_name)
def test_from_environ_deprecated_precendence(self):
old = uuid.uuid4().hex
new = uuid.uuid4().hex
@ -239,6 +243,12 @@ class ContextTest(test_base.BaseTestCase):
tenant=override)
self.assertEqual(ctx.tenant, override)
environ = {'HTTP_X_TENANT_NAME': old,
'HTTP_X_PROJECT_NAME': new}
ctx = context.RequestContext.from_environ(environ=environ)
self.assertEqual(ctx.project_name, new)
def test_from_environ_strip_roles(self):
environ = {'HTTP_X_ROLES': ' abc\t,\ndef\n,ghi\n\n'}
ctx = context.RequestContext.from_environ(environ=environ)