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

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