Test for output being indented by default value if not stated implicitly.

Test checks whether output json-line string is indented by default value
if this value is not stated implicitly. Test compares healthcheck
produced json-like string with manually indented one.

Automates: 02272ff39d76f1412483c5e3289564c93d196a03
Signed-off-by: Michal Polovka <mpolovka@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
Michal Polovka
2020-04-03 08:32:20 -04:00
committed by Rob Crittenden
parent 26233c887e
commit f5f960ed2a
@@ -7,12 +7,12 @@ Tests to verify that the ipa-healthcheck scenarios
from __future__ import absolute_import
from ipatests.test_integration.base import IntegrationTest
from ipatests.pytest_ipa.integration import tasks
import json
from ipalib import api
from ipapython.ipaldap import realm_to_serverid
import json
from ipatests.pytest_ipa.integration import tasks
from ipatests.test_integration.base import IntegrationTest
HEALTHCHECK_LOG = "/var/log/ipa/healthcheck/healthcheck.log"
HEALTHCHECK_SYSTEMD_FILE = (
@@ -108,6 +108,7 @@ DEFAULT_PKI_KRA_CERTS = [
"auditSigningCert cert-pki-kra",
]
def run_healthcheck(host, source=None, check=None, output_type="json"):
"""
Run ipa-healthcheck on the remote host and return the result
@@ -505,6 +506,19 @@ class TestIpaHealthCheck(IntegrationTest):
assert check["result"] == "SUCCESS"
assert check["kw"]["key"] in SRV_RECORDS
def test_ipa_healthcheck_output_indent(self):
"""
This test case checks whether default (2) indentation is applied
to output without it being implicitly stated
"""
cmd = self.master.run_command(["ipa-healthcheck",
"--source",
"ipahealthcheck.meta.services"],
raiseonerr=False)
output_str = cmd.stdout_text
output_json = json.loads(output_str)
assert output_str == "{}\n".format(json.dumps(output_json, indent=2))
def test_ipa_healthcheck_remove(self):
"""
This testcase checks the removal of of healthcheck tool