ipatests: ipahealthcheck tests to check change in permission of ipaserver log files

This testscase checks that when permission of
ipaserver-upgrade.log
file is changed healtcheck tool reports the correct warning message.

Signed-off-by: Sudhir Menon <sumenon@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
Sudhir Menon 2022-05-14 19:10:27 +05:30 committed by Florence Blanc-Renaud
parent d5e4e572ff
commit aa1105b64d

View File

@ -1294,6 +1294,23 @@ class TestIpaHealthCheck(IntegrationTest):
)
assert msg in cmd.stdout_text
def modify_perms_run_healthcheck(self, filename, modify_permissions,
expected_permissions):
"""
Modify the ipa logfile permissions and run
healthcheck command to check the status.
"""
modify_permissions(self.master, path=filename, 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"] == filename
assert data[0]["kw"]["type"] == "mode"
assert data[0]["kw"]["expected"] == expected_permissions
def test_ipahealthcheck_verify_perms_for_source_files(self,
modify_permissions):
"""
@ -1301,21 +1318,26 @@ class TestIpaHealthCheck(IntegrationTest):
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"
self.modify_perms_run_healthcheck(
paths.IPASERVER_INSTALL_LOG, modify_permissions,
expected_permissions="0600"
)
def test_ipahealthcheck_verify_perms_upgrade_log_file(self,
modify_permissions):
"""
This testcase creates /var/log/ipaupgrade.log file.
Once the file is generated the permissions are modified
to check that correct status message is displayed
by healthcheck tool
"""
self.master.run_command(["touch", paths.IPAUPGRADE_LOG])
self.modify_perms_run_healthcheck(
paths.IPAUPGRADE_LOG, modify_permissions,
expected_permissions="0600"
)
@pytest.fixture
def remove_healthcheck(self):