From 92adcf44398283e4eb92c0dbf2a0e39afaa3408a Mon Sep 17 00:00:00 2001
From: Michal Polovka <mpolovka@redhat.com>
Date: Fri, 5 Mar 2021 11:31:04 +0100
Subject: [PATCH 1/2] ipatests: test_installation: add install test scenarios

test_hostname_parameter: Test for #2692 ipa-server-install ignores --hostname
 - check whether hostname provided in `--hostname` parameter is being
   taken into account and set as new hostname without prompting for it
   again
test_ad_subpackage_dependency: Test for #4011 ipa-server-install crashes when AD subpackage is not installed
 - test if ipa-server installation succeeds without
   `freeipa-ipa-server-trust-ad` installed
test_backup_of_cs_cfg_should_be_created: Test for #4166 Backup CS.cfg before modifying it
 - test if ipa-server installer backs up CS.cfg before modifying it
test_update_krb5_conf_template_with_keyring_default_ccache_name: Test for #4013 Update krb5.conf.template to support KEYRING default_ccache_name
 - test if krb5.conf is updated with permanent ccache after installation

Related: https://pagure.io/freeipa/issue/2692
Related: https://pagure.io/freeipa/issue/4011
Related: https://pagure.io/freeipa/issue/4166
Related: https://pagure.io/freeipa/issue/4013

Signed-off-by: Michal Polovka <mpolovka@redhat.com>
---
 .../test_integration/test_installation.py     | 84 +++++++++++++++++++
 1 file changed, 84 insertions(+)

diff --git a/ipatests/test_integration/test_installation.py b/ipatests/test_integration/test_installation.py
index 18c5bd24393..ee73ef94275 100644
--- a/ipatests/test_integration/test_installation.py
+++ b/ipatests/test_integration/test_installation.py
@@ -1108,6 +1108,74 @@ def run_request(url, expected_stdout=None, expected_stderr=None):
                 expected_stdout=f'href="https://{self.master.hostname}/'
             )
 
+    def test_hostname_parameter(self):
+        """
+        Test for #2692 ipa-server-install ignores --hostname
+
+        https://pagure.io/freeipa/issue/2692
+        """
+        original_hostname = self.master.hostname
+        new_hostname = "ipa2692.test"
+        ip_address = self.master.ip
+        hosts = self.master.get_file_contents('/etc/hosts')
+        new_hosts = hosts + "\n{}        {}".format(ip_address, new_hostname)
+        self.master.put_file_contents('/etc/hosts', new_hosts)
+        result = tasks.install_master(self.master,
+                                      setup_dns=False,
+                                      extra_args=['--hostname',
+                                                  new_hostname])
+        try:
+            assert result.returncode == 0
+            hostname = self.master.run_command(['hostname', '-f']).stdout_text
+            assert hostname == new_hostname
+        finally:
+            self.master.hostname = original_hostname
+            self.master.put_file_contents('/etc/hosts', hosts)
+
+    def test_ad_subpackage_dependency(self):
+        """
+        Test for #4011 ipa-server-install crashes
+        when AD subpackage is not installed
+
+        https://pagure.io/freeipa/issue/4011
+        """
+        package_name = "*ipa-server-trust-ad"
+        tasks.uninstall_packages(self.master, [package_name])
+        result = tasks.install_master(self.master)
+        assert result.returncode == 0
+
+    def test_backup_of_cs_cfg_should_be_created(self):
+        """
+        Test for #4166 Backup CS.cfg before modifying it
+
+        https://pagure.io/freeipa/issue/4166
+        """
+        log_location = "/var/lib/pki/pki-tomcat/ca/conf/CS.cfg"
+        bcp_location = log_location + ".ipabkp"
+        ipainstall_log_location = "/var/log/ipaserver-install.log"
+        tasks.install_master(self.master)
+        ipaserver_install_log = self.master.get_file_contents(
+            ipainstall_log_location)
+        assert "backing up CS.cfg" in ipaserver_install_log
+        try:
+            self.master.get_file_contents(bcp_location)
+        except IOError:
+            raise AssertionError("Backup of CS.cfg not created")
+
+    def test_update_krb5_conf_template_with_keyring_default_ccache_name(self):
+        """
+        Test for #4013 Update krb5.conf.template to support
+        KEYRING default_ccache_name
+
+        https://pagure.io/freeipa/issue/4013
+        """
+        tasks.install_master(self.master)
+        tasks.kinit_admin(self.master)
+        klist = self.master.run_command(['klist']).stdout_text
+        assert '/tmp/' not in klist
+        krb5conf = self.master.get_file_contents('/etc/krb5.conf')
+        assert "default_ccache_name = KEYRING:persistent:%{uid}" in krb5conf
+
 
 class TestInstallMasterKRA(IntegrationTest):
 
@@ -1178,6 +1246,22 @@ def test_install_master(self):
 
         assert "Administrator e-mail address: me.example.org" in result
 
+    def test_installer_wizard_should_prompt_for_DNS(self):
+        """
+        Test for [RFE] Installer wizard should prompt for DNS
+
+        https://pagure.io/freeipa/issue/2575
+        """
+        tasks.install_master(self.master,
+                             setup_dns=False,
+                             stdin_text="yes\n\n\n\n\n\nyes\n")
+        tasks.kinit_admin(self.master)
+        result = self.master.run_command(
+            ['ipa', 'dnszone-show', self.master.domain.name]
+        ).stdout_text
+
+        assert "Active zone: TRUE" in result
+
     def test_server_install_lock_bind_recursion(self):
         """Test if server installer lock Bind9 recursion
 

From eea817600b0700b82a688f67395b12649ee17fec Mon Sep 17 00:00:00 2001
From: Michal Polovka <mpolovka@redhat.com>
Date: Fri, 5 Mar 2021 11:37:45 +0100
Subject: [PATCH 2/2] temp commit

Signed-off-by: Michal Polovka <mpolovka@redhat.com>
---
 .freeipa-pr-ci.yaml                        | 2 +-
 ipatests/prci_definitions/temp_commit.yaml | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/.freeipa-pr-ci.yaml b/.freeipa-pr-ci.yaml
index abcf8c5b634..80656690080 120000
--- a/.freeipa-pr-ci.yaml
+++ b/.freeipa-pr-ci.yaml
@@ -1 +1 @@
-ipatests/prci_definitions/gating.yaml
\ No newline at end of file
+ipatests/prci_definitions/temp_commit.yaml
\ No newline at end of file
diff --git a/ipatests/prci_definitions/temp_commit.yaml b/ipatests/prci_definitions/temp_commit.yaml
index 8f8a357acd1..c636c68fb14 100644
--- a/ipatests/prci_definitions/temp_commit.yaml
+++ b/ipatests/prci_definitions/temp_commit.yaml
@@ -68,7 +68,7 @@ jobs:
       class: RunPytest
       args:
         build_url: '{fedora-latest/build_url}'
-        test_suite: test_integration/test_REPLACEME.py
+        test_suite: test_integration/test_installation.py
         template: *ci-master-latest
         timeout: 3600
-        topology: *master_1repl_1client
+        topology: *master_3repl_1client
