summaryrefslogtreecommitdiff
path: root/oslo_context
diff options
context:
space:
mode:
authorChangBo Guo(gcb) <eric.guo@easystack.cn>2016-02-27 22:23:50 +0800
committerChangBo Guo(gcb) <eric.guo@easystack.cn>2016-02-27 22:28:48 +0800
commitc63a359094907bc50cc5e1be716508ddee825dfa (patch)
treece51d28c7064fbd825c23da42ce75f2072e19eec /oslo_context
parent187d5740632073750ccd4a5f8f1b4abed51f24b0 (diff)
downloadoslo-context-c63a359094907bc50cc5e1be716508ddee825dfa.tar.gz
Ensure to_dict() supports unicode
When we compose a string for user_identity, we should ensure that we don't break for non-ascii strings in user name or tenant name or domain names. Change-Id: Id457ebe415f78c435fc8ece810f0a1b20964dabf Closes-Bug: #1507937
Diffstat (limited to 'oslo_context')
-rw-r--r--oslo_context/context.py2
-rw-r--r--oslo_context/tests/test_context.py4
2 files changed, 4 insertions, 2 deletions
diff --git a/oslo_context/context.py b/oslo_context/context.py
index 24aa64e..038948d 100644
--- a/oslo_context/context.py
+++ b/oslo_context/context.py
@@ -48,7 +48,7 @@ class RequestContext(object):
accesses the system, as well as additional request information.
"""
- user_idt_format = '{user} {tenant} {domain} {user_domain} {p_domain}'
+ user_idt_format = u'{user} {tenant} {domain} {user_domain} {p_domain}'
def __init__(self, auth_token=None, user=None, tenant=None, domain=None,
user_domain=None, project_domain=None, is_admin=False,
diff --git a/oslo_context/tests/test_context.py b/oslo_context/tests/test_context.py
index e4f49c9..7d13c06 100644
--- a/oslo_context/tests/test_context.py
+++ b/oslo_context/tests/test_context.py
@@ -1,3 +1,4 @@
+# -*- encoding: utf-8 -*-
# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
@@ -177,7 +178,8 @@ class ContextTest(test_base.BaseTestCase):
def test_values(self):
auth_token = "token1"
- user = "user1"
+ # test unicode support
+ user = u"John Gāo"
tenant = "tenant1"
domain = "domain1"
user_domain = "user_domain1"