Blame SOURCES/0006-Backport-latest-test-fxes-in-python3-ipatests_rhbz#2048509.patch

07426e
From 0edf915efbb39fac45c784171dd715ec6b28861a Mon Sep 17 00:00:00 2001
07426e
From: Sumedh Sidhaye <ssidhaye@redhat.com>
07426e
Date: Fri, 14 Jan 2022 19:55:13 +0530
07426e
Subject: [PATCH] Added test automation for SHA384withRSA CSR support
07426e
07426e
Scenario 1:
07426e
Setup master with --ca-signing-algorithm=SHA384withRSA
07426e
Run certutil and check Signing Algorithm
07426e
07426e
Scenario 2:
07426e
Setup a master
07426e
Stop services
07426e
Modify default.params.signingAlg in CS.cfg
07426e
Restart services
07426e
Resubmit cert (Resubmitted cert should have new Algorithm)
07426e
07426e
Pagure Link: https://pagure.io/freeipa/issue/8906
07426e
07426e
Signed-off-by: Sumedh Sidhaye <ssidhaye@redhat.com>
07426e
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
07426e
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
07426e
Reviewed-By: Antonio Torres <antorres@redhat.com>
07426e
---
07426e
 .../test_integration/test_installation.py     | 63 +++++++++++++++++++
07426e
 1 file changed, 63 insertions(+)
07426e
07426e
diff --git a/ipatests/test_integration/test_installation.py b/ipatests/test_integration/test_installation.py
07426e
index 0947241ae..f2d372c0c 100644
07426e
--- a/ipatests/test_integration/test_installation.py
07426e
+++ b/ipatests/test_integration/test_installation.py
07426e
@@ -34,6 +34,7 @@ from ipatests.pytest_ipa.integration import tasks
07426e
 from ipatests.pytest_ipa.integration.env_config import get_global_config
07426e
 from ipatests.test_integration.base import IntegrationTest
07426e
 from ipatests.test_integration.test_caless import CALessBase, ipa_certs_cleanup
07426e
+from ipatests.test_integration.test_cert import get_certmonger_fs_id
07426e
 from ipaplatform import services
07426e
 
07426e
 
07426e
@@ -1916,3 +1917,65 @@ class TestInstallWithoutNamed(IntegrationTest):
07426e
         tasks.install_replica(
07426e
             self.master, self.replicas[0], setup_ca=False, setup_dns=False
07426e
         )
07426e
+
07426e
+
07426e
+class TestInstallwithSHA384withRSA(IntegrationTest):
07426e
+    num_replicas = 0
07426e
+
07426e
+    def test_install_master_withalgo_sha384withrsa(self, server_cleanup):
07426e
+        tasks.install_master(
07426e
+            self.master,
07426e
+            extra_args=['--ca-signing-algorithm=SHA384withRSA'],
07426e
+        )
07426e
+
07426e
+        # check Signing Algorithm post installation
07426e
+        dashed_domain = self.master.domain.realm.replace(".", '-')
07426e
+        cmd_args = ['certutil', '-L', '-d',
07426e
+                    '/etc/dirsrv/slapd-{}/'.format(dashed_domain),
07426e
+                    '-n', 'Server-Cert']
07426e
+        result = self.master.run_command(cmd_args)
07426e
+        assert 'SHA-384 With RSA Encryption' in result.stdout_text
07426e
+
07426e
+    def test_install_master_modify_existing(self, server_cleanup):
07426e
+        """
07426e
+        Setup a master
07426e
+        Stop services
07426e
+        Modify default.params.signingAlg in CS.cfg
07426e
+        Restart services
07426e
+        Resubmit cert (Resubmitted cert should have new Algorithm)
07426e
+        """
07426e
+        tasks.install_master(self.master)
07426e
+        self.master.run_command(['ipactl', 'stop'])
07426e
+        cs_cfg_content = self.master.get_file_contents(paths.CA_CS_CFG_PATH,
07426e
+                                                       encoding='utf-8')
07426e
+        new_lines = []
07426e
+        replace_str = "ca.signing.defaultSigningAlgorithm=SHA384withRSA"
07426e
+        ocsp_rep_str = "ca.ocsp_signing.defaultSigningAlgorithm=SHA384withRSA"
07426e
+        for line in cs_cfg_content.split('\n'):
07426e
+            if line.startswith('ca.signing.defaultSigningAlgorithm'):
07426e
+                new_lines.append(replace_str)
07426e
+            elif line.startswith('ca.ocsp_signing.defaultSigningAlgorithm'):
07426e
+                new_lines.append(ocsp_rep_str)
07426e
+            else:
07426e
+                new_lines.append(line)
07426e
+        self.master.put_file_contents(paths.CA_CS_CFG_PATH,
07426e
+                                      '\n'.join(new_lines))
07426e
+        self.master.run_command(['ipactl', 'start'])
07426e
+
07426e
+        cmd = ['getcert', 'list', '-f', paths.RA_AGENT_PEM]
07426e
+        result = self.master.run_command(cmd)
07426e
+        request_id = get_certmonger_fs_id(result.stdout_text)
07426e
+
07426e
+        # resubmit RA Agent cert
07426e
+        cmd = ['getcert', 'resubmit', '-f', paths.RA_AGENT_PEM]
07426e
+        self.master.run_command(cmd)
07426e
+
07426e
+        tasks.wait_for_certmonger_status(self.master,
07426e
+                                         ('CA_WORKING', 'MONITORING'),
07426e
+                                         request_id)
07426e
+
07426e
+        cmd_args = ['openssl', 'x509', '-in',
07426e
+                    paths.RA_AGENT_PEM, '-noout', '-text']
07426e
+        result = self.master.run_command(cmd_args)
07426e
+        assert_str = 'Signature Algorithm: sha384WithRSAEncryption'
07426e
+        assert assert_str in result.stdout_text
07426e
-- 
07426e
2.34.1
07426e
07426e
From 8b22ee018c3bb7f58a1b6694a7fd611688f8e74f Mon Sep 17 00:00:00 2001
07426e
From: Sumedh Sidhaye <ssidhaye@redhat.com>
07426e
Date: Thu, 25 Nov 2021 17:48:20 +0530
07426e
Subject: [PATCH] Extend test to see if replica is not shown when running
07426e
 `ipa-replica-manage list -v <FQDN>`
