URL: https://github.com/freeipa/freeipa/pull/6133
Author: miskopo
 Title: #6133: Test web subid
Action: opened

PR body:
"""
This is proof of concept PR, not to be merged!
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/6133/head:pr6133
git checkout pr6133
From f60b59f890f92d85c97b14ef22a73fe8d1cadbae Mon Sep 17 00:00:00 2001
From: Anuja More <am...@redhat.com>
Date: Mon, 6 Dec 2021 20:50:01 +0530
Subject: [PATCH 1/2] Web-UI tests for subid.

Signed-off-by: Anuja More <am...@redhat.com>
---
 ipatests/test_webui/test_subid.py | 141 ++++++++++++++++++++++++++++++
 ipatests/test_webui/ui_driver.py  |  28 ++++++
 2 files changed, 169 insertions(+)
 create mode 100644 ipatests/test_webui/test_subid.py

diff --git a/ipatests/test_webui/test_subid.py b/ipatests/test_webui/test_subid.py
new file mode 100644
index 00000000000..d11439b5ab1
--- /dev/null
+++ b/ipatests/test_webui/test_subid.py
@@ -0,0 +1,141 @@
+
+"""
+Sub UID-GID tests
+"""
+
+from ipatests.test_webui.ui_driver import UI_driver
+import ipatests.test_webui.data_config as config_data
+import ipatests.test_webui.data_user as user_data
+from ipatests.test_webui.ui_driver import screenshot
+import re
+
+
+class test_subid(UI_driver):
+
+    def add_user(self, pkey, name, surname):
+        self.add_record('user', {
+            'pkey': pkey,
+            'add': [
+                ('textbox', 'uid', pkey),
+                ('textbox', 'givenname', name),
+                ('textbox', 'sn', surname),
+            ]
+        })
+
+    def set_default_subid(self):
+        self.navigate_to_entity(config_data.ENTITY)
+        self.check_option('ipauserdefaultsubordinateid', 'checked')
+        self.facet_button_click('save')
+
+    def get_user_count(self, user_pkey):
+        self.navigate_to_entity('subid', facet='search')
+        self.apply_search_filter(user_pkey)
+        self.wait_for_request()
+        return self.get_rows()
+
+    @screenshot
+    def test_set_defaultsubid(self):
+        """
+        Test to verify that enable/disable is working for
+        adding subids to new users.
+        """
+        self.init_app()
+        self.add_record(user_data.ENTITY, user_data.DATA2)
+        self.navigate_to_entity(config_data.ENTITY)
+        # test subid can be enabled/disabled.
+        self.set_default_subid()
+        assert self.get_field_checked('ipauserdefaultsubordinateid')
+        self.set_default_subid()
+        assert not self.get_field_checked('ipauserdefaultsubordinateid')
+
+    @screenshot
+    def test_user_defaultsubid(self):
+        """
+        Test to verify that subid is generated for new user.
+        """
+        self.init_app()
+        user_pkey = "some-user"
+
+        self.set_default_subid()
+        assert self.get_field_checked('ipauserdefaultsubordinateid')
+
+        before_count = self.get_user_count(user_pkey)
+        assert len(before_count) == 0
+
+        self.add_user(user_pkey, 'Some', 'User')
+        after_count = self.get_user_count(user_pkey)
+        assert len(after_count) == 1
+
+    @screenshot
+    def test_user_subid_mod_desc(self):
+        """
+        Test to verify that auto-assigned subid description is modified.
+        """
+        self.init_app()
+        self.navigate_to_record("some-user")
+        self.switch_to_facet('memberof_subid')
+        rows = self.get_rows()
+        self.navigate_to_row_record(rows[-1])
+        self.fill_textbox("description", "some-user-subid-desc")
+        self.facet_button_click('save')
+
+    @screenshot
+    def test_admin_subid(self):
+        """
+        Test to verify that subid range with is created with owner admin.
+        """
+        self.init_app()
+        self.navigate_to_entity('subid', facet='search')
+        self.facet_button_click('add')
+        self.select_combobox('ipaowner', 'admin')
+        self.dialog_button_click('add')
+        self.wait(0.3)
+        self.assert_no_error_dialog()
+
+    @screenshot
+    def test_admin_subid_negative(self):
+        """
+        Test to verify that readding the subid fails with error.
+        """
+        self.init_app()
+        self.navigate_to_entity('subid', facet='search')
+        self.facet_button_click('add')
+        self.select_combobox('ipaowner', 'admin')
+        self.dialog_button_click('add')
+        self.wait(0.3)
+        err_dialog = self.get_last_error_dialog(dialog_name='error_dialog')
+        text = self.get_text('.modal-body div p', err_dialog)
+        text = text.strip()
+        pattern = r'Subordinate id with with name .* already exists.'
+        assert re.search(pattern, text)
+        self.close_all_dialogs()
+
+    @screenshot
+    def test_user_subid_add(self):
+        """
+        Test to verify that subid range is created for given user.
+        """
+        self.init_app()
+        self.navigate_to_entity('subid', facet='search')
+        before_count = self.get_rows()
+        self.facet_button_click('add')
+        self.select_combobox('ipaowner', user_data.PKEY2)
+        self.dialog_button_click('add')
+        self.wait(0.3)
+        self.assert_no_error_dialog()
+        after_count = self.get_rows()
+        assert len(before_count) < len(after_count)
+
+    @screenshot
+    def test_subid_del(self):
+        """
+        Test to remove subordinate id for given user.
+        """
+        self.init_app()
+        self.navigate_to_entity('subid', facet='search')
+        user_uid = self.get_record_pkey("some-user", "ipaowner",
+                                        table_name="ipauniqueid")
+        before_count = self.get_rows()
+        self.delete_record(user_uid, table_name="ipauniqueid")
+        after_count = self.get_rows()
+        assert len(before_count) > len(after_count)
diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
index 20361e4ddda..5870b67489f 100644
--- a/ipatests/test_webui/ui_driver.py
+++ b/ipatests/test_webui/ui_driver.py
@@ -1150,6 +1150,19 @@ def get_row(self, pkey, parent=None, name=None):
                 return row
         return None
 
+    def get_row_by_column_value(self, key, column_name, parent=None, name=None):
+        """
+        Get the first matched row element of a search table with given key
+        matched against selected column. None if not found
+        """
+        rows = self.get_rows(parent, name)
+        s = "td div[name='%s'][value='%s']" % column_name, key
+        for row in rows:
+            has = self.find(s, By.CSS_SELECTOR, row)
+            if has:
+                return row
+        return None
+
     def navigate_to_row_record(self, row, pkey_column=None):
         """
         Navigate to record by clicking on a link.
