summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamie Lennox <jamielennox@gmail.com>2016-08-19 09:17:39 +1000
committerJamie Lennox <jamielennox@gmail.com>2016-08-19 09:18:57 +1000
commitfd224586199f99affc5d37993907024bbf3cd00f (patch)
treeb43bc694689e301c2cff534220553a9e9905b1a3
parent0ad0950e0637c37145bc04df2166468523f8a10a (diff)
downloadoslo-context-fd224586199f99affc5d37993907024bbf3cd00f.tar.gz
Fix X-User and X-Tenant deprecated headers in from_environ
The X-User and X-Tenant deprecated headers from auth_token middleware are actually name values, not ID values. In most cases this doesn't matter because these are deprecated and only used when no newer headers are available but we should still fix it. Closes-Bug: #1614776 Change-Id: I16e80671e853387004434e766dd6ceebe0a6b2a6
-rw-r--r--oslo_context/context.py12
-rw-r--r--oslo_context/tests/test_context.py4
2 files changed, 8 insertions, 8 deletions
diff --git a/oslo_context/context.py b/oslo_context/context.py
index 1a2ce21..0961f3f 100644
--- a/oslo_context/context.py
+++ b/oslo_context/context.py
@@ -39,16 +39,16 @@ _request_store = threading.local()
# header to support backwards compatibility.
_ENVIRON_HEADERS = {'auth_token': ['HTTP_X_AUTH_TOKEN',
'HTTP_X_STORAGE_TOKEN'],
- 'user': ['HTTP_X_USER_ID',
- 'HTTP_X_USER'],
+ 'user': ['HTTP_X_USER_ID'],
'tenant': ['HTTP_X_PROJECT_ID',
- 'HTTP_X_TENANT_ID',
- 'HTTP_X_TENANT'],
+ 'HTTP_X_TENANT_ID'],
'user_domain': ['HTTP_X_USER_DOMAIN_ID'],
'project_domain': ['HTTP_X_PROJECT_DOMAIN_ID'],
- 'user_name': ['HTTP_X_USER_NAME'],
+ 'user_name': ['HTTP_X_USER_NAME',
+ 'HTTP_X_USER'],
'project_name': ['HTTP_X_PROJECT_NAME',
- 'HTTP_X_TENANT_NAME'],
+ 'HTTP_X_TENANT_NAME',
+ 'HTTP_X_TENANT'],
'user_domain_name': ['HTTP_X_USER_DOMAIN_NAME'],
'project_domain_name': ['HTTP_X_PROJECT_DOMAIN_NAME'],
'request_id': ['openstack.request_id'],
diff --git a/oslo_context/tests/test_context.py b/oslo_context/tests/test_context.py
index 956c1e5..4e03dfe 100644
--- a/oslo_context/tests/test_context.py
+++ b/oslo_context/tests/test_context.py
@@ -233,7 +233,7 @@ class ContextTest(test_base.BaseTestCase):
environ = {'HTTP_X_USER': value}
ctx = context.RequestContext.from_environ(environ=environ)
- self.assertEqual(value, ctx.user)
+ self.assertEqual(value, ctx.user_name)
environ = {'HTTP_X_TENANT_ID': value}
ctx = context.RequestContext.from_environ(environ=environ)
@@ -245,7 +245,7 @@ class ContextTest(test_base.BaseTestCase):
environ = {'HTTP_X_TENANT': value}
ctx = context.RequestContext.from_environ(environ=environ)
- self.assertEqual(value, ctx.tenant)
+ self.assertEqual(value, ctx.project_name)
environ = {'HTTP_X_ROLE': value}
ctx = context.RequestContext.from_environ(environ=environ)