07426e
07426e
Related: https://pagure.io/freeipa/issue/8605
07426e
07426e
Signed-off-by: Sumedh Sidhaye <ssidhaye@redhat.com>
07426e
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
07426e
---
07426e
 ipatests/test_integration/test_simple_replication.py | 3 ++-
07426e
 1 file changed, 2 insertions(+), 1 deletion(-)
07426e
07426e
diff --git a/ipatests/test_integration/test_simple_replication.py b/ipatests/test_integration/test_simple_replication.py
07426e
index 8de385144..17092a499 100644
07426e
--- a/ipatests/test_integration/test_simple_replication.py
07426e
+++ b/ipatests/test_integration/test_simple_replication.py
07426e
@@ -111,5 +111,6 @@ class TestSimpleReplication(IntegrationTest):
07426e
         # has to be run with --force, there is no --unattended
07426e
         self.master.run_command(['ipa-replica-manage', 'del',
07426e
                                  self.replicas[0].hostname, '--force'])
07426e
-        result = self.master.run_command(['ipa-replica-manage', 'list'])
07426e
+        result = self.master.run_command(
07426e
+            ['ipa-replica-manage', 'list', '-v', self.master.hostname])
07426e
         assert self.replicas[0].hostname not in result.stdout_text
07426e
-- 
07426e
2.34.1
07426e
07426e
From ba7ec71ba96280da3841ebe47df2a6dc1cd6341e Mon Sep 17 00:00:00 2001
07426e
From: Mohammad Rizwan <myusuf@redhat.com>
07426e
Date: Fri, 26 Nov 2021 12:11:21 +0530
07426e
Subject: [PATCH] ipatests: Fix test_ipa_cert_fix.py::TestCertFixReplica
07426e
 teardown
07426e
07426e
Fixture `expire_certs` moves date back after renewing the certs.
07426e
This is causing the ipa-replica to fail. This fix first uninstalls
07426e
the server then moves back the date.
07426e
07426e
Fixes: https://pagure.io/freeipa/issue/9052
07426e
07426e
Signed-off-by: Mohammad Rizwan <myusuf@redhat.com>
07426e
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
07426e
---
07426e
 ipatests/test_integration/test_ipa_cert_fix.py | 9 ++++++++-
07426e
 1 file changed, 8 insertions(+), 1 deletion(-)
07426e
07426e
diff --git a/ipatests/test_integration/test_ipa_cert_fix.py b/ipatests/test_integration/test_ipa_cert_fix.py
07426e
index 39904d5de..5b56054b4 100644
07426e
--- a/ipatests/test_integration/test_ipa_cert_fix.py
07426e
+++ b/ipatests/test_integration/test_ipa_cert_fix.py
07426e
@@ -389,6 +389,12 @@ class TestCertFixReplica(IntegrationTest):
07426e
             setup_dns=False, extra_args=['--no-ntp']
07426e
         )
07426e
 
07426e
+    @classmethod
07426e
+    def uninstall(cls, mh):
07426e
+        # Uninstall method is empty as the uninstallation is done in
07426e
+        # the fixture
07426e
+        pass
07426e
+
07426e
     @pytest.fixture
