diff --git a/ipatests/prci_definitions/nightly_latest.yaml b/ipatests/prci_definitions/nightly_latest.yaml index cc102338e..6cf4a7361 100644 --- a/ipatests/prci_definitions/nightly_latest.yaml +++ b/ipatests/prci_definitions/nightly_latest.yaml @@ -1472,3 +1472,15 @@ jobs: template: *ci-master-latest timeout: 7200 topology: *adroot_adchild_adtree_master_1client + + fedora-latest/test_backup_and_restore_TestBackupAndRestoreTrust: + requires: [fedora-latest/build] + priority: 50 + job: + class: RunPytest + args: + build_url: '{fedora-latest/build_url}' + test_suite: test_integration/test_backup_and_restore.py::TestBackupAndRestoreTrust + template: *ci-master-latest + timeout: 7200 + topology: *master_1repl diff --git a/ipatests/prci_definitions/nightly_latest_testing.yaml b/ipatests/prci_definitions/nightly_latest_testing.yaml index 174fb5346..afef56f0a 100644 --- a/ipatests/prci_definitions/nightly_latest_testing.yaml +++ b/ipatests/prci_definitions/nightly_latest_testing.yaml @@ -1574,3 +1574,16 @@ jobs: template: *testing-master-latest timeout: 7200 topology: *adroot_adchild_adtree_master_1client + + testing-fedora/test_backup_and_restore_TestBackupAndRestoreTrust: + requires: [testing-fedora/build] + priority: 50 + job: + class: RunPytest + args: + build_url: '{testing-fedora/build_url}' + update_packages: True + test_suite: test_integration/test_backup_and_restore.py::TestBackupAndRestoreTrust + template: *testing-master-latest + timeout: 7200 + topology: *master_1repl diff --git a/ipatests/prci_definitions/nightly_previous.yaml b/ipatests/prci_definitions/nightly_previous.yaml index 76e76d615..2fcb5d551 100644 --- a/ipatests/prci_definitions/nightly_previous.yaml +++ b/ipatests/prci_definitions/nightly_previous.yaml @@ -1448,3 +1448,15 @@ jobs: template: *ci-master-previous timeout: 7200 topology: *adroot_adchild_adtree_master_1client + + fedora-previous/test_backup_and_restore_TestBackupAndRestoreTrust: + requires: [fedora-previous/build] + priority: 50 + job: + class: RunPytest + args: + build_url: '{fedora-previous/build_url}' + test_suite: test_integration/test_backup_and_restore.py::TestBackupAndRestoreTrust + template: *ci-master-previous + timeout: 7200 + topology: *master_1repl diff --git a/ipatests/prci_definitions/nightly_rawhide.yaml b/ipatests/prci_definitions/nightly_rawhide.yaml index 34ee4cfb8..fd5648246 100644 --- a/ipatests/prci_definitions/nightly_rawhide.yaml +++ b/ipatests/prci_definitions/nightly_rawhide.yaml @@ -1588,3 +1588,16 @@ jobs: template: *ci-master-frawhide timeout: 7200 topology: *adroot_adchild_adtree_master_1client + + fedora-rawhide/test_backup_and_restore_TestBackupAndRestoreTrust: + requires: [fedora-rawhide/build] + priority: 50 + job: + class: RunPytest + args: + build_url: '{fedora-rawhide/build_url}' + update_packages: True + test_suite: test_integration/test_backup_and_restore.py::TestBackupAndRestoreTrust + template: *ci-master-frawhide + timeout: 7200 + topology: *master_1repl diff --git a/ipatests/pytest_ipa/integration/tasks.py b/ipatests/pytest_ipa/integration/tasks.py index 49b5050f8..017eb3458 100755 --- a/ipatests/pytest_ipa/integration/tasks.py +++ b/ipatests/pytest_ipa/integration/tasks.py @@ -2039,6 +2039,8 @@ def install_packages(host, pkgs): # Only supports RHEL 8+ and Fedora for now if platform in ('rhel', 'fedora'): install_cmd = ['/usr/bin/dnf', 'install', '-y'] + elif platform in ('ubuntu'): + install_cmd = ['apt-get', 'install', '-y'] else: raise ValueError('install_packages: unknown platform %s' % platform) host.run_command(install_cmd + pkgs) @@ -2053,6 +2055,8 @@ def uninstall_packages(host, pkgs): # Only supports RHEL 8+ and Fedora for now if platform in ('rhel', 'fedora'): install_cmd = ['/usr/bin/dnf', 'remove', '-y'] + elif platform in ('ubuntu'): + install_cmd = ['apt-get', 'remove', '-y'] else: raise ValueError('install_packages: unknown platform %s' % platform) host.run_command(install_cmd + pkgs) diff --git a/ipatests/test_integration/test_backup_and_restore.py b/ipatests/test_integration/test_backup_and_restore.py index dbe44ff22..1d5d3ae22 100644 --- a/ipatests/test_integration/test_backup_and_restore.py +++ b/ipatests/test_integration/test_backup_and_restore.py @@ -297,7 +297,10 @@ class BaseBackupAndRestoreWithDNS(IntegrationTest): tasks.install_master(cls.master, setup_dns=True) def _full_backup_restore_with_DNS_zone(self, reinstall=False): - """backup, uninstall, restore""" + """backup, uninstall, restore. + + Test for bug https://pagure.io/freeipa/issue/7630. + """ with restore_checker(self.master): self.master.run_command([ 'ipa', 'dnszone-add', @@ -312,13 +315,20 @@ class BaseBackupAndRestoreWithDNS(IntegrationTest): '--uninstall', '-U']) + tasks.uninstall_packages(self.master, ['*ipa-server-dns']) if reinstall: tasks.install_master(self.master, setup_dns=True) dirman_password = self.master.config.dirman_password + result = self.master.run_command( + ['ipa-restore', backup_path], + stdin_text=dirman_password + '\nyes', + raiseonerr=False) + assert 'Please install the package' in result.stderr_text + + tasks.install_packages(self.master, ['*ipa-server-dns']) self.master.run_command(['ipa-restore', backup_path], stdin_text=dirman_password + '\nyes') - tasks.resolve_record(self.master.ip, self.example_test_zone) tasks.kinit_admin(self.master) @@ -861,3 +871,39 @@ class TestReplicaInstallAfterRestore(IntegrationTest): # install second replica after restore tasks.install_replica(master, replica2) check_replication(master, replica2, "testuser2") + + +class TestBackupAndRestoreTrust(IntegrationTest): + """Test for Backup and Restore for Trust scenario""" + topology = 'star' + + def test_restore_trust_pkg_before_restore(self): + """Test restore with adtrust when trust-ad pkg is missing. + + Test for bug https://pagure.io/freeipa/issue/7630. + """ + tasks.install_packages(self.master, ['*ipa-server-trust-ad']) + self.master.run_command(['ipa-adtrust-install', '-U', + '--enable-compat', '--netbios-name', 'IPA', + '-a', self.master.config.admin_password, + '--add-sids']) + + with restore_checker(self.master): + backup_path = backup(self.master) + + self.master.run_command(['ipa-server-install', + '--uninstall', + '-U']) + + tasks.uninstall_packages(self.master, ['*ipa-server-trust-ad']) + + dirman_password = self.master.config.dirman_password + result = self.master.run_command( + ['ipa-restore', backup_path], + stdin_text=dirman_password + '\nyes', + raiseonerr=False) + assert 'Please install the package' in result.stderr_text + + tasks.install_packages(self.master, ['*ipa-server-trust-ad']) + self.master.run_command(['ipa-restore', backup_path], + stdin_text=dirman_password + '\nyes')