From c7712c17f3e92a29c4ca55a29fe210abbc2adc58 Mon Sep 17 00:00:00 2001 From: Florence Blanc-Renaud Date: May 17 2019 11:28:39 +0000 Subject: ipatests: add integration test checking the files mode The test runs rpm -V in order to check that the file permissions are consistent with the expectations set in the spec file. The file mode, owner and group are checked. Related to https://pagure.io/freeipa/issue/7934 Reviewed-By: Rob Crittenden Reviewed-By: Christian Heimes Reviewed-By: Christian Heimes --- diff --git a/ipatests/test_integration/test_installation.py b/ipatests/test_integration/test_installation.py index f5287ff..e09e9f2 100644 --- a/ipatests/test_integration/test_installation.py +++ b/ipatests/test_integration/test_installation.py @@ -10,8 +10,11 @@ installed. from __future__ import absolute_import import os +import re + import pytest from ipalib.constants import DOMAIN_LEVEL_0 +import ipaplatform from ipaplatform.constants import constants from ipaplatform.paths import paths from ipatests.pytest_ipa.integration.env_config import get_global_config @@ -404,6 +407,58 @@ class TestInstallMaster(IntegrationTest): exp_str = ("ipa: ERROR: No YubiKey found") assert exp_str in cmd.stderr_text + def test_file_permissions(self): + args = [ + "rpm", "-V", + "python3-ipaclient", + "python3-ipalib", + "python3-ipaserver", + "python2-ipaclient", + "python2-ipalib", + "python2-ipaserver" + ] + + if ipaplatform.NAME == 'fedora': + args.extend([ + "freeipa-client", + "freeipa-client-common", + "freeipa-common", + "freeipa-server", + "freeipa-server-common", + "freeipa-server-dns", + "freeipa-server-trust-ad" + ]) + else: + args.extend([ + "ipa-client", + "ipa-client-common", + "ipa-common", + "ipa-server", + "ipa-server-common", + "ipa-server-dns" + ]) + + result = self.master.run_command(args, raiseonerr=False) + if result.returncode != 0: + # Check the mode errors + mode_warnings = re.findall( + r"^.M....... [cdglr ]+ (?P.*)$", + result.stdout_text, re.MULTILINE) + msg = "rpm -V found mode issues for the following files: {}" + assert mode_warnings == [], msg.format(mode_warnings) + # Check the owner errors + user_warnings = re.findall( + r"^.....U... [cdglr ]+ (?P.*)$", + result.stdout_text, re.MULTILINE) + msg = "rpm -V found ownership issues for the following files: {}" + assert user_warnings == [], msg.format(user_warnings) + # Check the group errors + group_warnings = re.findall( + r"^......G.. [cdglr ]+ (?P.*)$", + result.stdout_text, re.MULTILINE) + msg = "rpm -V found group issues for the following files: {}" + assert group_warnings == [], msg.format(group_warnings) + class TestInstallMasterKRA(IntegrationTest):