def test_ipa_healthcheck_remove(self): """ This testcase checks the removal of of healthcheck tool on replica and master """ tasks.uninstall_packages(self.master, HEALTHCHECK_PKG) tasks.uninstall_packages(self.replicas[0], HEALTHCHECK_PKG)
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 = tasks.get_backup_dir(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')
def install(cls, mh): # External DNS is only available before install so cache a copy # of the *ipa-epn-client package so we can experimentally remove # it later. # # Notes: # - A package can't be downloaded that is already installed so we # have to remove it first. # - dnf cleans up previously downloaded locations so make a copy it # doesn't know about. # - Adds a class variable, pkg, containing the package name of # the downloaded *ipa-client-epn rpm. tasks.uninstall_packages(cls.clients[0], EPN_PKG) pkgdir = tasks.download_packages(cls.clients[0], EPN_PKG) pkg = cls.clients[0].run_command(r'ls -1 {}'.format(pkgdir)) cls.pkg = pkg.stdout_text.strip() cls.clients[0].run_command( ['cp', os.path.join(pkgdir, cls.pkg), '/tmp']) cls.clients[0].run_command(r'rm -rf {}'.format(pkgdir)) tasks.install_packages(cls.master, EPN_PKG) tasks.install_packages(cls.master, ["postfix"]) tasks.install_packages(cls.clients[0], EPN_PKG) tasks.install_packages(cls.clients[0], ["postfix"]) for host in (cls.master, cls.clients[0]): try: tasks.install_packages(host, ["cyrus-sasl"]) except Exception: # the package is likely already installed pass tasks.install_master(cls.master, setup_dns=True) tasks.install_client(cls.master, cls.clients[0]) configure_postfix(cls.master, cls.master.domain.realm) configure_postfix(cls.clients[0], cls.master.domain.realm)
def uninstall(cls, mh): super(TestEPN, cls).uninstall(mh) tasks.uninstall_packages(cls.master, ["postfix"]) tasks.uninstall_packages(cls.clients[0], ["postfix"]) cls.master.run_command(r'rm -f /etc/postfix/smtp.keytab') cls.master.run_command(r'getcert stop-tracking -f ' '/etc/pki/tls/certs/postfix.pem') cls.master.run_command(r'rm -f /etc/pki/tls/private/postfix.key') cls.master.run_command(r'rm -f /etc/pki/tls/certs/postfix.pem')
def _full_backup_restore_with_DNS_zone(self, reinstall=False): """backup, uninstall, restore. Test for bug https://pagure.io/freeipa/issue/7630. """ with restore_checker(self.master): self.master.run_command([ 'ipa', 'dnszone-add', self.example_test_zone, ]) tasks.resolve_record(self.master.ip, self.example_test_zone) backup_path = tasks.get_backup_dir(self.master) self.master.run_command( ['ipa-server-install', '--uninstall', '-U']) tasks.uninstall_packages(self.master, ['*ipa-server-dns']) 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']) if reinstall: tasks.install_master(self.master, setup_dns=True) self.master.run_command(['ipa-restore', backup_path], stdin_text=dirman_password + '\nyes') if reinstall: # If the server was reinstalled, reinstall may have changed # the uid and restore reverts to the original value. # clear the cache to make sure we get up-to-date values tasks.clear_sssd_cache(self.master) tasks.resolve_record(self.master.ip, self.example_test_zone) tasks.kinit_admin(self.master) self.master.run_command([ 'ipa', 'dnszone-add', self.example2_test_zone, ]) tasks.resolve_record(self.master.ip, self.example2_test_zone)
def test_ipa_healthcheck_log_rotate_file_exist_issue35(self): """ This test checks if log rotation has been added for ipa-healthcheck tool so that logs are rotated in /var/log/ipa/healthcheck folder. The test also checks that the logrotate configuration file is syntactically correct by calling logrotate --debug This is a testcase for below pagure issue https://github.com/freeipa/freeipa-healthcheck/issues/35 """ msg = "error: {}:".format(HEALTHCHECK_LOG_ROTATE_CONF) tasks.uninstall_packages(self.master, HEALTHCHECK_PKG) assert not self.master.transport.file_exists( HEALTHCHECK_LOG_ROTATE_CONF) tasks.install_packages(self.master, HEALTHCHECK_PKG) assert self.master.transport.file_exists(HEALTHCHECK_LOG_ROTATE_CONF) cmd = self.master.run_command( ['logrotate', '--debug', HEALTHCHECK_LOG_ROTATE_CONF]) assert msg not in cmd.stdout_text
def _full_backup_restore_with_DNS_zone(self, reinstall=False): """backup, uninstall, restore. Test for bug https://pagure.io/freeipa/issue/7630. """ with restore_checker(self.master): self.master.run_command([ 'ipa', 'dnszone-add', self.example_test_zone, ]) tasks.resolve_record(self.master.ip, self.example_test_zone) backup_path = backup(self.master) self.master.run_command( ['ipa-server-install', '--uninstall', '-U']) tasks.uninstall_packages(self.master, ['*ipa-server-dns']) 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']) if reinstall: tasks.install_master(self.master, setup_dns=True) 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) self.master.run_command([ 'ipa', 'dnszone-add', self.example2_test_zone, ]) tasks.resolve_record(self.master.ip, self.example2_test_zone)
def test_EPN_reinstall(self): """Test that EPN can be installed, uninstalled and reinstalled. Since post-install we no longer have access to the repos the package is downloaded and stored prior to server installation. """ tasks.uninstall_packages(self.clients[0], EPN_PKG) tasks.install_packages(self.clients[0], [os.path.join('/tmp', self.pkg)]) self.clients[0].run_command(r'rm -f /tmp/{}'.format(self.pkg)) # re-installing will create a new epn.conf so any execution # of ipa-epn will verify the reinstall was ok. Since the previous # test would have failed this one should be ok with new config. # Re-run the admin user expected failure (unused, stderr_text, _unused) = self._check_epn_output(self.master, dry_run=True) assert "uid=admin" in stderr_text
def uninstall(cls, mh): super(TestEPN, cls).uninstall(mh) tasks.uninstall_packages(cls.master, EPN_PKG) tasks.uninstall_packages(cls.master, ["postfix"]) tasks.uninstall_packages(cls.clients[0], EPN_PKG) tasks.uninstall_packages(cls.clients[0], ["postfix"]) cls.master.run_command(r'rm -f /etc/postfix/smtp.keytab') for cert in [SMTPD_CERT, SMTP_CLIENT_CERT]: cls.master.run_command(["getcert", "stop-tracking", "-f", cert]) cls.master.run_command([ "rm", "-f", SMTPD_CERT, SMTPD_KEY, SMTP_CLIENT_CERT, SMTP_CLIENT_KEY, ])