URL: https://github.com/freeipa/freeipa/pull/1479
Author: felipevolpone
 Title: #1479: Fixing WebUI Tests
Action: opened

PR body:
"""

"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/1479/head:pr1479
git checkout pr1479
From 866a5551a22aa91a33fb6c87938b2842d3105fbb Mon Sep 17 00:00:00 2001
From: Felipe Barreto <fbarr...@redhat.com>
Date: Tue, 16 Jan 2018 18:36:50 -0200
Subject: [PATCH 1/7] WebUI Tests: fixing logout problem in test_user.py

Now, when calling login, if the user is already logged in, it will
---
 ipatests/test_webui/ui_driver.py | 52 +++++++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
index d027f1cd44..67a9ce877b 100644
--- a/ipatests/test_webui/ui_driver.py
+++ b/ipatests/test_webui/ui_driver.py
@@ -363,34 +363,35 @@ def login(self, login=None, password=None, new_password=None):
         Log in if user is not logged in.
         """
         self.wait_for_request(n=2)
-        if not self.logged_in():
-
-            if not login:
-                login = self.config['ipa_admin']
-            if not password:
-                password = self.config['ipa_password']
-            if not new_password:
-                new_password = password
-
-            auth = self.get_login_screen()
-            login_tb = self.find("//input[@type='text'][@name='username']", 'xpath', auth, strict=True)
-            psw_tb = self.find("//input[@type='password'][@name='password']", 'xpath', auth, strict=True)
-            login_tb.send_keys(login)
-            psw_tb.send_keys(password)
-            psw_tb.send_keys(Keys.RETURN)
+        if self.logged_in():
+            self.logout()
+
+        if not login:
+            login = self.config['ipa_admin']
+        if not password:
+            password = self.config['ipa_password']
+        if not new_password:
+            new_password = password
+
+        auth = self.get_login_screen()
+        login_tb = self.find("//input[@type='text'][@name='username']", 'xpath', auth, strict=True)
+        psw_tb = self.find("//input[@type='password'][@name='password']", 'xpath', auth, strict=True)
+        login_tb.send_keys(login)
+        psw_tb.send_keys(password)
+        psw_tb.send_keys(Keys.RETURN)
+        self.wait(0.5)
+        self.wait_for_request(n=2)
+
+        # reset password if needed
+        newpw_tb = self.find("//input[@type='password'][@name='new_password']", 'xpath', auth)
+        verify_tb = self.find("//input[@type='password'][@name='verify_password']", 'xpath', auth)
+        if newpw_tb and newpw_tb.is_displayed():
+            newpw_tb.send_keys(new_password)
+            verify_tb.send_keys(new_password)
+            verify_tb.send_keys(Keys.RETURN)
             self.wait(0.5)
             self.wait_for_request(n=2)
 
