URL: https://github.com/freeipa/freeipa/pull/1839
Author: varunmylaraiah
 Title: #1839: WebUI tests: Extend netgroup tests with more scenarios
Action: opened

PR body:
"""
    Extended webui group automation test with below scenarios
    Scenarios
     *add netgroup with invalid names
     *add and delete records in various scenarios
     *verify button's action in various scenarios.
    
    https://pagure.io/freeipa/issue/7505
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/1839/head:pr1839
git checkout pr1839
From 488bb5c23f2e05a3f7a45a02165b357e168df887 Mon Sep 17 00:00:00 2001
From: Varun Mylaraiah <mva...@redhat.com>
Date: Thu, 5 Apr 2018 13:36:26 +0530
Subject: [PATCH 1/2] Temporary modifications

Signed-off-by: Varun Mylaraiah <mva...@redhat.com>
---
 .freeipa-pr-ci.yaml | 158 +++-------------------------------------------------
 1 file changed, 9 insertions(+), 149 deletions(-)

diff --git a/.freeipa-pr-ci.yaml b/.freeipa-pr-ci.yaml
index c95bef79e2..7de92aab11 100644
--- a/.freeipa-pr-ci.yaml
+++ b/.freeipa-pr-ci.yaml
@@ -3,6 +3,10 @@ topologies:
     name: build
     cpu: 2
     memory: 3800
+  ipaserver: &ipaserver
+    name: ipaserver
+    cpu: 1
+    memory: 2400
   master_1repl: &master_1repl
     name: master_1repl
     cpu: 4
@@ -27,158 +31,14 @@ jobs:
         timeout: 1800
         topology: *build
 
-  fedora-27/simple_replication:
+  fedora-27/test_webui:
     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
         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
-        template: *ci-master-f27
-        timeout: 3600
-        topology: *master_1repl
-
-  fedora-27/test_topologies:
-    requires: [fedora-27/build]
-    priority: 50
-    job:
-      class: RunPytest
-      args:
-        build_url: '{fedora-27/build_url}'
-        test_suite: test_integration/test_topologies.py
-        template: *ci-master-f27
-        timeout: 3600
-        topology: *master_1repl
-
-  fedora-27/test_sudo:
-    requires: [fedora-27/build]
-    priority: 50
-    job:
-      class: RunPytest
-      args:
-        build_url: '{fedora-27/build_url}'
-        test_suite: test_integration/test_sudo.py
-        template: *ci-master-f27
-        timeout: 3600
-        topology: *master_1repl_1client
-
-  fedora-27/test_kerberos_flags:
-    requires: [fedora-27/build]
-    priority: 50
-    job:
-      class: RunPytest
-      args:
-        build_url: '{fedora-27/build_url}'
-        test_suite: test_integration/test_kerberos_flags.py
-        template: *ci-master-f27
-        timeout: 3600
-        topology: *master_1repl_1client
-
-  fedora-27/test_http_kdc_proxy:
-    requires: [fedora-27/build]
-    priority: 50
-    job:
-      class: RunPytest
-      args:
-        build_url: '{fedora-27/build_url}'
-        test_suite: test_integration/test_http_kdc_proxy.py
-        template: *ci-master-f27
-        timeout: 3600
-        topology: *master_1repl_1client
-
-  fedora-27/test_forced_client_enrolment:
-    requires: [fedora-27/build]
-    priority: 50
-    job:
-      class: RunPytest
-      args:
-        build_url: '{fedora-27/build_url}'
-        test_suite: test_integration/test_forced_client_reenrollment.py
-        template: *ci-master-f27
-        timeout: 3600
-        topology: *master_1repl_1client
-
-  fedora-27/test_advise:
-    requires: [fedora-27/build]
-    priority: 50
-    job:
-      class: RunPytest
-      args:
-        build_url: '{fedora-27/build_url}'
-        test_suite: test_integration/test_advise.py
-        template: *ci-master-f27
-        timeout: 3600
-        topology: *master_1repl
-
-  fedora-27/test_testconfig:
-    requires: [fedora-27/build]
-    priority: 50
-    job:
-      class: RunPytest
-      args:
-        build_url: '{fedora-27/build_url}'
-        test_suite: test_integration/test_testconfig.py
-        template: *ci-master-f27
-        timeout: 3600
-        topology: *master_1repl
-
-  fedora-27/test_service_permissions:
-    requires: [fedora-27/build]
-    priority: 50
-    job:
-      class: RunPytest
-      args:
-        build_url: '{fedora-27/build_url}'
-        test_suite: test_integration/test_service_permissions.py
-        template: *ci-master-f27
-        timeout: 3600
-        topology: *master_1repl
-
-  fedora-27/test_netgroup:
-    requires: [fedora-27/build]
-    priority: 50
-    job:
-      class: RunPytest
-      args:
-        build_url: '{fedora-27/build_url}'
-        test_suite: test_integration/test_netgroup.py
-        template: *ci-master-f27
-        timeout: 3600
-        topology: *master_1repl
-
-  fedora-27/test_vault:
-    requires: [fedora-27/build]
-    priority: 50
-    job:
-      class: RunPytest
-      args:
-        build_url: '{fedora-27/build_url}'
-        test_suite: test_integration/test_vault.py
-        template: *ci-master-f27
-        timeout: 3600
-        topology: *master_1repl
+        timeout: 7200
+        topology: *ipaserver

From 966656317d76cb7198ef1498ab62db55b4663e89 Mon Sep 17 00:00:00 2001
From: Varun Mylaraiah <mva...@redhat.com>
Date: Wed, 18 Apr 2018 17:29:17 +0530
Subject: [PATCH 2/2] WebUI tests: Extend netgroup tests with more scenarios

Extended webui group automation test with below scenarios
Scenarios
 *add netgroup with invalid names
 *add and delete records in various scenarios
 *verify button's action in various scenarios.

https://pagure.io/freeipa/issue/7505

Signed-off-by: Varun Mylaraiah <mva...@redhat.com>
---
 ipatests/test_webui/data_netgroup.py |  59 +++++++++++++
 ipatests/test_webui/test_netgroup.py | 167 +++++++++++++++++++++++++++++++++++
 2 files changed, 226 insertions(+)

diff --git a/ipatests/test_webui/data_netgroup.py b/ipatests/test_webui/data_netgroup.py
index 8484ba9e14..978140ae05 100644
--- a/ipatests/test_webui/data_netgroup.py
+++ b/ipatests/test_webui/data_netgroup.py
@@ -41,3 +41,62 @@
         ('textarea', 'description', 'test-netgroup2 desc modified'),
     ],
 }
+
+PKEY3 = 'itest-netgroup3'
+DATA3 = {
+    'pkey': PKEY3,
+    'add': [
+        ('textbox', 'cn', PKEY3),
+        ('textarea', 'description', 'test-netgroup3 desc'),
+    ]
+}
+
+PKEY4 = 'itest-netgroup4'
+DATA4 = {
+    'pkey': PKEY4,
+    'add': [
+        ('textbox', 'cn', PKEY4),
+        ('textarea', 'description', 'test-netgroup4 desc'),
+    ]
+}
+
+PKEY5 = 'NewNetGroup'
+DATA5 = {
+    'pkey': PKEY5,
+    'add': [
+        ('textbox', 'cn', PKEY5),
+        ('textarea', 'description', 'Trying to add mixed case netgroup name'),
+    ]
+}
+
+
+PKEY6 = 'long-netgroup-name_longlonglonglonglonglonglonglonglonglonglonglong'
+DATA6 = {
+    'pkey': PKEY6,
+    'add': [
+        ('textbox', 'cn', PKEY6),
+        ('textarea', 'description', 'Trying to add long netgroup name'),
+    ]
+}
+
+PKEY7 = 'a'
+DATA7 = {
+    'pkey': PKEY7,
+    'add': [
+        ('textbox', 'cn', PKEY7),
+        ('textarea', 'description', 'Trying to add single character netgroup'
+                                    ' name'),
+    ]
+}
+
+PKEY8 = 'itest-netgroup8'
+DATA8 = {
+    'pkey': PKEY8,
+    'add': [
+        ('textbox', 'cn', PKEY8),
+        ('textarea', 'description', 'test-netgroup8 desc'),
+    ],
+    'mod': [
+        ('textarea', 'description', 'description modified for testing buttons'),
+    ],
+}
\ No newline at end of file
diff --git a/ipatests/test_webui/test_netgroup.py b/ipatests/test_webui/test_netgroup.py
index 05036366ec..aff1930958 100644
--- a/ipatests/test_webui/test_netgroup.py
+++ b/ipatests/test_webui/test_netgroup.py
@@ -29,6 +29,11 @@
 import ipatests.test_webui.data_hostgroup as hostgroup
 from ipatests.test_webui.test_host import host_tasks, ENTITY as HOST_ENTITY
 import pytest
+try:
+    from selenium.webdriver.common.keys import Keys
+    from selenium.webdriver.common.action_chains import ActionChains
+except ImportError:
+    pass
 
 
 @pytest.mark.tier1
@@ -42,6 +47,160 @@ def test_crud(self):
         self.init_app()
         self.basic_crud(netgroup.ENTITY, netgroup.DATA)
 
+    @screenshot
+    def test_add_netgroup(self):
+        """
+        add: netgroup
+        """
+        self.init_app()
+
+        # add mixed case netgroup name
+        self.add_record(netgroup.ENTITY, netgroup.DATA5)
+        pkey = netgroup.DATA5['pkey'].lower()
+        self.delete_record(pkey)
+
+        # add long netgroup name
+        self.add_record(netgroup.ENTITY, netgroup.DATA6, delete=True)
+
+        # add single character netgroup name #bz815481
+        self.add_record(netgroup.ENTITY, netgroup.DATA7, delete=True)
+
+        # add multiple records using add_and_another button
+        self.add_record(netgroup.ENTITY, [netgroup.DATA, netgroup.DATA2,
+                                          netgroup.DATA3, netgroup.DATA4])
+        # search record
+        pkey = netgroup.DATA2['pkey']
+        self.search_pkey(pkey)
+        self.assert_record(pkey)
+
+        # Negative search
+        pkey = netgroup.DATA5['pkey']
+        self.search_pkey(pkey)
+        self.assert_record(pkey, negative=True)
+
+        # delete multiple records
+        records = [netgroup.DATA, netgroup.DATA2, netgroup.DATA3]
+        self.select_multiple_records(netgroup.ENTITY, records)
+        self.facet_button_click('remove')
+        self.dialog_button_click('ok')
+
+        # Find and delete
+        pkey = netgroup.DATA4['pkey']
+        self.search_pkey(pkey)
+        self.select_record(pkey)
+        self.facet_button_click('remove')
+        self.dialog_button_click('ok')
+
+    def search_pkey(self, pkey):
+        search_field_s = '.search-filter input[name=filter]'
+        self.fill_text(search_field_s, pkey)
+        self.action_button_click('find', parent=None)
+        self.wait_for_request(n=2)
+
+    @screenshot
+    def test_add_netgroup_negative(self):
+        """
+        Negative test for adding netgroup
+        """
+        self.init_app()
+
+        # add then cancel
+        self.add_record(netgroup.ENTITY, netgroup.DATA, dialog_btn='cancel')
+
+        # add duplicate
+        self.add_record(netgroup.ENTITY, netgroup.DATA)
+        expected_error = 'group with name "%s" already exists' % netgroup.PKEY
+        self.navigate_to_entity(netgroup.ENTITY)
+        self.facet_button_click('add')
+        self.fill_input('cn', netgroup.PKEY)
+        self.cancel_retry_dialog(expected_error)
+        self.delete_record(netgroup.PKEY)
+
+        # empty netgroup name mixcase
+        self.navigate_to_entity(netgroup.ENTITY)
+        self.facet_button_click('add')
+        self.dialog_button_click('add')
+        elem = self.find(".widget[name='cn']")
+        self.assert_field_validation_required(elem)
+        self.dialog_button_click('cancel')
+
+        # invalid_group_name
+        expected_error = 'may only include letters, numbers, _, -, and .'
+        pkey = ';test-gr@up'
+        self.navigate_to_entity(netgroup.ENTITY)
+        self.facet_button_click('add')
+        self.fill_input('cn', pkey)
+        elem = self.find(".widget[name='cn']")
+        self.assert_field_validation(expected_error, parent=elem)
+        self.dialog_button_click('cancel')
+
+    def cancel_retry_dialog(self, expected_error):
+        self.dialog_button_click('add')
+        dialog = self.get_last_error_dialog()
+        assert (expected_error in dialog.text)
+        self.wait_for_request()
+        # Key press for Retry
+        actions = ActionChains(self.driver)
+        actions.send_keys(Keys.ENTER).perform()
+        self.wait_for_request(n=2)
+        self.dialog_button_click('cancel')
+        self.wait_for_request(n=2)
+        self.dialog_button_click('cancel')
+
+    def test_add_and_edit_group(self):
+        """
+        1. add and switch to edit mode
+        2. verifying Save, Revert, Refresh and Undo button
+        """
+        self.init_app()
+
+        # add and edit record
+        self.add_record(netgroup.ENTITY, netgroup.DATA8,
+                        dialog_btn='add_and_edit')
+        mod_description = "description modified for testing buttons"
+
+        # verifying undo button
+        self.fill_fields(netgroup.DATA8['mod'])
+        self.undo_click()
+        self.verify_btn_action(mod_description)
+        self.wait_for_request(n=2)
+
+        # verifying revert button
+        self.mod_record(netgroup.ENTITY, netgroup.DATA8, facet_btn='revert')
+        self.wait_for_request()
+        self.verify_btn_action(mod_description)
+        self.wait_for_request(n=2)
+
+        # verifying refresh button
+        self.fill_fields(netgroup.DATA8['mod'], undo=True)
+        self.facet_button_click('refresh')
+        self.verify_btn_action(mod_description)
+        self.wait_for_request(n=2)
+
+        # verifying Save button
+        self.mod_record(netgroup.ENTITY, netgroup.DATA8)
+        self.wait_for_request()
+        self.verify_btn_action(mod_description, campare=True)
+        self.wait_for_request(n=2)
+
+        # clean up
+        self.navigate_to_entity(netgroup.ENTITY)
+        self.delete_record(netgroup.PKEY8)
+
+    def undo_click(self):
+        facet = self.get_facet()
+        s = ".textarea-widget button[name='undo']"
+        self._button_click(s, facet)
+
+    def verify_btn_action(self, mod_description, campare=False):
+        current_description = self.get_field_value("description",
+                                                  element="textarea")
+        if campare:
+            assert current_description == mod_description
+        else:
+            assert current_description != mod_description
+
+
     @screenshot
     def test_mod(self):
         """
@@ -78,6 +237,14 @@ def test_mod(self):
 
         self.mod_rule_tables(tables, categories, [])
 
+        # verifying undo on memberships
+        for cat in categories:
+            self.check_option(cat, 'all')
+            self.assert_facet_button_enabled('save', enabled=True)
+            undo = "div[name = %s] > button[name='undo']" % cat
+            self._button_click(undo, parent=None)
+            self.assert_facet_button_enabled('save', enabled=False)
+
         # cleanup
         # -------
         self.delete(netgroup.ENTITY, [netgroup.DATA, netgroup.DATA2])
_______________________________________________
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