07426e
     def expire_certs(self):
07426e
         # move system date to expire certs
07426e
@@ -398,7 +404,8 @@ class TestCertFixReplica(IntegrationTest):
07426e
         yield
07426e
 
07426e
         # move date back on replica and master
07426e
-        for host in self.master, self.replicas[0]:
07426e
+        for host in self.replicas[0], self.master:
07426e
+            tasks.uninstall_master(host)
07426e
             tasks.move_date(host, 'start', '-3years-1days')
07426e
 
07426e
     def test_renew_expired_cert_replica(self, expire_certs):
07426e
-- 
07426e
2.34.1
07426e
07426e
From 465f1669a6c5abc72da1ecaf9aefa8488f80806c Mon Sep 17 00:00:00 2001
07426e
From: Anuja More <amore@redhat.com>
07426e
Date: Mon, 13 Dec 2021 17:37:05 +0530
07426e
Subject: [PATCH] ipatests: Test default value of nsslapd-sizelimit.
07426e
07426e
related : https://pagure.io/freeipa/issue/8962
07426e
07426e
Signed-off-by: Anuja More <amore@redhat.com>
07426e
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
07426e
---
07426e
 ipatests/test_integration/test_installation.py | 13 +++++++++++++
07426e
 1 file changed, 13 insertions(+)
07426e
07426e
diff --git a/ipatests/test_integration/test_installation.py b/ipatests/test_integration/test_installation.py
07426e
index 95cfaad54..0947241ae 100644
07426e
--- a/ipatests/test_integration/test_installation.py
07426e
+++ b/ipatests/test_integration/test_installation.py
07426e
@@ -1067,6 +1067,19 @@ class TestInstallMaster(IntegrationTest):
07426e
         )
07426e
         assert "nsslapd-db-locks" not in result.stdout_text
07426e
 
07426e
+    def test_nsslapd_sizelimit(self):
07426e
+        """ Test for default value of nsslapd-sizelimit.
07426e
+
07426e
+        Related : https://pagure.io/freeipa/issue/8962
07426e
+        """
07426e
+        result = tasks.ldapsearch_dm(
07426e
+            self.master,
07426e
+            "cn=config",
07426e
+            ["nsslapd-sizelimit"],
07426e
+            scope="base"
07426e
+        )
07426e
+        assert "nsslapd-sizelimit: 100000" in result.stdout_text
07426e
+
07426e
     def test_admin_root_alias_CVE_2020_10747(self):
07426e
         # Test for CVE-2020-10747 fix
07426e
         # https://bugzilla.redhat.com/show_bug.cgi?id=1810160
07426e
-- 
07426e
2.34.1
07426e
07426e
From cbd9ac6ab07dfb60f67da762fdd70856ad35c230 Mon Sep 17 00:00:00 2001
07426e
From: Mohammad Rizwan <myusuf@redhat.com>
07426e
Date: Thu, 25 Nov 2021 13:10:05 +0530
07426e
Subject: [PATCH] ipatests: Test empty cert request doesn't force certmonger to
07426e
 segfault
07426e
07426e
When empty cert request is submitted to certmonger, it goes to
07426e
segfault. This fix test that if something like this happens,
07426e
certmonger should gracefuly handle it
07426e
07426e
and some PEP8 fixes
07426e
07426e
related: https://pagure.io/certmonger/issue/191
07426e
07426e
Signed-off-by: Mohammad Rizwan <myusuf@redhat.com>
07426e
---
07426e
 ipatests/test_integration/test_cert.py | 79 +++++++++++++++++++++++++-
07426e
 1 file changed, 78 insertions(+), 1 deletion(-)
07426e
07426e
diff --git a/ipatests/test_integration/test_cert.py b/ipatests/test_integration/test_cert.py
07426e
index 5ffb8c608..0518d7954 100644
07426e
--- a/ipatests/test_integration/test_cert.py
07426e
+++ b/ipatests/test_integration/test_cert.py
07426e
@@ -14,6 +14,7 @@ import random
07426e
 import re
07426e
 import string
07426e
 import time
07426e
+import textwrap
07426e
 
07426e
 from ipaplatform.paths import paths
07426e
 from ipapython.dn import DN
07426e
@@ -193,7 +194,7 @@ class TestInstallMasterClient(IntegrationTest):
07426e
         tasks.kinit_admin(self.master)
07426e
         tasks.user_add(self.master, user)
07426e
 
07426e
-        for id in (0,1):
07426e
+        for id in (0, 1):
07426e
             csr_file = f'{id}.csr'
07426e
             key_file = f'{id}.key'
07426e
             cert_file = f'{id}.crt'
