From 4e3a2bd6bff79c17bc439555dcf41a11d0569e6f Mon Sep 17 00:00:00 2001 From: sumenon Date: Tue, 10 Sep 2019 17:08:38 +0530 Subject: [PATCH] ipatests: check that ipa-healthcheck warns if no dna range is set Added testcase to verify that ipa-healthcheck tool displays a warning if no DNS range is set. It previously just reported at the SUCCESS level that no range was set. Issue: freeipa/freeipa-healthcheck#60 Reviewed-By: Rob Crittenden Reviewed-By: Francois Cami --- .../test_integration/test_ipahealthcheck.py | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/ipatests/test_integration/test_ipahealthcheck.py b/ipatests/test_integration/test_ipahealthcheck.py index 177561b41..9b2f3e9a8 100644 --- a/ipatests/test_integration/test_ipahealthcheck.py +++ b/ipatests/test_integration/test_ipahealthcheck.py @@ -413,6 +413,82 @@ class TestIpaHealthCheck(IntegrationTest): assert check["kw"]["key"] == "crl_manager" assert check["kw"]["crlgen_enabled"] is False + def test_ipa_healthcheck_dna_plugin_returns_warning_pagure_issue_60(self): + """ + This testcase checks that the status for IPADNARangeCheck on replica + changes from WARNING to SUCCESS when user is added on the replica + as the DNA range is set. + Issue: freeipa/freeipa-healthcheck#60 + """ + self.master.run_command( + [ + "ipa-healthcheck", + "--source", + "ipahealthcheck.ipa.dna", + "--check", + "IPADNARangeCheck", + "--output-file", + HEALTHCHECK_OUTPUT_FILE, + ], + raiseonerr=False, + ) + contents = self.master.get_file_contents( + HEALTHCHECK_OUTPUT_FILE, encoding="utf-8" + ) + data = json.loads(contents) + for check in data: + assert check["result"] == "SUCCESS" + # Install ipa-healthcheck rpm on replica + tasks.install_packages(self.replicas[0], HEALTHCHECK_PKG) + self.replicas[0].run_command( + [ + "ipa-healthcheck", + "--source", + "ipahealthcheck.ipa.dna", + "--check", + "IPADNARangeCheck", + "--output-file", + HEALTHCHECK_OUTPUT_FILE, + ], + raiseonerr=False, + ) + contents = self.replicas[0].get_file_contents( + HEALTHCHECK_OUTPUT_FILE, encoding="utf-8" + ) + data = json.loads(contents) + for check in data: + assert check["result"] == "WARNING" + assert ( + check["kw"]["msg"] == "No DNA range defined. If no masters " + "define a range then users and groups cannot be created." + ) + + # Now kinit as admin and add a user on replica which will create a + # DNA configuration. + tasks.kinit_admin(self.replicas[0]) + tasks.user_add( + self.replicas[0], 'ipauser1', first='Test', last='User', + ) + # Now run the ipa-healthcheck command again + self.replicas[0].run_command( + [ + "ipa-healthcheck", + "--source", + "ipahealthcheck.ipa.dna", + "--check", + "IPADNARangeCheck", + "--output-file", + HEALTHCHECK_OUTPUT_FILE, + ], + raiseonerr=False, + ) + contents = self.replicas[0].get_file_contents( + HEALTHCHECK_OUTPUT_FILE, encoding="utf-8" + ) + data = json.loads(contents) + for check in data: + assert check["result"] == "SUCCESS" + def test_ipa_healthcheck_remove(self): """ This testcase checks the removal of of healthcheck tool