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:
parent
c79bd02e28
commit
2314ed85c2
@ -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,
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user