Change user name limit to 255 characters
Origin user name limit in heat is 64 characters. but the max acceptable username limit should be 255 in keystone. This patch propose to change the limit to 255 Also, this can avoid warning from heat keystone client in heat integration tests. Closes-Bug: #1685817 Change-Id: I7b9e7076bd700c086b07f13dadf89531579aa4a1
This commit is contained in:
parent
e8e0a2483a
commit
a41b5cf5eb
@ -238,11 +238,11 @@ class KsClientWrapper(object):
|
||||
pass
|
||||
|
||||
def _get_username(self, username):
|
||||
if(len(username) > 64):
|
||||
LOG.warning("Truncating the username %s to the last 64 "
|
||||
if(len(username) > 255):
|
||||
LOG.warning("Truncating the username %s to the last 255 "
|
||||
"characters.", username)
|
||||
# get the last 64 characters of the username
|
||||
return username[-64:]
|
||||
# get the last 255 characters of the username
|
||||
return username[-255:]
|
||||
|
||||
def create_stack_user(self, username, password=''):
|
||||
"""Create a user defined as part of a stack.
|
||||
|
@ -153,22 +153,22 @@ class KeystoneClientTest(common.HeatTestCase):
|
||||
return mock_ks_auth, mock_auth_ref
|
||||
|
||||
def test_username_length(self):
|
||||
"""Test that user names >64 characters are properly truncated."""
|
||||
"""Test that user names >255 characters are properly truncated."""
|
||||
|
||||
self._stubs_auth()
|
||||
|
||||
ctx = utils.dummy_context()
|
||||
ctx.trust_id = None
|
||||
|
||||
# a >64 character user name and the expected version
|
||||
long_user_name = 'U' * 64 + 'S'
|
||||
good_user_name = long_user_name[-64:]
|
||||
# a >255 character user name and the expected version
|
||||
long_user_name = 'U' * 255 + 'S'
|
||||
good_user_name = 'U' * 254 + 'S'
|
||||
# mock keystone client user functions
|
||||
self.mock_ks_v3_client.users = self.m.CreateMockAnything()
|
||||
mock_user = self.m.CreateMockAnything()
|
||||
mock_user.id = 'auser123'
|
||||
# when keystone is called, the name should have been truncated
|
||||
# to the last 64 characters of the long name
|
||||
# to the last 255 characters of the long name
|
||||
self.mock_ks_v3_client.users.create(name=good_user_name,
|
||||
password='password',
|
||||
default_project=ctx.tenant_id
|
||||
|
@ -61,7 +61,7 @@ def call_until_true(duration, sleep_for, func, *args, **kwargs):
|
||||
|
||||
|
||||
def rand_name(name=''):
|
||||
randbits = str(random.randint(1, 0x7fffffff))
|
||||
randbits = six.text_type(random.randint(1, 0x7fffffff))
|
||||
if name:
|
||||
return name + '-' + randbits
|
||||
else:
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
other:
|
||||
- Now heat keystone user name charaters limit increased from 64 to 255.
|
||||
Any extra charaters will lost when truncate the name to the last 255
|
||||
charaters.
|
Loading…
Reference in New Issue
Block a user