Remove heat_stack_owner role assigning to user

Prior to juno, and with earlier juno defaults, users needed to have
the heat_stack_owner role to use heat stack apis assign that role
to the user if the role is present.

Juno is very old release, deprecated and this functionality is no
longer needed so we are removing the code for the same.

Depends-On: https://review.opendev.org/#/c/660985/

Story: 2005756
Task: 33459

Change-Id: Ifd4f1c9162449864a91bdc480689679f902e1437
Signed-off-by: Chandan Kumar (raukadah) <chkumar@redhat.com>
This commit is contained in:
Chandan Kumar (raukadah) 2019-05-23 13:11:12 +05:30
parent e0d5dd6725
commit a7172e6561
3 changed files with 8 additions and 32 deletions

View File

@ -520,7 +520,7 @@ def config_tempest(**kwargs):
if kwargs.get('create', False) and kwargs.get('test_accounts') is None:
users = Users(clients.projects, clients.roles, clients.users, conf)
users.create_tempest_users(services.is_service('orchestration'))
users.create_tempest_users()
flavors = Flavors(clients.flavors, kwargs.get('create', False), conf,
kwargs.get('flavor_min_mem', C.DEFAULT_FLAVOR_RAM),
kwargs.get('flavor_min_disk', C.DEFAULT_FLAVOR_DISK),

View File

@ -57,29 +57,17 @@ class TestUsers(BaseConfigTempestTest):
@mock.patch('config_tempest.users.Users.give_role_to_user')
def _test_create_tempest_user(self,
mock_give_role_to_user,
mock_create_user_with_project,
orchestration=False):
mock_create_user_with_project):
alt_username = "my_user"
alt_password = "my_pass"
alt_project_name = "my_project"
self.conf.set("identity", "alt_username", alt_username)
self.conf.set("identity", "alt_password", alt_password)
self.conf.set("identity", "alt_project_name", alt_project_name)
self.Service.create_tempest_users(orchestration)
if orchestration:
self.assertEqual(mock_give_role_to_user.mock_calls, [
mock.call(self.conf.get('auth',
'admin_username'),
role_name='admin'),
mock.call(self.conf.get('identity',
'username'),
role_name='heat_stack_owner',
role_required=False),
])
else:
mock_give_role_to_user.assert_called_with(
self.conf.get('auth', 'admin_username'),
role_name='admin')
self.Service.create_tempest_users()
mock_give_role_to_user.assert_called_with(
self.conf.get('auth', 'admin_username'),
role_name='admin')
self.assertEqual(mock_create_user_with_project.mock_calls, [
mock.call(self.conf.get('identity', 'username'),
self.conf.get('identity', 'password'),
@ -90,10 +78,7 @@ class TestUsers(BaseConfigTempestTest):
])
def test_create_tempest_user(self):
self._test_create_tempest_user(orchestration=False)
def test_create_tempest_user_with_orchestration(self):
self._test_create_tempest_user(orchestration=True)
self._test_create_tempest_user()
@mock.patch('config_tempest.clients.ProjectsClient'
'.get_project_by_name')

View File

@ -31,10 +31,9 @@ class Users(object):
self.users_client = users_client
self._conf = conf
def create_tempest_users(self, orchestration=False):
def create_tempest_users(self):
"""Create users necessary for Tempest if they don't exist already.
:type orchestration: boolean
"""
sec = 'identity'
self.create_user_with_project(self._conf.get(sec, 'username'),
@ -49,14 +48,6 @@ class Users(object):
self.give_role_to_user(username, role_name='admin')
# Prior to juno, and with earlier juno defaults, users needed to have
# the heat_stack_owner role to use heat stack apis. We assign that role
# to the user if the role is present.
if orchestration:
self.give_role_to_user(self._conf.get('identity', 'username'),
role_name='heat_stack_owner',
role_required=False)
def give_role_to_user(self, username, role_name,
role_required=True):
"""Give the user a role in the project.