mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-25 08:21:05 -06:00
Test that ipa-healthcheck human output translates error strings
The code rather than the string was being displayed in human output for non-SUCCESS messages. Verify that in case of an error the right output will be present. https://bugzilla.redhat.com/show_bug.cgi?id=1752849 Reviewed-By: Mohammad Rizwan Yusuf <myusuf@redhat.com> Reviewed-By: Sumedh Sidhaye <ssidhaye@redhat.com> Reviewed-By: Stanislav Levin <slev@altlinux.org> Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
parent
452ef8cc76
commit
4a3b7baed7
@ -109,11 +109,15 @@ DEFAULT_PKI_KRA_CERTS = [
|
||||
]
|
||||
|
||||
|
||||
def run_healthcheck(host, source=None, check=None):
|
||||
def run_healthcheck(host, source=None, check=None, output_type="json"):
|
||||
"""
|
||||
Run ipa-healthcheck on the remote host and return the result
|
||||
|
||||
Returns: the tuple returncode, json (if any)
|
||||
Returns: the tuple returncode, output
|
||||
|
||||
output is:
|
||||
json data if output_type == "json"
|
||||
stdout if output_type == "human"
|
||||
"""
|
||||
data = None
|
||||
cmd = ["ipa-healthcheck"]
|
||||
@ -125,10 +129,16 @@ def run_healthcheck(host, source=None, check=None):
|
||||
cmd.append("--check")
|
||||
cmd.append(check)
|
||||
|
||||
cmd.append("--output-type")
|
||||
cmd.append(output_type)
|
||||
|
||||
result = host.run_command(cmd, raiseonerr=False)
|
||||
|
||||
if result.stdout_text:
|
||||
if output_type == "json":
|
||||
data = json.loads(result.stdout_text)
|
||||
else:
|
||||
data = result.stdout_text.strip()
|
||||
|
||||
return result.returncode, data
|
||||
|
||||
@ -168,6 +178,28 @@ class TestIpaHealthCheck(IntegrationTest):
|
||||
for source in sources:
|
||||
assert source in result.stdout_text
|
||||
|
||||
def test_human_output(self):
|
||||
"""
|
||||
Test that in human output the severity value is correct
|
||||
|
||||
Only the SUCCESS (0) value was being translated, otherwise
|
||||
the numeric value was being shown (BZ 1752849)
|
||||
"""
|
||||
self.master.run_command(["systemctl", "stop", "sssd"])
|
||||
try:
|
||||
returncode, output = run_healthcheck(
|
||||
self.master,
|
||||
"ipahealthcheck.meta.services",
|
||||
"sssd",
|
||||
"human",
|
||||
)
|
||||
finally:
|
||||
self.master.run_command(["systemctl", "start", "sssd"])
|
||||
|
||||
assert returncode == 1
|
||||
assert output == \
|
||||
"ERROR: ipahealthcheck.meta.services.sssd: sssd: not running"
|
||||
|
||||
def test_dogtag_ca_check_exists(self):
|
||||
"""
|
||||
Testcase to verify checks available in
|
||||
|
Loading…
Reference in New Issue
Block a user