7e1b55
From 488ac7e3ba9f36d6b187687d120920d2d80d8b7f Mon Sep 17 00:00:00 2001
7e1b55
From: Michal Polovka <mpolovka@redhat.com>
7e1b55
Date: Tue, 10 Aug 2021 18:11:05 +0200
7e1b55
Subject: [PATCH] ipatests: test_ipahealthcheck: Verify permissions for
7e1b55
 /var/log/ files
7e1b55
7e1b55
Test if files in /var/log are being checked with ipahealthcheck.ipa.files source.
7e1b55
7e1b55
Resolves: https://pagure.io/freeipa/issue/8949
7e1b55
7e1b55
Signed-off-by: Michal Polovka <mpolovka@redhat.com>
7e1b55
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
7e1b55
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
7e1b55
---
7e1b55
 .../test_integration/test_ipahealthcheck.py   | 23 +++++++++++++++++++
7e1b55
 1 file changed, 23 insertions(+)
7e1b55
7e1b55
diff --git a/ipatests/test_integration/test_ipahealthcheck.py b/ipatests/test_integration/test_ipahealthcheck.py
7e1b55
index 36fe72be7..089793a2f 100644
7e1b55
--- a/ipatests/test_integration/test_ipahealthcheck.py
7e1b55
+++ b/ipatests/test_integration/test_ipahealthcheck.py
7e1b55
@@ -1227,6 +1227,29 @@ class TestIpaHealthCheck(IntegrationTest):
7e1b55
         )
7e1b55
         assert msg in cmd.stdout_text
7e1b55
 
7e1b55
+    def test_ipahealthcheck_verify_perms_for_source_files(self,
7e1b55
+                                                          modify_permissions):
7e1b55
+        """
7e1b55
+        This tests checks if files in /var/log are checked with ipa.files
7e1b55
+        source.
7e1b55
+        The test modifies permissions of ipainstall log file and checks the
7e1b55
+        response from healthcheck.
7e1b55
+
7e1b55
+        https://pagure.io/freeipa/issue/8949
7e1b55
+        """
7e1b55
+        modify_permissions(self.master, path=paths.IPASERVER_INSTALL_LOG,
7e1b55
+                           mode="0644")
7e1b55
+        returncode, data = run_healthcheck(
7e1b55
+            self.master, "ipahealthcheck.ipa.files", failures_only=True)
7e1b55
+
7e1b55
+        assert returncode == 1
7e1b55
+        assert len(data) == 1
7e1b55
+        assert data[0]["result"] == "WARNING"
7e1b55
+        assert data[0]["kw"]["path"] == paths.IPASERVER_INSTALL_LOG
7e1b55
+        assert data[0]["kw"]["type"] == "mode"
7e1b55
+        assert data[0]["kw"]["expected"] == "0600"
7e1b55
+
7e1b55
+
7e1b55
     @pytest.fixture
7e1b55
     def remove_healthcheck(self):
7e1b55
         """
7e1b55
-- 
7e1b55
2.31.1
7e1b55