From 405dcc6becfca504dce7e06c6f0849a9c06df4c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= Date: Wed, 14 Aug 2019 15:37:53 +0200 Subject: [PATCH] ipatests: check that ipa-client-automount restores nsswitch.conf at uninstall time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check that using ipa-client-install, ipa-client-automount --no-ssd, then uninstalling both properly restores nsswitch.conf sequentially. Related-to:: https://pagure.io/freeipa/issue/8038 Signed-off-by: François Cami Reviewed-By: Francois Cami Reviewed-By: Rob Crittenden --- ipatests/prci_definitions/nightly_f29.yaml | 12 ++++ ipatests/prci_definitions/nightly_master.yaml | 12 ++++ .../prci_definitions/nightly_rawhide.yaml | 12 ++++ ipatests/test_integration/test_nfs.py | 72 +++++++++++++++++++ 4 files changed, 108 insertions(+) diff --git a/ipatests/prci_definitions/nightly_f29.yaml b/ipatests/prci_definitions/nightly_f29.yaml index 79c0b0e98..f64466955 100644 --- a/ipatests/prci_definitions/nightly_f29.yaml +++ b/ipatests/prci_definitions/nightly_f29.yaml @@ -1257,6 +1257,18 @@ jobs: timeout: 9000 topology: *master_3client + fedora-29/nfs_nsswitch_restore: + requires: [fedora-29/build] + priority: 50 + job: + class: RunPytest + args: + build_url: '{fedora-29/build_url}' + test_suite: test_integration/test_nfs.py::TestIpaClientAutomountFileRestore + template: *ci-master-f29 + timeout: 3600 + topology: *master_3client + fedora-29/mask: requires: [fedora-29/build] priority: 50 diff --git a/ipatests/prci_definitions/nightly_master.yaml b/ipatests/prci_definitions/nightly_master.yaml index ddc31a680..8922a25d4 100644 --- a/ipatests/prci_definitions/nightly_master.yaml +++ b/ipatests/prci_definitions/nightly_master.yaml @@ -1257,6 +1257,18 @@ jobs: timeout: 9000 topology: *master_3client + fedora-30/nfs_nsswitch_restore: + requires: [fedora-30/build] + priority: 50 + job: + class: RunPytest + args: + build_url: '{fedora-30/build_url}' + test_suite: test_integration/test_nfs.py::TestIpaClientAutomountFileRestore + template: *ci-master-f30 + timeout: 3600 + topology: *master_3client + fedora-30/mask: requires: [fedora-30/build] priority: 50 diff --git a/ipatests/prci_definitions/nightly_rawhide.yaml b/ipatests/prci_definitions/nightly_rawhide.yaml index fde6b8122..40c7508be 100644 --- a/ipatests/prci_definitions/nightly_rawhide.yaml +++ b/ipatests/prci_definitions/nightly_rawhide.yaml @@ -1269,6 +1269,18 @@ jobs: timeout: 9000 topology: *master_3client + fedora-rawhide/nfs_nsswitch_restore: + requires: [fedora-rawhide/build] + priority: 50 + job: + class: RunPytest + args: + build_url: '{fedora-rawhide/build_url}' + test_suite: test_integration/test_nfs.py::TestIpaClientAutomountFileRestore + template: *ci-master-frawhide + timeout: 9000 + topology: *master_3client + fedora-rawhide/automember: requires: [fedora-rawhide/build] priority: 50 diff --git a/ipatests/test_integration/test_nfs.py b/ipatests/test_integration/test_nfs.py index adfc19f04..0e1ef6af7 100644 --- a/ipatests/test_integration/test_nfs.py +++ b/ipatests/test_integration/test_nfs.py @@ -15,6 +15,7 @@ from __future__ import absolute_import +import pytest import os import re import time @@ -258,3 +259,74 @@ class TestNFS(IntegrationTest): time.sleep(WAIT_AFTER_UNINSTALL) self.cleanup() + + +class TestIpaClientAutomountFileRestore(IntegrationTest): + + num_clients = 1 + topology = 'line' + + @classmethod + def install(cls, mh): + tasks.install_master(cls.master, setup_dns=True) + + def teardown_method(self, method): + tasks.uninstall_client(self.clients[0]) + + def nsswitch_backup_restore( + self, + no_sssd=False, + ): + + # In order to get a more pure sum, one that ignores the Generated + # header and any white space we have to do a bit of work... + sha256nsswitch_cmd = \ + 'egrep -v "Generated|^$" /etc/nsswitch.conf | sed "s/\\s//g" ' \ + '| sort | sha256sum' + + cmd = self.clients[0].run_command(sha256nsswitch_cmd) + orig_sha256 = cmd.stdout_text + + grep_automount_command = \ + "grep automount /etc/nsswitch.conf | cut -d: -f2" + + tasks.install_client(self.master, self.clients[0]) + cmd = self.clients[0].run_command(grep_automount_command) + after_ipa_client_install = cmd.stdout_text.split() + + if no_sssd: + ipa_client_automount_command = [ + "ipa-client-automount", "--no-sssd", "-U" + ] + else: + ipa_client_automount_command = [ + "ipa-client-automount", "-U" + ] + self.clients[0].run_command(ipa_client_automount_command) + cmd = self.clients[0].run_command(grep_automount_command) + after_ipa_client_automount = cmd.stdout_text.split() + if no_sssd: + assert after_ipa_client_automount == ['files', 'ldap'] + else: + assert after_ipa_client_automount == ['sss', 'files'] + + cmd = self.clients[0].run_command(grep_automount_command) + assert cmd.stdout_text.split() == after_ipa_client_automount + + self.clients[0].run_command([ + "ipa-client-automount", "--uninstall", "-U" + ]) + + cmd = self.clients[0].run_command(grep_automount_command) + assert cmd.stdout_text.split() == after_ipa_client_install + + tasks.uninstall_client(self.clients[0]) + cmd = self.clients[0].run_command(sha256nsswitch_cmd) + assert cmd.stdout_text == orig_sha256 + + @pytest.mark.xfail(reason='freeipa ticket 8054', strict=True) + def test_nsswitch_backup_restore_sssd(self): + self.nsswitch_backup_restore() + + def test_nsswitch_backup_restore_no_sssd(self): + self.nsswitch_backup_restore(no_sssd=True)