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

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