@@ -1238,6 +1251,20 @@ def get_record_value(self, pkey, column, parent=None, table_name=None):
             val = el.text
         return val
 
+    def get_record_pkey(self, key, column, parent=None, table_name=None):
+        """
+        Get record pkey if value of column is known
+        """
+        row = self.get_row_by_column_value(key,
+                                           column_name=column,
+                                           parent=parent,
+                                           name=table_name)
+        val = None
+        if row:
+            el = self.find("input", By.CSS_SELECTOR, row)
+            val = el.get_attribute("value")
+        return val
+
     @repeat_on_stale_parent_reference
     def has_record(self, pkey, parent=None, table_name=None):
         """
@@ -1437,6 +1464,7 @@ def find_record(self, entity, data, facet='search', dummy='XXXXXXX'):
         self.action_button_click('find', facet)
         self.wait_for_request(n=2)
 
+
     def add_record(self, entity, data, facet='search', facet_btn='add',
                    dialog_btn='add', add_another_btn='add_and_add_another',
                    delete=False, pre_delete=True, dialog_name='add',

From a335ce956caf876c2182963b8d3fca950324ce39 Mon Sep 17 00:00:00 2001
From: Michal Polovka <mpolo...@redhat.com>
Date: Fri, 7 Jan 2022 16:49:09 +0100
Subject: [PATCH 2/2] temp commit

Signed-off-by: Michal Polovka <mpolo...@redhat.com>
---
 .freeipa-pr-ci.yaml                        | 2 +-
 ipatests/prci_definitions/temp_commit.yaml | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/.freeipa-pr-ci.yaml b/.freeipa-pr-ci.yaml
index abcf8c5b634..80656690080 120000
--- a/.freeipa-pr-ci.yaml
+++ b/.freeipa-pr-ci.yaml
@@ -1 +1 @@
-ipatests/prci_definitions/gating.yaml
\ No newline at end of file
+ipatests/prci_definitions/temp_commit.yaml
\ No newline at end of file
diff --git a/ipatests/prci_definitions/temp_commit.yaml b/ipatests/prci_definitions/temp_commit.yaml
index 31935bf044a..12229fd2ec0 100644
--- a/ipatests/prci_definitions/temp_commit.yaml
+++ b/ipatests/prci_definitions/temp_commit.yaml
@@ -65,10 +65,10 @@ jobs:
     requires: [fedora-latest/build]
     priority: 50
     job:
-      class: RunPytest
+      class: RunWebuiTests
       args:
         build_url: '{fedora-latest/build_url}'
-        test_suite: test_integration/test_REPLACEME.py
+        test_suite: test_webui/test_subid.py
         template: *ci-master-latest
         timeout: 3600
-        topology: *master_1repl_1client
+        topology: *ipaserver
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/freeipa-devel@lists.fedorahosted.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to