07426e
@@ -584,3 +585,79 @@ class TestCAShowErrorHandling(IntegrationTest):
07426e
         error_msg = 'ipa: ERROR: The certificate for ' \
07426e
                     '{} is not available on this server.'.format(lwca)
07426e
         assert error_msg in result.stderr_text
07426e
+
07426e
+    def test_certmonger_empty_cert_not_segfault(self):
07426e
+        """Test empty cert request doesn't force certmonger to segfault
07426e
+
07426e
+        Test scenario:
07426e
+        create a cert request file in /var/lib/certmonger/requests which is
07426e
+        missing most of the required information, and ask request a new
07426e
+        certificate to certmonger. The wrong request file should not make
07426e
+        certmonger crash.
07426e
+
07426e
+        related: https://pagure.io/certmonger/issue/191
07426e
+        """
07426e
+        empty_cert_req_content = textwrap.dedent("""
07426e
+        id=dogtag-ipa-renew-agent
07426e
+        key_type=UNSPECIFIED
07426e
+        key_gen_type=UNSPECIFIED
07426e
+        key_size=0
07426e
+        key_gen_size=0
07426e
+        key_next_type=UNSPECIFIED
07426e
+        key_next_gen_type=UNSPECIFIED
07426e
+        key_next_size=0
07426e
+        key_next_gen_size=0
07426e
+        key_preserve=0
07426e
+        key_storage_type=NONE
07426e
+        key_perms=0
07426e
+        key_requested_count=0
07426e
+        key_issued_count=0
07426e
+        cert_storage_type=FILE
07426e
+        cert_perms=0
07426e
+        cert_is_ca=0
07426e
+        cert_ca_path_length=0
07426e
+        cert_no_ocsp_check=0
07426e
+        last_need_notify_check=19700101000000
07426e
+        last_need_enroll_check=19700101000000
07426e
+        template_is_ca=0
07426e
+        template_ca_path_length=-1
07426e
+        template_no_ocsp_check=0
07426e
+        state=NEED_KEY_PAIR
07426e
+        autorenew=0
07426e
+        monitor=0
07426e
+        submitted=19700101000000
07426e
+        """)
07426e
+        # stop certmonger service
07426e
+        self.master.run_command(['systemctl', 'stop', 'certmonger'])
07426e
+
07426e
+        # place an empty cert request file to certmonger request dir
07426e
+        self.master.put_file_contents(
07426e
+            os.path.join(paths.CERTMONGER_REQUESTS_DIR, '20211125062617'),
07426e
+            empty_cert_req_content
07426e
+        )
07426e
+
07426e
+        # start certmonger, it should not fail
07426e
+        self.master.run_command(['systemctl', 'start', 'certmonger'])
07426e
+
07426e
+        # request a new cert, should succeed and certmonger doesn't goes
07426e
+        # to segfault
07426e
+        result = self.master.run_command([
07426e
+            "ipa-getcert", "request",
07426e
+            "-f", os.path.join(paths.OPENSSL_CERTS_DIR, "test.pem"),
07426e
+            "-k", os.path.join(paths.OPENSSL_PRIVATE_DIR, "test.key"),
07426e
+        ])
07426e
+        request_id = re.findall(r'\d+', result.stdout_text)
07426e
+
07426e
+        # check if certificate is in MONITORING state
07426e
+        status = tasks.wait_for_request(self.master, request_id[0], 50)
07426e
+        assert status == "MONITORING"
07426e
+
07426e
+        self.master.run_command(
07426e
+            ['ipa-getcert', 'stop-tracking', '-i', request_id[0]]
07426e
+        )
07426e
+        self.master.run_command([
07426e
+            'rm', '-rf',
07426e
+            os.path.join(paths.CERTMONGER_REQUESTS_DIR, '20211125062617'),
07426e
+            os.path.join(paths.OPENSSL_CERTS_DIR, 'test.pem'),
07426e
+            os.path.join(paths.OPENSSL_PRIVATE_DIR, 'test.key')
07426e
+        ])
07426e
-- 
07426e
2.34.1
07426e
07426e
From edbd8f692a28fc999b92e9032614d366511db323 Mon Sep 17 00:00:00 2001
07426e
From: Anuja More <amore@redhat.com>
07426e
Date: Mon, 6 Dec 2021 20:50:01 +0530
07426e
Subject: [PATCH] ipatests: webui: Tests for subordinate ids.
07426e
07426e
Added web-ui tests to verify where operations
07426e
using subordinate ids are working as expected.
07426e
07426e
Related : https://pagure.io/freeipa/issue/8361
07426e
07426e
Signed-off-by: Anuja More <amore@redhat.com>
07426e
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
07426e
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
07426e
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
07426e
---
07426e
 ipatests/test_webui/test_subid.py | 141 ++++++++++++++++++++++++++++++
