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

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