From f5f960ed2ab08208b52260ab2dbe99da500ee04e Mon Sep 17 00:00:00 2001 From: Michal Polovka Date: Fri, 3 Apr 2020 09:02:03 +0200 Subject: [PATCH] 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 Reviewed-By: Rob Crittenden --- .../test_integration/test_ipahealthcheck.py | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/ipatests/test_integration/test_ipahealthcheck.py b/ipatests/test_integration/test_ipahealthcheck.py index 67aa10438..84c02dfd3 100644 --- a/ipatests/test_integration/test_ipahealthcheck.py +++ b/ipatests/test_integration/test_ipahealthcheck.py @@ -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