URL: https://github.com/freeipa/freeipa/pull/1765 Author: pvoborni Title: #1765: [Backport][ipa-4-6] test realm domain add with DNS check Action: opened
PR body: """ This is a backport of PR #1596 to ipa-4-6. A new ticket was created for the backport: https://pagure.io/freeipa/issue/7481 Only commit message was changed. So could be acked automatically as other backport patches. """ To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/1765/head:pr1765 git checkout pr1765
From 6bd4051108dad19a46e82315730dcb4e13ceca6b Mon Sep 17 00:00:00 2001 From: Petr Vobornik <pvobo...@redhat.com> Date: Fri, 16 Feb 2018 17:26:33 +0100 Subject: [PATCH 1/3] webui:tests: move DNS test data to separate file So that the data can be used in other test without running the DNS tests. https://pagure.io/freeipa/issue/7481 Reviewed-By: Petr Cech <pc...@redhat.com> --- ipatests/test_webui/data_dns.py | 63 +++++++++++++++++++++++++++++++++++++++ ipatests/test_webui/test_dns.py | 66 ++++------------------------------------- 2 files changed, 69 insertions(+), 60 deletions(-) create mode 100644 ipatests/test_webui/data_dns.py diff --git a/ipatests/test_webui/data_dns.py b/ipatests/test_webui/data_dns.py new file mode 100644 index 0000000000..95e502adad --- /dev/null +++ b/ipatests/test_webui/data_dns.py @@ -0,0 +1,63 @@ +# +# Copyright (C) 2018 FreeIPA Contributors see COPYING for license +# + +ZONE_ENTITY = 'dnszone' +FORWARD_ZONE_ENTITY = 'dnsforwardzone' +RECORD_ENTITY = 'dnsrecord' +CONFIG_ENTITY = 'dnsconfig' + +ZONE_DEFAULT_FACET = 'records' + +ZONE_PKEY = 'foo.itest.' + +ZONE_DATA = { + 'pkey': ZONE_PKEY, + 'add': [ + ('textbox', 'idnsname', ZONE_PKEY), + ], + 'mod': [ + ('checkbox', 'idnsallowsyncptr', 'checked'), + ], +} + +FORWARD_ZONE_PKEY = 'forward.itest.' + +FORWARD_ZONE_DATA = { + 'pkey': FORWARD_ZONE_PKEY, + 'add': [ + ('textbox', 'idnsname', FORWARD_ZONE_PKEY), + ('multivalued', 'idnsforwarders', [ + ('add', '192.168.2.1'), + ]), + ('radio', 'idnsforwardpolicy', 'only'), + ], + 'mod': [ + ('multivalued', 'idnsforwarders', [ + ('add', '192.168.3.1'), + ]), + ('checkbox', 'idnsforwardpolicy', 'first'), + ], +} + +RECORD_PKEY = 'itest' +A_IP = '192.168.1.10' +RECORD_ADD_DATA = { + 'pkey': RECORD_PKEY, + 'add': [ + ('textbox', 'idnsname', RECORD_PKEY), + ('textbox', 'a_part_ip_address', A_IP), + ] +} + +RECORD_MOD_DATA = { + 'fields': [ + ('textbox', 'a_part_ip_address', '192.168.1.11'), + ] +} + +CONFIG_MOD_DATA = { + 'mod': [ + ('checkbox', 'idnsallowsyncptr', 'checked'), + ], +} diff --git a/ipatests/test_webui/test_dns.py b/ipatests/test_webui/test_dns.py index a576db9df7..24e79dd85a 100644 --- a/ipatests/test_webui/test_dns.py +++ b/ipatests/test_webui/test_dns.py @@ -23,68 +23,14 @@ from ipatests.test_webui.ui_driver import UI_driver from ipatests.test_webui.ui_driver import screenshot +from ipatests.test_webui.data_dns import ( + ZONE_ENTITY, FORWARD_ZONE_ENTITY, CONFIG_ENTITY, + ZONE_DEFAULT_FACET, ZONE_PKEY, ZONE_DATA, FORWARD_ZONE_PKEY, + FORWARD_ZONE_DATA, RECORD_PKEY, A_IP, RECORD_ADD_DATA, RECORD_MOD_DATA, + CONFIG_MOD_DATA +) import pytest -ZONE_ENTITY = 'dnszone' -FORWARD_ZONE_ENTITY = 'dnsforwardzone' -RECORD_ENTITY = 'dnsrecord' -CONFIG_ENTITY = 'dnsconfig' - -ZONE_DEFAULT_FACET = 'records' - -ZONE_PKEY = 'foo.itest.' - -ZONE_DATA = { - 'pkey': ZONE_PKEY, - 'add': [ - ('textbox', 'idnsname', ZONE_PKEY), - ], - 'mod': [ - ('checkbox', 'idnsallowsyncptr', 'checked'), - ], -} - -FORWARD_ZONE_PKEY = 'forward.itest.' - -FORWARD_ZONE_DATA = { - 'pkey': FORWARD_ZONE_PKEY, - 'add': [ - ('textbox', 'idnsname', FORWARD_ZONE_PKEY), - ('multivalued', 'idnsforwarders', [ - ('add', '192.168.2.1'), - ]), - ('radio', 'idnsforwardpolicy', 'only'), - ], - 'mod': [ - ('multivalued', 'idnsforwarders', [ - ('add', '192.168.3.1'), - ]), - ('checkbox', 'idnsforwardpolicy', 'first'), - ], -} - -RECORD_PKEY = 'itest' -A_IP = '192.168.1.10' -RECORD_ADD_DATA = { - 'pkey': RECORD_PKEY, - 'add': [ - ('textbox', 'idnsname', RECORD_PKEY), - ('textbox', 'a_part_ip_address', A_IP), - ] -} - -RECORD_MOD_DATA = { - 'fields': [ - ('textbox', 'a_part_ip_address', '192.168.1.11'), - ] -} - -CONFIG_MOD_DATA = { - 'mod': [ - ('checkbox', 'idnsallowsyncptr', 'checked'), - ], -} - @pytest.mark.tier1 class test_dns(UI_driver): From 9cae0f3e8ecb75569b6a41411364c9e02a48adbf Mon Sep 17 00:00:00 2001 From: Petr Vobornik <pvobo...@redhat.com> Date: Fri, 16 Feb 2018 18:12:48 +0100 Subject: [PATCH 2/3] webui:tests: realm domain add with DNS check Try adding and deleting with "Check DNS" (in html 'ok' button) DNS check expects that the added domain will have DNS record: TXT _kerberos.$domain "$REALM" When a new domain is added using dnszone-add it automatically adds this TXT record and adds a realm domain. So in order to test without external DNS we must get into state where realm domain is not added (in order to add it) but DNS domain with the TXT record exists. https://pagure.io/freeipa/issue/7481 Reviewed-By: Petr Cech <pc...@redhat.com> --- ipatests/test_webui/test_realmdomains.py | 62 +++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/ipatests/test_webui/test_realmdomains.py b/ipatests/test_webui/test_realmdomains.py index e7737c9320..d53f23e1b7 100644 --- a/ipatests/test_webui/test_realmdomains.py +++ b/ipatests/test_webui/test_realmdomains.py @@ -23,6 +23,9 @@ from ipatests.test_webui.ui_driver import UI_driver from ipatests.test_webui.ui_driver import screenshot +from ipatests.test_webui.data_dns import ( + ZONE_ENTITY, ZONE_DATA, ZONE_PKEY, ZONE_DEFAULT_FACET +) import pytest ENTITY = 'realmdomains' @@ -31,6 +34,12 @@ @pytest.mark.tier1 class test_realmdomains(UI_driver): + def del_realm_domain(self, realmdomain, button): + self.del_multivalued('associateddomain', realmdomain) + self.facet_button_click('save') + self.dialog_button_click(button) + self.wait_for_request() + @screenshot def test_read(self): """ @@ -39,15 +48,60 @@ def test_read(self): self.init_app() self.navigate_to_entity(ENTITY) - # add + # add with force - skipping DNS check self.add_multivalued('associateddomain', 'itest.bar') self.facet_button_click('save') self.dialog_button_click('force') self.wait_for_request() # delete - self.del_multivalued('associateddomain', 'itest.bar') - self.facet_button_click('save') - self.dialog_button_click('force') + self.del_realm_domain('itest.bar', 'force') self.wait_for_request() + + # Try adding and deleting with "Check DNS" (in html 'ok' button) + + # DNS check expects that the added domain will have DNS record: + # TXT _kerberos.$domain "$REALM" + # When a new domain is added using dnszone-add it automatically adds + # this TXT record and adds a realm domain. So in order to test without + # external DNS we must get into state where realm domain is not added + # (in order to add it) but DNS domain with the TXT record + # exists. + + # add DNS domain + self.navigate_to_entity(ZONE_ENTITY) + self.add_record(ZONE_ENTITY, ZONE_DATA) + + realmdomain = ZONE_PKEY.strip('.') + realm = self.config.get('ipa_realm') + + # remove the added domain from Realm Domain + self.navigate_to_entity(ENTITY) + self.del_realm_domain(realmdomain, 'ok') + + # re-add _TXT kerberos.$domain "$REALM" + self.navigate_to_entity(ZONE_ENTITY) + self.navigate_to_record(ZONE_PKEY) + + DNS_RECORD_ADD_DATA = { + 'pkey': '_kerberos', + 'add': [ + ('textbox', 'idnsname', '_kerberos'), + ('selectbox', 'record_type', 'txtrecord'), + ('textbox', 'txt_part_data', realm), + ] + } + self.add_record(ZONE_ENTITY, DNS_RECORD_ADD_DATA, + facet=ZONE_DEFAULT_FACET, navigate=False) + + # add Realm Domain and Check DNS + self.navigate_to_entity(ENTITY) + self.add_multivalued('associateddomain', realmdomain) + self.facet_button_click('save') + self.dialog_button_click('ok') self.wait_for_request() + + # cleanup + self.del_realm_domain(realmdomain, 'ok') + self.navigate_to_entity(ZONE_ENTITY) + self.delete_record(ZONE_PKEY) From 87cb8f024cff204f3ac3c9b5137d858e54d71bd3 Mon Sep 17 00:00:00 2001 From: Petr Vobornik <pvobo...@redhat.com> Date: Fri, 16 Feb 2018 23:54:40 +0100 Subject: [PATCH 3/3] webui:tests: close big notifications in realm domains tests Realm domains commands produce big fat warnings about DNS state/checks. Given the length of these warnings, they stay displayed for longer time. As Web UI automated tests progresses quickly more of the warnings can be displayed at the same time and thus taking a lot of space and thus covering UI needed for next test step. By closing the notifications before next action we make sure that test won't fail because notification covered the required UI. https://pagure.io/freeipa/issue/7481 Reviewed-By: Petr Cech <pc...@redhat.com> --- ipatests/test_webui/test_realmdomains.py | 3 +++ ipatests/test_webui/ui_driver.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/ipatests/test_webui/test_realmdomains.py b/ipatests/test_webui/test_realmdomains.py index d53f23e1b7..56fd791ec6 100644 --- a/ipatests/test_webui/test_realmdomains.py +++ b/ipatests/test_webui/test_realmdomains.py @@ -39,6 +39,7 @@ def del_realm_domain(self, realmdomain, button): self.facet_button_click('save') self.dialog_button_click(button) self.wait_for_request() + self.close_notifications() @screenshot def test_read(self): @@ -53,6 +54,7 @@ def test_read(self): self.facet_button_click('save') self.dialog_button_click('force') self.wait_for_request() + self.close_notifications() # delete self.del_realm_domain('itest.bar', 'force') @@ -78,6 +80,7 @@ def test_read(self): # remove the added domain from Realm Domain self.navigate_to_entity(ENTITY) self.del_realm_domain(realmdomain, 'ok') + self.close_notifications() # re-add _TXT kerberos.$domain "$REALM" self.navigate_to_entity(ZONE_ENTITY) diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py index acf865b3e2..ee38782f5f 100644 --- a/ipatests/test_webui/ui_driver.py +++ b/ipatests/test_webui/ui_driver.py @@ -702,6 +702,21 @@ def profile_menu_action(self, name): # possible dialog transition effect self.wait(0.5) + def close_notifications(self): + """ + Close all notifications like success messages, warnings, infos + """ + self.wait() + while True: + # get close button of notification + s = ".notification-area .alert button" + button = self.find(s, By.CSS_SELECTOR, strict=False) + if button: + button.click() + self.wait() + else: + break + def get_form(self): """ Get last dialog or visible facet
_______________________________________________ FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org