c8cd81
From c55185d3dc3c6cd2ffebab77fbf8caa40a32bcd1 Mon Sep 17 00:00:00 2001
c8cd81
From: Erik <ebelko@redhat.com>
c8cd81
Date: Mon, 18 Jul 2022 11:59:24 +0200
c8cd81
Subject: [PATCH] ipatests: healthcheck: test if system is FIPS enabled
c8cd81
c8cd81
Test if FIPS is enabled and the check exists.
c8cd81
c8cd81
Related: https://pagure.io/freeipa/issue/8951
c8cd81
c8cd81
Signed-off-by: Erik Belko <ebelko@redhat.com>
c8cd81
Reviewed-By: Michal Polovka <mpolovka@redhat.com>
c8cd81
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
c8cd81
---
c8cd81
 .../test_integration/test_ipahealthcheck.py   | 25 +++++++++++++++++++
c8cd81
 1 file changed, 25 insertions(+)
c8cd81
c8cd81
diff --git a/ipatests/test_integration/test_ipahealthcheck.py b/ipatests/test_integration/test_ipahealthcheck.py
c8cd81
index 23af09f3a7eaa8012e7a898ce6a534d1fad45323..a0c85f79e6e84f9e63072c6d70276480e4af97ad 100644
c8cd81
--- a/ipatests/test_integration/test_ipahealthcheck.py
c8cd81
+++ b/ipatests/test_integration/test_ipahealthcheck.py
c8cd81
@@ -340,6 +340,31 @@ class TestIpaHealthCheck(IntegrationTest):
c8cd81
         assert returncode == 0
c8cd81
         assert output == "No issues found."
c8cd81
 
c8cd81
+    def test_ipa_healthcheck_fips_enabled(self):
c8cd81
+        """
c8cd81
+        Test if FIPS is enabled and the check exists.
c8cd81
+
c8cd81
+        https://pagure.io/freeipa/issue/8951
c8cd81
+        """
c8cd81
+        returncode, check = run_healthcheck(self.master,
c8cd81
+                                            source="ipahealthcheck.meta.core",
c8cd81
+                                            check="MetaCheck",
c8cd81
+                                            output_type="json",
c8cd81
+                                            failures_only=False)
c8cd81
+        assert returncode == 0
c8cd81
+
c8cd81
+        cmd = self.master.run_command(['fips-mode-setup', '--is-enabled'],
c8cd81
+                                      raiseonerr=False)
c8cd81
+        returncode = cmd.returncode
c8cd81
+
c8cd81
+        # If this produces IndexError, the check does not exist
c8cd81
+        if check[0]["kw"]["fips"] == "disabled":
c8cd81
+            assert returncode == 2
c8cd81
+        elif check[0]["kw"]["fips"] == "enabled":
c8cd81
+            assert returncode == 0
c8cd81
+        else:
c8cd81
+            assert returncode == 1
c8cd81
+
c8cd81
     def test_ipa_healthcheck_after_certupdate(self):
c8cd81
         """
c8cd81
         Verify that ipa-certupdate hasn't messed up tracking
c8cd81
-- 
c8cd81
2.37.2
c8cd81