Blob Blame History Raw
From 488ac7e3ba9f36d6b187687d120920d2d80d8b7f Mon Sep 17 00:00:00 2001
From: Michal Polovka <mpolovka@redhat.com>
Date: Tue, 10 Aug 2021 18:11:05 +0200
Subject: [PATCH] ipatests: test_ipahealthcheck: Verify permissions for
 /var/log/ files

Test if files in /var/log are being checked with ipahealthcheck.ipa.files source.

Resolves: https://pagure.io/freeipa/issue/8949

Signed-off-by: Michal Polovka <mpolovka@redhat.com>
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
---
 .../test_integration/test_ipahealthcheck.py   | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/ipatests/test_integration/test_ipahealthcheck.py b/ipatests/test_integration/test_ipahealthcheck.py
index 36fe72be7..089793a2f 100644
--- a/ipatests/test_integration/test_ipahealthcheck.py
+++ b/ipatests/test_integration/test_ipahealthcheck.py
@@ -1227,6 +1227,29 @@ class TestIpaHealthCheck(IntegrationTest):
         )
         assert msg in cmd.stdout_text
 
+    def test_ipahealthcheck_verify_perms_for_source_files(self,
+                                                          modify_permissions):
+        """
+        This tests checks if files in /var/log are checked with ipa.files
+        source.
+        The test modifies permissions of ipainstall log file and checks the
+        response from healthcheck.
+
+        https://pagure.io/freeipa/issue/8949
+        """
+        modify_permissions(self.master, path=paths.IPASERVER_INSTALL_LOG,
+                           mode="0644")
+        returncode, data = run_healthcheck(
+            self.master, "ipahealthcheck.ipa.files", failures_only=True)
+
+        assert returncode == 1
+        assert len(data) == 1
+        assert data[0]["result"] == "WARNING"
+        assert data[0]["kw"]["path"] == paths.IPASERVER_INSTALL_LOG
+        assert data[0]["kw"]["type"] == "mode"
+        assert data[0]["kw"]["expected"] == "0600"
+
+
     @pytest.fixture
     def remove_healthcheck(self):
         """
-- 
2.31.1