-            # reset password if needed
-            newpw_tb = self.find("//input[@type='password'][@name='new_password']", 'xpath', auth)
-            verify_tb = self.find("//input[@type='password'][@name='verify_password']", 'xpath', auth)
-            if newpw_tb and newpw_tb.is_displayed():
-                newpw_tb.send_keys(new_password)
-                verify_tb.send_keys(new_password)
-                verify_tb.send_keys(Keys.RETURN)
-                self.wait(0.5)
-                self.wait_for_request(n=2)
-
     def logged_in(self):
         """
         Check if user is logged in
@@ -835,6 +836,7 @@ def select_combobox(self, name, value, parent=None, combobox_input=None):
         if combobox_input:
             if not option:
                 self.fill_textbox(combobox_input, value, cb)
+                self.wait(5)
         else:
             if not option:
                 # try to search

From a56ee82872f20105a0f2854ef87a108ec23fabdd Mon Sep 17 00:00:00 2001
From: Felipe Barreto <fbarr...@redhat.com>
Date: Tue, 16 Jan 2018 18:37:51 -0200
Subject: [PATCH 2/7] WebUI Tests: removing workaroud to scroll to the element

Acording to geckodriver, the workaround is not necessary anymore.
---
 ipatests/test_webui/ui_driver.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
index 67a9ce877b..c749f62f16 100644
--- a/ipatests/test_webui/ui_driver.py
+++ b/ipatests/test_webui/ui_driver.py
@@ -664,7 +664,6 @@ def button_click(self, name, parent=None,
 
     def _button_click(self, selector, parent, name=''):
         btn = self.find(selector, By.CSS_SELECTOR, parent, strict=True)
-        ActionChains(self.driver).move_to_element(btn).perform()
         disabled = btn.get_attribute("disabled")
         assert btn.is_displayed(), 'Button is not displayed: %s' % name
         assert not disabled, 'Invalid button state: disabled. Button: %s' % name

From d1d532c0f425b9f84195f3a82fa2cdc7a9eca8fa Mon Sep 17 00:00:00 2001
From: Felipe Barreto <fbarr...@redhat.com>
Date: Tue, 16 Jan 2018 18:38:57 -0200
Subject: [PATCH 3/7] WebUI Tests: fixing test_hbac

Adding more wait_for_request between navigation.
---
 ipatests/test_webui/test_hbac.py | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/ipatests/test_webui/test_hbac.py b/ipatests/test_webui/test_hbac.py
index d8e9f9ecfd..f44c1f1b87 100644
--- a/ipatests/test_webui/test_hbac.py
+++ b/ipatests/test_webui/test_hbac.py
@@ -138,29 +138,30 @@ def test_hbac_test(self):
         self.wait_for_request(n=2)
         self.assert_facet('hbactest', 'run_test')
         self.button_click('run_test')
-        self.wait_for_request(n=2)
         self.assert_text("div.hbac-test-result-panel p", 'Access Granted'.upper())
         self.button_click('prev')
         self.assert_facet('hbactest', 'rules')
         self.switch_to_facet('run_test')
+        self.wait_for_request(n=2)
         self.button_click('new_test')
         self.assert_facet('hbactest', 'user')
 
         # test pre-run validation and navigation to related facet
-        self.switch_to_facet('run_test')
-        self.button_click('run_test')
-        self.assert_dialog('message_dialog')
+        def __hbac_run_test(self):
+            self.wait_for_request(n=2)
+            self.switch_to_facet('run_test')
+            self.wait_for_request(n=2)
+            self.button_click('run_test')
+            self.assert_dialog('message_dialog')
+
+        __hbac_run_test(self)
         self.click_on_link('User name')
         self.assert_facet('hbactest', 'user')
 
-        self.switch_to_facet('run_test')
-        self.button_click('run_test')
-        self.assert_dialog('message_dialog')
+        __hbac_run_test(self)
         self.click_on_link('Target host')
         self.assert_facet('hbactest', 'targethost')
 
-        self.switch_to_facet('run_test')
-        self.button_click('run_test')
-        self.assert_dialog('message_dialog')
+        __hbac_run_test(self)
         self.click_on_link('Service')
         self.assert_facet('hbactest', 'service')

From 4687e9df1cbccb65a2b65f60964770d46b38a0f6 Mon Sep 17 00:00:00 2001
From: Felipe Barreto <fbarr...@redhat.com>
Date: Tue, 16 Jan 2018 18:39:20 -0200
Subject: [PATCH 4/7] WebUI Tests: fixing test_group

Removing old data that is not needed anymore.
---
 ipatests/test_webui/test_group.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/ipatests/test_webui/test_group.py b/ipatests/test_webui/test_group.py
index 91ae2d23ef..0c33ee234a 100644
--- a/ipatests/test_webui/test_group.py
+++ b/ipatests/test_webui/test_group.py
@@ -58,10 +58,8 @@ def test_group_types(self):
                 ('callback', self.check_posix_enabled, True),
                 ('textbox', 'cn', pkey),
                 ('textarea', 'description', 'test-group desc'),
-                ('radio', 'type', 'normal'),
+                ('radio', 'type', 'nonposix'),
                 ('callback', self.check_posix_enabled, False),
-                ('radio', 'type', 'posix'),
-                ('callback', self.check_posix_enabled, True),
                 ('radio', 'type', 'external'),
                 ('callback', self.check_posix_enabled, False),
                 ('radio', 'type', 'posix'),

From 4884033d196da6a6222f739f3f268737ba3618c3 Mon Sep 17 00:00:00 2001
From: Felipe Barreto <fbarr...@redhat.com>
Date: Tue, 16 Jan 2018 18:39:48 -0200
Subject: [PATCH 5/7] WebUI Tests: fixing test_navigation

Removing old menu options and including idview
---
 ipatests/test_webui/test_navigation.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/ipatests/test_webui/test_navigation.py b/ipatests/test_webui/test_navigation.py
index b51d71d03c..53bc7b512c 100644
--- a/ipatests/test_webui/test_navigation.py
+++ b/ipatests/test_webui/test_navigation.py
@@ -106,12 +106,11 @@ def test_menu_navigation(self):
 
         # Identity
         # don't start by users (default)
-        self.navigate_by_menu('identity/group', False)
+        self.navigate_by_menu('identity/group_search', False)
         self.navigate_by_menu('identity/user_search', False)
         self.navigate_by_menu('identity/host', False)
-        self.navigate_by_menu('identity/hostgroup', False)
-        self.navigate_by_menu('identity/netgroup', False)
         self.navigate_by_menu('identity/service', False)
+        self.navigate_by_menu('identity/idview', False)
         self.navigate_by_menu('identity/automember', False)
         self.navigate_by_menu('identity/automember/amhostgroup')
         self.navigate_by_menu('identity/automember/amgroup')

From d97ec438fb52b3ae5275b3669ab64922c9190154 Mon Sep 17 00:00:00 2001
From: Felipe Barreto <fbarr...@redhat.com>
Date: Wed, 17 Jan 2018 15:38:20 -0200
Subject: [PATCH 6/7] WebUI Tests: fixing test_range test case

Should not be expected that is possible to change the range of
a local IPA domain.
---
 ipatests/test_webui/test_range.py | 35 ++++++++++++++++++++++++++++++++++-
 ipatests/test_webui/ui_driver.py  |  3 ++-
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/ipatests/test_webui/test_range.py b/ipatests/test_webui/test_range.py
index bc07325106..19af4755da 100644
--- a/ipatests/test_webui/test_range.py
+++ b/ipatests/test_webui/test_range.py
@@ -40,7 +40,40 @@ def test_crud(self):
         """
         self.init_app()
         self.get_shifts()
