From 33a74fb2c45dc23e4792a70c586286941e37989a Mon Sep 17 00:00:00 2001 From: Serhii Tsymbaliuk Date: Mon, 8 Oct 2018 10:35:30 +0200 Subject: [PATCH] UI tests for "Automember": check setting default user/host group https://pagure.io/freeipa/issue/7721 Reviewed-By: Mohammad Rizwan Yusuf Reviewed-By: Petr Cech Reviewed-By: Petr Vobornik --- install/ui/src/freeipa/automember.js | 5 ++- ipatests/test_webui/test_automember.py | 59 ++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/install/ui/src/freeipa/automember.js b/install/ui/src/freeipa/automember.js index b3035e45e..fd86b2ed2 100644 --- a/install/ui/src/freeipa/automember.js +++ b/install/ui/src/freeipa/automember.js @@ -700,7 +700,10 @@ IPA.automember.default_group_widget = function(spec) { title: title }).appendTo(container); - that.group_select_node = $('
', { 'class': 'automember-header-control' }); + that.group_select_node = $('
', { + 'class': 'automember-header-control', + name: that.group_select.name + }); that.group_select.create(that.group_select_node); that.group_select_node.appendTo(container); that.group_select.update([]); // preload groups diff --git a/ipatests/test_webui/test_automember.py b/ipatests/test_webui/test_automember.py index 4405b32a2..9f80c297a 100644 --- a/ipatests/test_webui/test_automember.py +++ b/ipatests/test_webui/test_automember.py @@ -112,6 +112,9 @@ class TestAutomember(UI_driver): ] }) + def delete_users(self, *pkeys): + self.delete('user', [{'pkey': pkey} for pkey in pkeys]) + def delete_user_groups(self, *pkeys): self.delete('group', [{'pkey': pkey} for pkey in pkeys]) @@ -180,6 +183,12 @@ class TestAutomember(UI_driver): btn.click() self.wait() + def get_host_util(self): + host_util = host_tasks() + host_util.driver = self.driver + host_util.config = self.config + return host_util + @screenshot def test_crud(self): """ @@ -218,9 +227,7 @@ class TestAutomember(UI_driver): Test automember rebuild membership feature for hosts """ - host_util = host_tasks() - host_util.driver = self.driver - host_util.config = self.config + host_util = self.get_host_util() domain = self.config.get('ipa_domain') host1 = 'web1.%s' % domain host2 = 'web2.%s' % domain @@ -342,7 +349,7 @@ class TestAutomember(UI_driver): # Delete group, users and automember rule self.delete_user_groups('devel') - self.delete('user', [{'pkey': 'dev1'}, {'pkey': 'dev2'}]) + self.delete_users('dev1', 'dev2') self.delete_user_group_rules('devel') @screenshot @@ -530,3 +537,47 @@ class TestAutomember(UI_driver): self.delete_host_group_rules(pkey) self.delete_host_groups(pkey) + + @screenshot + def test_set_default_user_group(self): + """ + Test setting default user group + """ + + pkey = 'default-user-group' + user_pkey = 'some-user' + + self.add_user_group(pkey) + self.navigate_by_menu('identity/automember/amgroup') + self.select_combobox('automemberdefaultgroup', pkey) + + self.add_user(user_pkey, 'Some', 'User') + self.navigate_to_record(user_pkey) + self.switch_to_facet('memberof_group') + self.assert_record(pkey) + + self.delete_users(user_pkey) + self.delete_user_groups(pkey) + + @screenshot + def test_set_default_host_group(self): + """ + Test setting default host group + """ + + pkey = 'default-host-group' + host_util = self.get_host_util() + domain = self.config.get('ipa_domain') + + self.add_host_group(pkey) + self.navigate_by_menu('identity/automember/amhostgroup') + self.select_combobox('automemberdefaultgroup', pkey) + + host_data = host_util.get_data('some-host', domain) + self.add_record('host', host_data) + self.navigate_to_record(host_data['pkey']) + self.switch_to_facet('memberof_hostgroup') + self.assert_record(pkey) + + self.delete('host', [{'pkey': host_data['pkey']}]) + self.delete_host_groups(pkey)