07426e
 ipatests/test_webui/ui_driver.py  |  28 ++++++
07426e
 2 files changed, 169 insertions(+)
07426e
 create mode 100644 ipatests/test_webui/test_subid.py
07426e
07426e
diff --git a/ipatests/test_webui/test_subid.py b/ipatests/test_webui/test_subid.py
07426e
new file mode 100644
07426e
index 000000000..26decdba0
07426e
--- /dev/null
07426e
+++ b/ipatests/test_webui/test_subid.py
07426e
@@ -0,0 +1,141 @@
07426e
+
07426e
+"""
07426e
+Tests for subordinateid.
07426e
+"""
07426e
+
07426e
+from ipatests.test_webui.ui_driver import UI_driver
07426e
+import ipatests.test_webui.data_config as config_data
07426e
+import ipatests.test_webui.data_user as user_data
07426e
+from ipatests.test_webui.ui_driver import screenshot
07426e
+import re
07426e
+
07426e
+
07426e
+class test_subid(UI_driver):
07426e
+
07426e
+    def add_user(self, pkey, name, surname):
07426e
+        self.add_record('user', {
07426e
+            'pkey': pkey,
07426e
+            'add': [
07426e
+                ('textbox', 'uid', pkey),
07426e
+                ('textbox', 'givenname', name),
07426e
+                ('textbox', 'sn', surname),
07426e
+            ]
07426e
+        })
07426e
+
07426e
+    def set_default_subid(self):
07426e
+        self.navigate_to_entity(config_data.ENTITY)
07426e
+        self.check_option('ipauserdefaultsubordinateid', 'checked')
07426e
+        self.facet_button_click('save')
07426e
+
07426e
+    def get_user_count(self, user_pkey):
07426e
+        self.navigate_to_entity('subid', facet='search')
07426e
+        self.apply_search_filter(user_pkey)
07426e
+        self.wait_for_request()
07426e
+        return self.get_rows()
07426e
+
07426e
+    @screenshot
07426e
+    def test_set_defaultsubid(self):
07426e
+        """
07426e
+        Test to verify that enable/disable is working for
07426e
+        adding subids to new users.
07426e
+        """
07426e
+        self.init_app()
07426e
+        self.add_record(user_data.ENTITY, user_data.DATA2)
07426e
+        self.navigate_to_entity(config_data.ENTITY)
07426e
+        # test subid can be enabled/disabled.
07426e
+        self.set_default_subid()
07426e
+        assert self.get_field_checked('ipauserdefaultsubordinateid')
07426e
+        self.set_default_subid()
07426e
+        assert not self.get_field_checked('ipauserdefaultsubordinateid')
07426e
+
07426e
+    @screenshot
07426e
+    def test_user_defaultsubid(self):
07426e
+        """
07426e
+        Test to verify that subid is generated for new user.
07426e
+        """
07426e
+        self.init_app()
07426e
+        user_pkey = "some-user"
07426e
+
07426e
+        self.set_default_subid()
07426e
+        assert self.get_field_checked('ipauserdefaultsubordinateid')
07426e
+
07426e
+        before_count = self.get_user_count(user_pkey)
07426e
+        assert len(before_count) == 0
07426e
+
07426e
+        self.add_user(user_pkey, 'Some', 'User')
07426e
+        after_count = self.get_user_count(user_pkey)
07426e
+        assert len(after_count) == 1
07426e
+
07426e
+    @screenshot
07426e
+    def test_user_subid_mod_desc(self):
07426e
+        """
07426e
+        Test to verify that auto-assigned subid description is modified.
07426e
+        """
07426e
+        self.init_app()
07426e
+        self.navigate_to_record("some-user")
07426e
+        self.switch_to_facet('memberof_subid')
07426e
+        rows = self.get_rows()
07426e
+        self.navigate_to_row_record(rows[-1])
07426e
+        self.fill_textbox("description", "some-user-subid-desc")
07426e
+        self.facet_button_click('save')
07426e
+
07426e
+    @screenshot
07426e
+    def test_admin_subid(self):
07426e
+        """
07426e
+        Test to verify that subid range is created with owner admin.
07426e
+        """
07426e
+        self.init_app()
07426e
+        self.navigate_to_entity('subid', facet='search')
07426e
+        self.facet_button_click('add')
07426e
+        self.select_combobox('ipaowner', 'admin')
07426e
+        self.dialog_button_click('add')
07426e
+        self.wait(0.3)
07426e
+        self.assert_no_error_dialog()
07426e
+
07426e
+    @screenshot
07426e
+    def test_admin_subid_negative(self):
07426e
+        """
07426e
+        Test to verify that readding the subid fails with error.
07426e
+        """
07426e
+        self.init_app()
07426e
+        self.navigate_to_entity('subid', facet='search')
07426e
+        self.facet_button_click('add')
07426e
+        self.select_combobox('ipaowner', 'admin')
07426e
+        self.dialog_button_click('add')
07426e
+        self.wait(0.3)
07426e
+        err_dialog = self.get_last_error_dialog(dialog_name='error_dialog')
07426e
+        text = self.get_text('.modal-body div p', err_dialog)
07426e
+        text = text.strip()
07426e
+        pattern = r'Subordinate id with with name .* already exists.'
07426e
+        assert re.search(pattern, text) is not None
07426e
+        self.close_all_dialogs()
07426e
+
07426e
+    @screenshot
07426e
+    def test_user_subid_add(self):
07426e
+        """
07426e
+        Test to verify that subid range is created for given user.
07426e
+        """
07426e
+        self.init_app()
07426e
+        self.navigate_to_entity('subid', facet='search')
07426e
+        before_count = self.get_rows()
07426e
+        self.facet_button_click('add')
07426e
+        self.select_combobox('ipaowner', user_data.PKEY2)
07426e
+        self.dialog_button_click('add')
07426e
+        self.wait(0.3)
07426e
+        self.assert_no_error_dialog()
07426e
+        after_count = self.get_rows()
07426e
+        assert len(before_count) < len(after_count)
07426e
+
07426e
+    @screenshot
07426e
+    def test_subid_del(self):
07426e
+        """
07426e
+        Test to remove subordinate id for given user.
07426e
+        """
07426e
+        self.init_app()
07426e
+        self.navigate_to_entity('subid', facet='search')
07426e
+        user_uid = self.get_record_pkey("some-user", "ipaowner",
07426e
+                                        table_name="ipauniqueid")
07426e
+        before_count = self.get_rows()
07426e
+        self.delete_record(user_uid, table_name="ipauniqueid")
07426e
+        after_count = self.get_rows()
07426e
+        assert len(before_count) > len(after_count)
07426e
diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
07426e
index 46fd512ae..77fd74e49 100644
07426e
--- a/ipatests/test_webui/ui_driver.py
07426e
+++ b/ipatests/test_webui/ui_driver.py
07426e
@@ -1151,6 +1151,34 @@ class UI_driver:
07426e
                 return row
