summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--keystone/common/sql/core.py4
-rw-r--r--tests/test_backend.py9
2 files changed, 12 insertions, 1 deletions
diff --git a/keystone/common/sql/core.py b/keystone/common/sql/core.py
index ee95e9af..fb29298a 100644
--- a/keystone/common/sql/core.py
+++ b/keystone/common/sql/core.py
@@ -73,8 +73,10 @@ def initialize_decorator(init):
if isinstance(attr, InstrumentedAttribute):
column = attr.property.columns[0]
if isinstance(column.type, String):
+ if not isinstance(v, unicode):
+ v = str(v)
if column.type.length and \
- column.type.length < len(str(v)):
+ column.type.length < len(v):
#if signing.token_format == 'PKI', the id will
#store it's public key which is very long.
if config.CONF.signing.token_format == 'PKI' and \
diff --git a/tests/test_backend.py b/tests/test_backend.py
index fea52b8e..2a2b93aa 100644
--- a/tests/test_backend.py
+++ b/tests/test_backend.py
@@ -136,6 +136,15 @@ class IdentityTests(object):
user_ref = self.identity_api._get_user(self.user_foo['id'])
self.assertNotEqual(user_ref['password'], self.user_foo['password'])
+ def test_create_unicode_user_name(self):
+ unicode_name = u'name \u540d\u5b57'
+ user = {'id': uuid.uuid4().hex,
+ 'name': unicode_name,
+ 'domain_id': DEFAULT_DOMAIN_ID,
+ 'password': uuid.uuid4().hex}
+ ref = self.identity_api.create_user(user['id'], user)
+ self.assertEqual(unicode_name, ref['name'])
+
def test_get_project(self):
tenant_ref = self.identity_api.get_project(
tenant_id=self.tenant_bar['id'])