diff options
Diffstat (limited to 'ipatests/test_integration')
-rw-r--r-- | ipatests/test_integration/tasks.py | 77 | ||||
-rw-r--r-- | ipatests/test_integration/test_caless.py | 29 | ||||
-rw-r--r-- | ipatests/test_integration/test_forced_client_reenrollment.py | 7 | ||||
-rw-r--r-- | ipatests/test_integration/test_legacy_clients.py | 5 |
4 files changed, 61 insertions, 57 deletions
diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py index ca5b44e4f..ccb0d8693 100644 --- a/ipatests/test_integration/tasks.py +++ b/ipatests/test_integration/tasks.py @@ -30,6 +30,7 @@ import StringIO from ldif import LDIFWriter from ipapython import ipautil +from ipaplatform.paths import paths from ipapython.dn import DN from ipapython.ipa_log_manager import log_mgr from ipatests.test_integration import util @@ -75,8 +76,8 @@ def backup_file(host, filename): def fix_etc_hosts(host): - backup_file(host, '/etc/hosts') - contents = host.get_file_contents('/etc/hosts') + backup_file(host, paths.HOSTS) + contents = host.get_file_contents(paths.HOSTS) # Remove existing mentions of the host's FQDN, short name, and IP contents = re.sub('\s%s(\s|$)' % re.escape(host.hostname), ' ', contents, flags=re.MULTILINE) @@ -87,12 +88,12 @@ def fix_etc_hosts(host): # Add the host's info again contents += '\n%s %s %s\n' % (host.ip, host.hostname, host.shortname) log.debug('Writing the following to /etc/hosts:\n%s', contents) - host.put_file_contents('/etc/hosts', contents) + host.put_file_contents(paths.HOSTS, contents) def fix_hostname(host): - backup_file(host, '/etc/hostname') - host.put_file_contents('/etc/hostname', host.hostname + '\n') + backup_file(host, paths.ETC_HOSTNAME) + host.put_file_contents(paths.ETC_HOSTNAME, host.hostname + '\n') host.run_command(['hostname', host.hostname]) backupname = os.path.join(host.config.test_dir, 'backup_hostname') @@ -100,24 +101,24 @@ def fix_hostname(host): def fix_resolv_conf(host): - backup_file(host, '/etc/resolv.conf') - lines = host.get_file_contents('/etc/resolv.conf').splitlines() + backup_file(host, paths.RESOLV_CONF) + lines = host.get_file_contents(paths.RESOLV_CONF).splitlines() lines = ['#' + l if l.startswith('nameserver') else l for l in lines] for other_host in host.domain.hosts: if other_host.role in ('master', 'replica'): lines.append('nameserver %s' % other_host.ip) contents = '\n'.join(lines) log.debug('Writing the following to /etc/resolv.conf:\n%s', contents) - host.put_file_contents('/etc/resolv.conf', contents) + host.put_file_contents(paths.RESOLV_CONF, contents) def fix_apache_semaphores(master): - systemd_available = master.transport.file_exists('/bin/systemctl') + systemd_available = master.transport.file_exists(paths.SYSTEMCTL) if systemd_available: master.run_command(['systemctl', 'stop', 'httpd'], raiseonerr=False) else: - master.run_command(['/sbin/service', 'httpd', 'stop'], raiseonerr=False) + master.run_command([paths.SBIN_SERVICE, 'httpd', 'stop'], raiseonerr=False) master.run_command('for line in `ipcs -s | grep apache | cut -d " " -f 2`; ' 'do ipcrm -s $line; done', raiseonerr=False) @@ -184,11 +185,11 @@ def enable_replication_debugging(host): def install_master(host): - host.collect_log('/var/log/ipaserver-install.log') - host.collect_log('/var/log/ipaclient-install.log') + host.collect_log(paths.IPASERVER_INSTALL_LOG) + host.collect_log(paths.IPACLIENT_INSTALL_LOG) inst = host.domain.realm.replace('.', '-') - host.collect_log('/var/log/dirsrv/slapd-%s/errors' % inst) - host.collect_log('/var/log/dirsrv/slapd-%s/access' % inst) + host.collect_log(paths.SLAPD_INSTANCE_ERROR_LOG_TEMPLATE % inst) + host.collect_log(paths.SLAPD_INSTANCE_ACCESS_LOG_TEMPLATE % inst) apply_common_fixes(host) fix_apache_semaphores(host) @@ -207,8 +208,8 @@ def install_master(host): def install_replica(master, replica, setup_ca=True): - replica.collect_log('/var/log/ipareplica-install.log') - replica.collect_log('/var/log/ipareplica-conncheck.log') + replica.collect_log(paths.IPAREPLICA_INSTALL_LOG) + replica.collect_log(paths.IPAREPLICA_CONNCHECK_LOG) apply_common_fixes(replica) fix_apache_semaphores(replica) @@ -218,7 +219,7 @@ def install_replica(master, replica, setup_ca=True): '--ip-address', replica.ip, replica.hostname]) replica_bundle = master.get_file_contents( - '/var/lib/ipa/replica-info-%s.gpg' % replica.hostname) + paths.REPLICA_INFO_TEMPLATE_GPG % replica.hostname) replica_filename = os.path.join(replica.config.test_dir, 'replica-info.gpg') replica.put_file_contents(replica_filename, replica_bundle) @@ -239,7 +240,7 @@ def install_replica(master, replica, setup_ca=True): def install_client(master, client, extra_args=()): - client.collect_log('/var/log/ipaclient-install.log') + client.collect_log(paths.IPACLIENT_INSTALL_LOG) apply_common_fixes(client) @@ -262,11 +263,11 @@ def install_adtrust(host): """ # ipa-adtrust-install appends to ipaserver-install.log - host.collect_log('/var/log/ipaserver-install.log') + host.collect_log(paths.IPASERVER_INSTALL_LOG) inst = host.domain.realm.replace('.', '-') - host.collect_log('/var/log/dirsrv/slapd-%s/errors' % inst) - host.collect_log('/var/log/dirsrv/slapd-%s/access' % inst) + host.collect_log(paths.SLAPD_INSTANCE_ERROR_LOG_TEMPLATE % inst) + host.collect_log(paths.SLAPD_INSTANCE_ACCESS_LOG_TEMPLATE % inst) kinit_admin(host) host.run_command(['ipa-adtrust-install', '-U', @@ -354,7 +355,7 @@ def establish_trust_with_ad(master, ad, extra_args=()): """ # Force KDC to reload MS-PAC info by trying to get TGT for HTTP - master.run_command(['kinit', '-kt', '/etc/httpd/conf/ipa.keytab', + master.run_command(['kinit', '-kt', paths.IPA_KEYTAB, 'HTTP/%s' % master.hostname]) master.run_command(['systemctl', 'restart', 'krb5kdc.service']) master.run_command(['kdestroy', '-A']) @@ -397,7 +398,7 @@ def configure_auth_to_local_rule(master, ad): % (ad.domain.realm, ad.domain.realm, ad.domain.name)) line2 = " auth_to_local = DEFAULT" - krb5_conf_content = master.get_file_contents('/etc/krb5.conf') + krb5_conf_content = master.get_file_contents(paths.KRB5_CONF) krb5_lines = [line.rstrip() for line in krb5_conf_content.split('\n')] realm_section_index = krb5_lines.index(section_identifier) @@ -405,7 +406,7 @@ def configure_auth_to_local_rule(master, ad): krb5_lines.insert(realm_section_index + 2, line2) krb5_conf_new_content = '\n'.join(krb5_lines) - master.put_file_contents('/etc/krb5.conf', krb5_conf_new_content) + master.put_file_contents(paths.KRB5_CONF, krb5_conf_new_content) master.run_command(['systemctl', 'restart', 'sssd']) @@ -419,13 +420,13 @@ def setup_sssd_debugging(host): # First, remove any previous occurences host.run_command(['sed', '-i', '/debug_level = 7/d', - '/etc/sssd/sssd.conf' + paths.SSSD_CONF ], raiseonerr=False) # Add the debug directive to each section host.run_command(['sed', '-i', '/\[*\]/ a\debug_level = 7', - '/etc/sssd/sssd.conf' + paths.SSSD_CONF ], raiseonerr=False) @@ -440,22 +441,22 @@ def clear_sssd_cache(host): Clears SSSD cache by removing the cache files. Restarts SSSD. """ - systemd_available = host.transport.file_exists('/bin/systemctl') + systemd_available = host.transport.file_exists(paths.SYSTEMCTL) if systemd_available: host.run_command(['systemctl', 'stop', 'sssd']) else: - host.run_command(['/sbin/service', 'sssd', 'stop']) + host.run_command([paths.SBIN_SERVICE, 'sssd', 'stop']) host.run_command("find /var/lib/sss/db -name '*.ldb' | " "xargs rm -fv") - host.run_command(['rm', '-fv', '/var/lib/sss/mc/group']) - host.run_command(['rm', '-fv', '/var/lib/sss/mc/passwd']) + host.run_command(['rm', '-fv', paths.SSSD_MC_GROUP]) + host.run_command(['rm', '-fv', paths.SSSD_MC_PASSWD]) if systemd_available: host.run_command(['systemctl', 'start', 'sssd']) else: - host.run_command(['/sbin/service', 'sssd', 'start']) + host.run_command([paths.SBIN_SERVICE, 'sssd', 'start']) # To avoid false negatives due to SSSD not responding yet time.sleep(10) @@ -487,24 +488,24 @@ def kinit_admin(host): def uninstall_master(host): - host.collect_log('/var/log/ipaserver-uninstall.log') + host.collect_log(paths.IPASERVER_UNINSTALL_LOG) host.run_command(['ipa-server-install', '--uninstall', '-U'], raiseonerr=False) host.run_command(['pkidestroy', '-s', 'CA', '-i', 'pki-tomcat'], raiseonerr=False) host.run_command(['rm', '-rf', - '/var/log/pki/pki-tomcat', - '/etc/sysconfig/pki-tomcat', - '/etc/sysconfig/pki/tomcat/pki-tomcat', - '/var/lib/pki/pki-tomcat', - '/etc/pki/pki-tomcat'], + paths.TOMCAT_TOPLEVEL_DIR, + paths.SYSCONFIG_PKI_TOMCAT, + paths.SYSCONFIG_PKI_TOMCAT_PKI_TOMCAT_DIR, + paths.VAR_LIB_PKI_TOMCAT_DIR, + paths.PKI_TOMCAT], raiseonerr=False) unapply_fixes(host) def uninstall_client(host): - host.collect_log('/var/log/ipaclient-uninstall.log') + host.collect_log(paths.IPACLIENT_UNINSTALL_LOG) host.run_command(['ipa-client-install', '--uninstall', '-U'], raiseonerr=False) diff --git a/ipatests/test_integration/test_caless.py b/ipatests/test_integration/test_caless.py index d20a8511c..d5382988b 100644 --- a/ipatests/test_integration/test_caless.py +++ b/ipatests/test_integration/test_caless.py @@ -27,6 +27,7 @@ import nose from ipalib import x509 from ipapython import ipautil +from ipaplatform.paths import paths from ipapython.dn import DN from ipatests.test_integration.base import IntegrationTest from ipatests.test_integration import tasks @@ -113,7 +114,7 @@ class CALessBase(IntegrationTest): # Remove CA cert in /etc/pki/nssdb, in case of failed (un)install for host in cls.get_all_hosts(): - cls.master.run_command(['certutil', '-d', '/etc/pki/nssdb', '-D', + cls.master.run_command(['certutil', '-d', paths.NSS_DB_DIR, '-D', '-n', 'External CA cert'], raiseonerr=False) @@ -145,11 +146,11 @@ class CALessBase(IntegrationTest): for filename in set(files_to_copy): cls.copy_cert(host, filename) - cls.collect_log(host, '/var/log/ipaserver-install.log') - cls.collect_log(host, '/var/log/ipaclient-install.log') + cls.collect_log(host, paths.IPASERVER_INSTALL_LOG) + cls.collect_log(host, paths.IPACLIENT_INSTALL_LOG) inst = host.domain.realm.replace('.', '-') - cls.collect_log(host, '/var/log/dirsrv/slapd-%s/errors' % inst) - cls.collect_log(host, '/var/log/dirsrv/slapd-%s/access' % inst) + cls.collect_log(host, paths.SLAPD_INSTANCE_ERROR_LOG_TEMPLATE % inst) + cls.collect_log(host, paths.SLAPD_INSTANCE_ACCESS_LOG_TEMPLATE % inst) args = [ 'ipa-server-install', @@ -216,11 +217,11 @@ class CALessBase(IntegrationTest): os.path.join(self.cert_dir, filename), os.path.join(master.config.test_dir, filename)) - self.collect_log(replica, '/var/log/ipareplica-install.log') - self.collect_log(replica, '/var/log/ipaclient-install.log') + self.collect_log(replica, paths.IPAREPLICA_INSTALL_LOG) + self.collect_log(replica, paths.IPACLIENT_INSTALL_LOG) inst = replica.domain.realm.replace('.', '-') - self.collect_log(replica, '/var/log/dirsrv/slapd-%s/errors' % inst) - self.collect_log(replica, '/var/log/dirsrv/slapd-%s/access' % inst) + self.collect_log(replica, paths.SLAPD_INSTANCE_ERROR_LOG_TEMPLATE % inst) + self.collect_log(replica, paths.SLAPD_INSTANCE_ACCESS_LOG_TEMPLATE % inst) args = [ 'ipa-replica-prepare', @@ -244,7 +245,7 @@ class CALessBase(IntegrationTest): if result.returncode == 0: replica_bundle = master.get_file_contents( - '/var/lib/ipa/replica-info-%s.gpg' % replica.hostname) + paths.REPLICA_INFO_TEMPLATE_GPG % replica.hostname) replica.put_file_contents(self.get_replica_filename(replica), replica_bundle) else: @@ -327,7 +328,7 @@ class CALessBase(IntegrationTest): for host in self.get_all_hosts(): # Check the cert PEM file - remote_cacrt = host.get_file_contents('/etc/ipa/ca.crt') + remote_cacrt = host.get_file_contents(paths.IPA_CA_CRT) self.log.debug('%s:/etc/ipa/ca.crt contents:\n%s', host, remote_cacrt) binary_cacrt = base64.b64decode(x509.strip_header(remote_cacrt)) @@ -344,7 +345,7 @@ class TestServerInstall(CALessBase): # Remove CA cert in /etc/pki/nssdb, in case of failed (un)install for host in self.get_all_hosts(): - self.master.run_command(['certutil', '-d', '/etc/pki/nssdb', '-D', + self.master.run_command(['certutil', '-d', paths.NSS_DB_DIR, '-D', '-n', 'External CA cert'], raiseonerr=False) @@ -768,11 +769,11 @@ class TestReplicaInstall(CALessBase): self.master.run_command(['ipa', 'host-del', replica.hostname], raiseonerr=False) - replica.run_command(['certutil', '-d', '/etc/pki/nssdb', '-D', + replica.run_command(['certutil', '-d', paths.NSS_DB_DIR, '-D', '-n', 'External CA cert'], raiseonerr=False) self.uninstall_server() - self.master.run_command(['certutil', '-d', '/etc/pki/nssdb', '-D', + self.master.run_command(['certutil', '-d', paths.NSS_DB_DIR, '-D', '-n', 'External CA cert'], raiseonerr=False) def test_no_certs(self): diff --git a/ipatests/test_integration/test_forced_client_reenrollment.py b/ipatests/test_integration/test_forced_client_reenrollment.py index cece522f8..ded1a2397 100644 --- a/ipatests/test_integration/test_forced_client_reenrollment.py +++ b/ipatests/test_integration/test_forced_client_reenrollment.py @@ -18,11 +18,12 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import os import subprocess +from ipaplatform.paths import paths from ipatests.test_integration.base import IntegrationTest from ipatests.test_integration import tasks -CLIENT_KEYTAB = '/etc/krb5.keytab' +CLIENT_KEYTAB = paths.KRB5_KEYTAB class TestForcedClientReenrollment(IntegrationTest): @@ -274,9 +275,9 @@ class TestForcedClientReenrollment(IntegrationTest): """ Put server's ip address at the top of resolv.conf """ - contents = client.get_file_contents('/etc/resolv.conf') + contents = client.get_file_contents(paths.RESOLV_CONF) nameserver = 'nameserver %s\n' % server.ip if not contents.startswith(nameserver): contents = nameserver + contents.replace(nameserver, '') - client.put_file_contents('/etc/resolv.conf', contents) + client.put_file_contents(paths.RESOLV_CONF, contents) diff --git a/ipatests/test_integration/test_legacy_clients.py b/ipatests/test_integration/test_legacy_clients.py index b7fbd0165..513664e50 100644 --- a/ipatests/test_integration/test_legacy_clients.py +++ b/ipatests/test_integration/test_legacy_clients.py @@ -21,6 +21,7 @@ import os import re import nose +from ipaplatform.paths import paths from ipatests.test_integration import tasks @@ -40,7 +41,7 @@ class BaseTestLegacyClient(object): '/etc/openldap/cacerts', '/etc/openldap/ldap.conf', '/etc/nsswitch.conf', - '/etc/sssd/sssd.conf'] + paths.SSSD_CONF] # Actual test classes need to override these attributes to set the expected # values on the UID and GID results, since this varies with the usage of the @@ -88,7 +89,7 @@ class BaseTestLegacyClient(object): advice_path]) # Restart SSHD to load new PAM configuration - self.legacy_client.run_command(['/sbin/service', 'sshd', 'restart']) + self.legacy_client.run_command([paths.SBIN_SERVICE, 'sshd', 'restart']) def clear_sssd_caches(self): tasks.clear_sssd_cache(self.master) |