-        self.basic_crud(ENTITY, self.get_data(PKEY))
+        self.basic_crud(ENTITY, self.get_data(PKEY), mod=False)
+
+    @screenshot
+    def test_mod(self):
+        """
+        Test mod operating in a new range
+        """
+
+        self.init_app()
+        self.navigate_to_entity(ENTITY)
+        self.get_shifts()
+
+        # creating record
+        add = self.get_add_data(PKEY)
+        data = self.get_data(PKEY, add_data=add)
+
+        self.add_record(ENTITY, data, facet='search', navigate=False,
+                        facet_btn='add', dialog_name='add',
+                        dialog_btn='add')
+        self.navigate_to_record(PKEY)
+
+        # changing idrange and trying to save it
+        self.fill_fields(data['mod'], undo=True)
+        self.assert_facet_button_enabled('save')
+        self.facet_button_click('save')
+        self.wait_for_request(n=2)
+
+        dialog = self.get_last_error_dialog()
+        assert ("can not be used to change ID allocation for local IPA domain"
+                in dialog.text)
+        self.dialog_button_click('cancel')
+        self.navigate_to_entity(ENTITY)
+        self.wait_for_request()
+        self.delete_record(PKEY)
 
     @screenshot
     def test_types(self):
diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
index c749f62f16..88c4edc0a0 100644
--- a/ipatests/test_webui/ui_driver.py
+++ b/ipatests/test_webui/ui_driver.py
@@ -1289,6 +1289,7 @@ def basic_crud(self, entity, data,
                    update_btn='save',
                    breadcrumb=None,
                    navigate=True,
+                   mod=True,
                    delete=True):
         """
         Basic CRUD operation sequence.
@@ -1339,7 +1340,7 @@ def basic_crud(self, entity, data,
         self.validate_fields(data.get('add_v'))
 
         # 4. Mod values
-        if data.get('mod'):
+        if mod and data.get('mod'):
             self.mod_record(entity, data, details_facet, update_btn)
             self.validate_fields(data.get('mod_v'))
 

From fbd20d009043f43d462ac509932f8e6fbb500f81 Mon Sep 17 00:00:00 2001
From: Felipe Barreto <fbarr...@redhat.com>
Date: Wed, 17 Jan 2018 18:46:02 -0200
Subject: [PATCH 7/7] adding webui tests to PR CI

---
 .freeipa-pr-ci.yaml | 38 +++++++++-----------------------------
 1 file changed, 9 insertions(+), 29 deletions(-)

diff --git a/.freeipa-pr-ci.yaml b/.freeipa-pr-ci.yaml
index ab983feeb2..666c80ad6d 100644
--- a/.freeipa-pr-ci.yaml
+++ b/.freeipa-pr-ci.yaml
@@ -11,6 +11,10 @@ topologies:
     name: master_1repl_1client
     cpu: 4
     memory: 6700
+  ipaserver: &ipaserver
+    name: ipaserver
+    cpu: 1
+    memory: 2400
 
 jobs:
   fedora-27/build:
@@ -27,38 +31,14 @@ jobs:
         timeout: 1800
         topology: *build
 
-  fedora-27/simple_replication:
+  fedora-27/webui_tests:
     requires: [fedora-27/build]
     priority: 50
     job:
-      class: RunPytest
+      class: RunWebuiTests
       args:
         build_url: '{fedora-27/build_url}'
-        test_suite: test_integration/test_simple_replication.py
+        test_suite: test_webui/test_user.py::test_user::test_crud
         template: *ci-master-f27
-        timeout: 3600
-        topology: *master_1repl
-
-  fedora-27/caless:
-    requires: [fedora-27/build]
-    priority: 50
-    job:
-      class: RunPytest
-      args:
-        build_url: '{fedora-27/build_url}'
-        test_suite: test_integration/test_caless.py::TestServerReplicaCALessToCAFull
-        template: *ci-master-f27
-        timeout: 3600
-        topology: *master_1repl
-
-  fedora-27/external_ca:
-    requires: [fedora-27/build]
-    priority: 50
-    job:
-      class: RunPytest
-      args:
-        build_url: '{fedora-27/build_url}'
-        test_suite: test_integration/test_external_ca.py::TestExternalCA
-        template: *ci-master-f27
-        timeout: 3600
-        topology: *master_1repl
+        timeout: 1200
+        topology: *ipaserver
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to