diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2013-06-26 15:18:05 +0200 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2013-07-26 13:35:12 +0200 |
commit | ae311300981f127dc978526f68aaae3f64e3b519 (patch) | |
tree | a76bb524ebfb0f9225eca77c7ef3671cf8694898 | |
parent | 6a0aabede5875ad23dab777d0c2f6bac05fa2599 (diff) | |
download | freeipa-ae311300981f127dc978526f68aaae3f64e3b519.tar.gz freeipa-ae311300981f127dc978526f68aaae3f64e3b519.tar.xz freeipa-ae311300981f127dc978526f68aaae3f64e3b519.zip |
Web UI integration tests: Add trust tests
https://fedorahosted.org/freeipa/ticket/3744
-rw-r--r-- | ipatests/test_webui/test_realmdomains.py | 2 | ||||
-rw-r--r-- | ipatests/test_webui/test_trust.py | 92 | ||||
-rw-r--r-- | ipatests/test_webui/ui_driver.py | 40 |
3 files changed, 124 insertions, 10 deletions
diff --git a/ipatests/test_webui/test_realmdomains.py b/ipatests/test_webui/test_realmdomains.py index ea8984118..7173e13b7 100644 --- a/ipatests/test_webui/test_realmdomains.py +++ b/ipatests/test_webui/test_realmdomains.py @@ -41,7 +41,7 @@ class test_realmdomains(UI_driver): self.wait_for_request() # delete - self.delete_multivalued('associateddomain', 'itest.bar') + self.del_multivalued('associateddomain', 'itest.bar') self.facet_button_click('update') self.dialog_button_click('force') self.wait_for_request() diff --git a/ipatests/test_webui/test_trust.py b/ipatests/test_webui/test_trust.py new file mode 100644 index 000000000..e308844d9 --- /dev/null +++ b/ipatests/test_webui/test_trust.py @@ -0,0 +1,92 @@ +# Authors: +# Petr Vobornik <pvoborni@redhat.com> +# +# Copyright (C) 2013 Red Hat +# see file 'COPYING' for use and warranty information +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +""" +Trust tests +""" + +from ipatests.test_webui.ui_driver import UI_driver + +ENTITY = 'trust' +CONFIG_ENTITY = 'trustconfig' + +CONFIG_DATA = { + 'mod': [ + ['combobox', 'ipantfallbackprimarygroup', 'admins'], + ] +} + +CONFIG_DATA2 = { + 'mod': [ + ['combobox', 'ipantfallbackprimarygroup', 'Default SMB Group'] + ] +} + + +class test_trust(UI_driver): + + def __init__(self, *args, **kwargs): + super(test_trust, self).__init__(args, kwargs) + + if not self.has_trusts(): + self.skip('Trusts not configured') + + def get_data(self): + + domain = self.config.get('ad_domain') + admin = self.config.get('ad_admin') + psw = self.config.get('ad_password') + + data = { + 'pkey': domain, + 'add': [ + ('textbox', 'realm_server', domain), + ('textbox', 'realm_admin', admin), + ('password', 'realm_passwd', psw), + ], + 'mod': [ + ('multivalued', 'ipantsidblacklistincoming', [ + ('del', 'S-1-5-18'), + ('add', 'S-1-5-21'), + ]), + ('multivalued', 'ipantsidblacklistoutgoing', [ + ('del', 'S-1-5-18'), + ('add', 'S-1-5-21'), + ]), + ], + } + + return data + + def test_crud(self): + """ + Basic basic CRUD: trust + + Test establishing trust by using Windows admin credentials + """ + self.init_app() + data = self.get_data() + self.basic_crud(ENTITY, data) + + def test_config_mod(self): + self.init_app() + self.navigate_to_entity(CONFIG_ENTITY) + + self.mod_record(CONFIG_ENTITY, CONFIG_DATA) + self.mod_record(CONFIG_ENTITY, CONFIG_DATA2) diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py index e7551dea5..4a0ca1cd1 100644 --- a/ipatests/test_webui/ui_driver.py +++ b/ipatests/test_webui/ui_driver.py @@ -86,6 +86,7 @@ class UI_driver(object): raise nose.SkipTest('Selenium not installed') def __init__(self, driver=None, config=None): + self.request_timeout = 30 self.driver = driver self.config = config if not config: @@ -261,7 +262,7 @@ class UI_driver(object): for i in range(n): self.wait(implicit) - WebDriverWait(self.driver, 10).until_not(lambda d: runner.has_active_request()) + WebDriverWait(self.driver, self.request_timeout).until_not(lambda d: runner.has_active_request()) self.wait() self.wait(d) @@ -586,7 +587,7 @@ class UI_driver(object): last = inputs[-1] last.send_keys(value) - def delete_multivalued(self, name, value, parent=None): + def del_multivalued(self, name, value, parent=None): if not parent: parent = self.get_form() s = "div[name='%s'].multivalued-widget" % name @@ -604,7 +605,19 @@ class UI_driver(object): self.wait() clicked = True - assert clicked, 'Value was not removed' + assert clicked, 'Value was not removed: %s' % value + + def fill_multivalued(self, name, instructions, parent=None): + """ + Add or delete a value from multivalued field + """ + for instruction in instructions: + t = instruction[0] + value = instruction[1] + if t == 'add': + self.add_multivalued(name, value, parent) + else: + self.del_multivalued(name, value, parent) def check_option(self, name, value=None, parent=None): @@ -661,7 +674,7 @@ class UI_driver(object): self.wait() - def get_undo_button(self, field, parent): + def get_undo_buttons(self, field, parent): """ Get field undo button """ @@ -669,8 +682,8 @@ class UI_driver(object): if not parent: parent = self.get_form() s = "div[name='%s'].field span.undo" % (field) - undo = self.find(s, By.CSS_SELECTOR, parent, strict=True) - return undo + undos = self.find(s, By.CSS_SELECTOR, parent, strict=True, all=True) + return undos def get_rows(self, parent=None): """ @@ -821,6 +834,8 @@ class UI_driver(object): self.add_table_record(key, val, parent) elif type == 'add_table_association': self.add_table_associations(key, val, parent) + elif type == 'multivalued': + self.fill_multivalued(key, val, parent) elif type == 'table': self.select_record(val, parent, key) self.wait() @@ -1266,9 +1281,16 @@ class UI_driver(object): """ Assert that undo button is or is not visible """ - undo = self.get_undo_button(field, parent) - state = undo.is_displayed() - assert state == visible, 'Undo button has invalid state. Field: %s' % field + undos = self.get_undo_buttons(field, parent) + state = False + for undo in undos: + if undo.is_displayed(): + state = True + break + if visible: + assert state, "Undo button not visible. Field: %s" % field + else: + assert not state, "Undo button visible. Field: %s" % field def assert_visible(self, selector, parent=None, negative=False): """ |