07426e
         return None
07426e
 
07426e
+    def get_row_by_column_value(self, key, column_name, parent=None,
07426e
+                                table_name=None):
07426e
+        """
07426e
+        Get the first matched row element of a search table with given key
07426e
+        matched against selected column. None if not found
07426e
+        """
07426e
+        rows = self.get_rows(parent, table_name)
07426e
+        s = "td div[name='%s']" % column_name
07426e
+        for row in rows:
07426e
+            has = self.find(s, By.CSS_SELECTOR, row)
07426e
+            if has.text == key:
07426e
+                return row
07426e
+        return None
07426e
+
07426e
+    def get_record_pkey(self, key, column, parent=None, table_name=None):
07426e
+        """
07426e
+        Get record pkey if value of column is known
07426e
+        """
07426e
+        row = self.get_row_by_column_value(key,
07426e
+                                           column_name=column,
07426e
+                                           parent=parent,
07426e
+                                           table_name=table_name)
07426e
+        val = None
07426e
+        if row:
07426e
+            el = self.find("td input", By.CSS_SELECTOR, row)
07426e
+            val = el.get_attribute("value")
07426e
+        return val
07426e
+
07426e
     def navigate_to_row_record(self, row, pkey_column=None):
07426e
         """
07426e
         Navigate to record by clicking on a link.
07426e
-- 
07426e
2.34.1
07426e
07426e
From 419d7fd6e5a9ed2d356ad05eef1043309f5646ef Mon Sep 17 00:00:00 2001
07426e
From: Michal Polovka <mpolovka@redhat.com>
07426e
Date: Fri, 7 Jan 2022 12:12:26 +0100
07426e
Subject: [PATCH] ipatests: webui: Use safe-loader for loading YAML
07426e
 configuration file
07426e
07426e
FullLoader class for YAML loader was introduced in version 5.1 which
07426e
also deprecated default loader. SafeLoader, however, stays consistent
07426e
across the versions and brings added security.
07426e
07426e
This fix is necessary as PyYAML > 5.1 is not available in downstream.
07426e
07426e
Related: https://pagure.io/freeipa/issue/9009
07426e
07426e
Signed-off-by: Michal Polovka <mpolovka@redhat.com>
07426e
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
07426e
---
07426e
 ipatests/test_webui/ui_driver.py | 2 +-
07426e
 1 file changed, 1 insertion(+), 1 deletion(-)
07426e
07426e
diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py
07426e
index 77fd74e49..519efee9b 100644
07426e
--- a/ipatests/test_webui/ui_driver.py
07426e
+++ b/ipatests/test_webui/ui_driver.py
07426e
@@ -192,7 +192,7 @@ class UI_driver:
07426e
         if not NO_YAML and os.path.isfile(path):
07426e
             try:
07426e
                 with open(path, 'r') as conf:
07426e
-                    cls.config = yaml.load(stream=conf, Loader=yaml.FullLoader)
07426e
+                    cls.config = yaml.safe_load(stream=conf)
07426e
             except yaml.YAMLError as e:
07426e
                 pytest.skip("Invalid Web UI config.\n%s" % e)
07426e
             except IOError as e:
07426e
-- 
07426e
2.34.1
07426e
07426e
From 5444da016edc416c0c9481c660c013053dbb93b5 Mon Sep 17 00:00:00 2001
07426e
From: Mohammad Rizwan <myusuf@redhat.com>
07426e
Date: Thu, 18 Nov 2021 18:43:22 +0530
07426e
Subject: [PATCH] PEP8 Fixes
07426e
07426e
Signed-off-by: Mohammad Rizwan <myusuf@redhat.com>
07426e
---
07426e
 .../test_integration/test_replica_promotion.py     | 14 +++++++-------
07426e
 1 file changed, 7 insertions(+), 7 deletions(-)
07426e
07426e
diff --git a/ipatests/test_integration/test_replica_promotion.py b/ipatests/test_integration/test_replica_promotion.py
07426e
index 1a4e9bc12..c328b1a08 100644
07426e
--- a/ipatests/test_integration/test_replica_promotion.py
07426e
+++ b/ipatests/test_integration/test_replica_promotion.py
07426e
@@ -138,7 +138,6 @@ class TestReplicaPromotionLevel1(ReplicaPromotionBase):
07426e
         assert res.returncode == 1
07426e
         assert expected_err in res.stderr_text
07426e
 
07426e
-
07426e
     @replicas_cleanup
07426e
     def test_one_command_installation(self):
07426e
         """
