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

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