To use id instead of name when making credentials from context

If tenant_name or user_name has chinese characters,
an 'UnicodeEncodeError' exception raised when making
credentials from request context.
There are two solutions to fix this problem:
1. Call encodeutils.safe_encode to encode the tenant_name
with utf-8 before using.
2. Modify to use tenant_id/user_id instead
of name as other OpenStack projects(Nova, Cinder, Neutron...)
did.

This patch select the  option2 to fix the problem.

Change-Id: I2510405b7b2cc9125828a19a151a56bcd44c2222
Closes-Bug: #1488754
This commit is contained in:
huangtianhua 2015-08-26 17:20:29 +08:00 committed by Rico Lin
parent c79bd02e28
commit 2314ed85c2
2 changed files with 4 additions and 4 deletions

View File

@ -95,8 +95,8 @@ class RequestContext(context.RequestContext):
return self._clients
def to_dict(self):
user_idt = '{user} {tenant}'.format(user=self.username or '-',
tenant=self.tenant or '-')
user_idt = '{user} {tenant}'.format(user=self.user_id or '-',
tenant=self.tenant_id or '-')
return {'auth_token': self.auth_token,
'username': self.username,

View File

@ -42,11 +42,11 @@ class TestRequestContext(common.HeatTestCase):
'roles': ['arole', 'notadmin'],
'tenant_id': '456tenant',
'user_id': 'fooUser',
'tenant': 'atenant',
'tenant': u'\u5218\u80dc',
'auth_url': 'http://xyz',
'aws_creds': 'blah',
'region_name': 'RegionOne',
'user_identity': 'mick atenant'}
'user_identity': 'fooUser 456tenant'}
super(TestRequestContext, self).setUp()