07426e
@@ -150,11 +149,11 @@ class TestReplicaPromotionLevel1(ReplicaPromotionBase):
07426e
         Firewall(self.replicas[0]).enable_services(["freeipa-ldap",
07426e
                                                     "freeipa-ldaps"])
07426e
         self.replicas[0].run_command(['ipa-replica-install', '-w',
07426e
-                                     self.master.config.admin_password,
07426e
-                                     '-n', self.master.domain.name,
07426e
-                                     '-r', self.master.domain.realm,
07426e
-                                     '--server', self.master.hostname,
07426e
-                                     '-U'])
07426e
+                                      self.master.config.admin_password,
07426e
+                                      '-n', self.master.domain.name,
07426e
+                                      '-r', self.master.domain.realm,
07426e
+                                      '--server', self.master.hostname,
07426e
+                                      '-U'])
07426e
         # Ensure that pkinit is properly configured, test for 7566
07426e
         result = self.replicas[0].run_command(['ipa-pkinit-manage', 'status'])
07426e
         assert "PKINIT is enabled" in result.stdout_text
07426e
@@ -321,7 +320,7 @@ class TestWrongClientDomain(IntegrationTest):
07426e
         result1 = client.run_command(['ipa-replica-install', '-U', '-w',
07426e
                                       self.master.config.dirman_password],
07426e
                                      raiseonerr=False)
