Blame SOURCES/0018-Don-t-collect-the-CRLManager-role-if-the-CA-is-not-c.patch

531784
From a63d5ac05157e689e99494661240d43d131c0e91 Mon Sep 17 00:00:00 2001
531784
From: Rob Crittenden <rcritten@redhat.com>
531784
Date: Tue, 11 May 2021 13:19:41 -0400
531784
Subject: [PATCH] Don't collect the CRLManager role if the CA is not configured
531784
531784
This was raising a false positive in the IPA CA-less case.
531784
531784
https://github.com/freeipa/freeipa-healthcheck/issues/201
531784
531784
Signed-off-by: Rob Crittenden <rcritten@redhat.com>
531784
---
531784
 src/ipahealthcheck/ipa/roles.py |  2 ++
531784
 tests/test_ipa_roles.py         | 12 ++++++++++++
531784
 2 files changed, 14 insertions(+)
531784
531784
diff --git a/src/ipahealthcheck/ipa/roles.py b/src/ipahealthcheck/ipa/roles.py
531784
index 0ff2269..aac7b80 100644
531784
--- a/src/ipahealthcheck/ipa/roles.py
531784
+++ b/src/ipahealthcheck/ipa/roles.py
531784
@@ -25,6 +25,8 @@ class IPACRLManagerCheck(IPAPlugin):
531784
     """
531784
     @duration
531784
     def check(self):
531784
+        if not self.ca.is_configured():
531784
+            return
531784
         try:
531784
             enabled = self.ca.is_crlgen_enabled()
531784
         except AttributeError:
531784
diff --git a/tests/test_ipa_roles.py b/tests/test_ipa_roles.py
531784
index 21c0069..7c4a2d1 100644
531784
--- a/tests/test_ipa_roles.py
531784
+++ b/tests/test_ipa_roles.py
531784
@@ -48,6 +48,18 @@ class TestCRLManagerRole(BaseTest):
531784
         assert result.check == 'IPACRLManagerCheck'
531784
         assert result.kw.get('crlgen_enabled') is True
531784
 
531784
+    @patch('ipaserver.install.cainstance.CAInstance')
531784
+    def test_crlmanager_no_ca(self, mock_ca):
531784
+        """There should be no CRLManagerCheck without a CA"""
531784
+        mock_ca.return_value = CAInstance(False)
531784
+        framework = object()
531784
+        registry.initialize(framework, config.Config)
531784
+        f = IPACRLManagerCheck(registry)
531784
+
531784
+        self.results = capture_results(f)
531784
+
531784
+        assert len(self.results) == 0
531784
+
531784
 
531784
 class TestRenewalMaster(BaseTest):
531784
     def test_renewal_master_not_set(self):
531784
-- 
531784
2.31.1
531784