From a41b5cf5eb2fcb3ab999c2eaee0838d5ca10f6e6 Mon Sep 17 00:00:00 2001 From: ricolin Date: Mon, 24 Apr 2017 23:51:09 +0800 Subject: [PATCH] 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 --- heat/engine/clients/os/keystone/heat_keystoneclient.py | 8 ++++---- heat/tests/clients/test_heat_client.py | 10 +++++----- heat_integrationtests/common/test.py | 2 +- ...ystone-user-name-limit-to-255-bd076132b98744be.yaml | 5 +++++ 4 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 releasenotes/notes/change-heat-keystone-user-name-limit-to-255-bd076132b98744be.yaml diff --git a/heat/engine/clients/os/keystone/heat_keystoneclient.py b/heat/engine/clients/os/keystone/heat_keystoneclient.py index 110b2fa0d5..21131d30b7 100644 --- a/heat/engine/clients/os/keystone/heat_keystoneclient.py +++ b/heat/engine/clients/os/keystone/heat_keystoneclient.py @@ -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. diff --git a/heat/tests/clients/test_heat_client.py b/heat/tests/clients/test_heat_client.py index ae3ffbce9e..e17427ceb3 100644 --- a/heat/tests/clients/test_heat_client.py +++ b/heat/tests/clients/test_heat_client.py @@ -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 diff --git a/heat_integrationtests/common/test.py b/heat_integrationtests/common/test.py index f2e7dd75c2..842f4e774b 100644 --- a/heat_integrationtests/common/test.py +++ b/heat_integrationtests/common/test.py @@ -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: diff --git a/releasenotes/notes/change-heat-keystone-user-name-limit-to-255-bd076132b98744be.yaml b/releasenotes/notes/change-heat-keystone-user-name-limit-to-255-bd076132b98744be.yaml new file mode 100644 index 0000000000..eeaf4fc767 --- /dev/null +++ b/releasenotes/notes/change-heat-keystone-user-name-limit-to-255-bd076132b98744be.yaml @@ -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.