Skip to content

Commit

Permalink
test: Handle PKI >= 11.5.0 not storing certs in CS.cfg
Browse files Browse the repository at this point in the history
Update the test to expect 0 results if the PKI version is
>= 11.5.0.

Fixes: #317

Signed-off-by: Rob Crittenden <[email protected]>
  • Loading branch information
rcritten committed Jan 12, 2024
1 parent e556edc commit 9a364d7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/test_dogtag_ca.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
# Copyright (C) 2019 FreeIPA Contributors see COPYING for license
#

import pki.util
from util import capture_results, CAInstance, KRAInstance
from base import BaseTest
from ipahealthcheck.core import config, constants
from ipahealthcheck.dogtag.plugin import registry
from ipahealthcheck.dogtag.ca import DogtagCertsConfigCheck
from unittest.mock import Mock, patch
import pytest

pki_version = pki.util.Version(pki.specification_version())


class mock_Cert:
Expand Down Expand Up @@ -43,6 +47,9 @@ class TestCACerts(BaseTest):
Mock(return_value=KRAInstance()),
}

@pytest.mark.skipif(
pki_version >= pki.util.Version("11.5.0"),
reason='Does not apply to PKI 11.5.0+')
@patch('ipahealthcheck.dogtag.ca.get_directive')
@patch('ipaserver.install.certs.CertDB')
def test_ca_certs_ok(self, mock_certdb, mock_directive):
Expand All @@ -64,13 +71,14 @@ def test_ca_certs_ok(self, mock_certdb, mock_directive):

self.results = capture_results(f)

assert len(self.results) == 6

for result in self.results.results:
assert result.result == constants.SUCCESS
assert result.source == 'ipahealthcheck.dogtag.ca'
assert result.check == 'DogtagCertsConfigCheck'

@pytest.mark.skipif(
pki_version >= pki.util.Version("11.5.0"),
reason='Does not apply to PKI 11.5.0+')
@patch('ipahealthcheck.dogtag.ca.get_directive')
@patch('ipaserver.install.certs.CertDB')
def test_cert_missing_from_file(self, mock_certdb, mock_directive):
Expand Down

0 comments on commit 9a364d7

Please sign in to comment.