07426e
-        assert(result1.returncode == 0), (
07426e
+        assert (result1.returncode == 0), (
07426e
             'Failed to promote the client installed with the upcase domain name')
07426e
 
07426e
     def test_client_rollback(self):
07426e
@@ -355,6 +354,7 @@ class TestWrongClientDomain(IntegrationTest):
07426e
         assert("An error occurred while removing SSSD" not in
07426e
                result.stdout_text)
07426e
 
07426e
+
07426e
 class TestRenewalMaster(IntegrationTest):
07426e
 
07426e
     topology = 'star'
07426e
-- 
07426e
2.34.1
07426e
07426e
From 1d19b860d4cd3bd65a4b143b588425d9a64237fd Mon Sep 17 00:00:00 2001
07426e
From: Mohammad Rizwan <myusuf@redhat.com>
07426e
Date: Thu, 18 Nov 2021 18:36:58 +0530
07426e
Subject: [PATCH] Test cases for ipa-replica-conncheck command
07426e
07426e
Following test cases would be checked:
07426e
- when called with --principal (it should then prompt for a password)
07426e
- when called with --principal / --password
07426e
- when called without principal and password but with a kerberos TGT,
07426e
  kinit admin done before calling ipa-replica-conncheck
07426e
- when called without principal and password, and without any kerberos
07426e
  TGT (it should default to principal=admin and prompt for a password)
07426e
07426e
related: https://pagure.io/freeipa/issue/9047
07426e
07426e
Signed-off-by: Mohammad Rizwan <myusuf@redhat.com>
07426e
---
07426e
 .../test_replica_promotion.py                 | 70 +++++++++++++++++++
07426e
 1 file changed, 70 insertions(+)
07426e
07426e
diff --git a/ipatests/test_integration/test_replica_promotion.py b/ipatests/test_integration/test_replica_promotion.py
07426e
index b9c56f775..1a4e9bc12 100644
07426e
--- a/ipatests/test_integration/test_replica_promotion.py
07426e
+++ b/ipatests/test_integration/test_replica_promotion.py
07426e
@@ -437,6 +437,76 @@ class TestRenewalMaster(IntegrationTest):
07426e
         self.assertCARenewalMaster(master, replica.hostname)
07426e
         self.assertCARenewalMaster(replica, replica.hostname)
07426e
 
07426e
+    def test_replica_concheck(self):
07426e
+        """Test cases for ipa-replica-conncheck command
07426e
+
07426e
+        Following test cases would be checked:
07426e
+        - when called with --principal (it should then prompt for a password)
07426e
+        - when called with --principal / --password
07426e
+        - when called without principal and password but with a kerberos TGT,
07426e
+          kinit admin done before calling ipa-replica-conncheck
07426e
+        - when called without principal and password, and without any kerberos
07426e
+          TGT (it should default to principal=admin and prompt for a password)
07426e
+
07426e
+          related: https://pagure.io/freeipa/issue/9047
07426e
+        """
07426e
+        exp_str1 = "Connection from replica to master is OK."
07426e
+        exp_str2 = "Connection from master to replica is OK"
07426e
+        tasks.kdestroy_all(self.replicas[0])
07426e
+        # when called with --principal (it should then prompt for a password)
07426e
+        result = self.replicas[0].run_command(
07426e
+            ['ipa-replica-conncheck', '--auto-master-check',
07426e
+             '--master', self.master.hostname,
07426e
+             '-r', self.replicas[0].domain.realm,
07426e
+             '-p', self.replicas[0].config.admin_name],
07426e
+            stdin_text=self.master.config.admin_password
07426e
+        )
07426e
+        assert result.returncode == 0
07426e
+        assert (
07426e
+            exp_str1 in result.stderr_text and exp_str2 in result.stderr_text
07426e
+        )
07426e
+
07426e
+        # when called with --principal / --password
07426e
+        result = self.replicas[0].run_command([
07426e
+            'ipa-replica-conncheck', '--auto-master-check',
07426e
+            '--master', self.master.hostname,
07426e
+            '-r', self.replicas[0].domain.realm,
07426e
+            '-p', self.replicas[0].config.admin_name,
07426e
+            '-w', self.master.config.admin_password
07426e
+        ])
07426e
+        assert result.returncode == 0
07426e
+        assert (
07426e
+            exp_str1 in result.stderr_text and exp_str2 in result.stderr_text
07426e
+        )
07426e
+
07426e
+        # when called without principal and password, and without
07426e
+        # any kerberos TGT, it should default to principal=admin
07426e
+        # and prompt for a password
07426e
+        result = self.replicas[0].run_command(
07426e
+            ['ipa-replica-conncheck', '--auto-master-check',
07426e
+             '--master', self.master.hostname,
07426e
+             '-r', self.replicas[0].domain.realm],
07426e
+            stdin_text=self.master.config.admin_password
07426e
+        )
07426e
+        assert result.returncode == 0
07426e
+        assert (
07426e
+            exp_str1 in result.stderr_text and exp_str2 in result.stderr_text
07426e
+        )
07426e
+
07426e
+        # when called without principal and password but with a kerberos TGT,
07426e
+        # kinit admin done before calling ipa-replica-conncheck
07426e
+        tasks.kinit_admin(self.replicas[0])
07426e
+        result = self.replicas[0].run_command(
07426e
+            ['ipa-replica-conncheck', '--auto-master-check',
07426e
+             '--master', self.master.hostname,
07426e
+             '-r', self.replicas[0].domain.realm]
07426e
+        )
07426e
+        assert result.returncode == 0
07426e
+        assert (
07426e
+            exp_str1 in result.stderr_text and exp_str2 in result.stderr_text
07426e
+        )
07426e
+        tasks.kdestroy_all(self.replicas[0])
07426e
+
07426e
     def test_automatic_renewal_master_transfer_ondelete(self):
07426e
         # Test that after replica uninstallation, master overtakes the cert
07426e
         # renewal master role from replica (which was previously set there)
07426e
-- 
07426e
2.34.1
07426e