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

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