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

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