From 8a2e6ec3202ece070e6d9f529727ea89cec460f1 Mon Sep 17 00:00:00 2001 From: Antonio Torres Date: Mon, 8 Feb 2021 17:03:03 +0100 Subject: [PATCH] ipatests: add test for ipa-cacert-manage prune Add test for prune option of ipa-cacert-manage. After a certificate is installed, a jump in time is performed to a date where the certificate is expired, and then it is pruned. Related: https://pagure.io/freeipa/issue/7404 Signed-off-by: Antonio Torres Reviewed-By: Rob Crittenden --- ipatests/test_integration/test_commands.py | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ipatests/test_integration/test_commands.py b/ipatests/test_integration/test_commands.py index 45f642bf2..df3f862b5 100644 --- a/ipatests/test_integration/test_commands.py +++ b/ipatests/test_integration/test_commands.py @@ -1465,3 +1465,26 @@ class TestIPACommand(IntegrationTest): if 'invalid option' not in nologin.stderr_text: assert 'This account is currently not available' in \ result.stdout_text + + def test_ipa_cacert_manage_prune(self): + """Test for ipa-cacert-manage prune""" + + certfile = os.path.join(self.master.config.test_dir, 'cert.pem') + self.master.put_file_contents(certfile, isrgrootx1) + result = self.master.run_command( + [paths.IPA_CACERT_MANAGE, 'install', certfile]) + + certs_before_prune = self.master.run_command( + [paths.IPA_CACERT_MANAGE, 'list'], raiseonerr=False + ).stdout_text + + assert isrgrootx1_nick in certs_before_prune + + # Jump in time to make sure the cert is expired + self.master.run_command(['date', '-s', '+15Years']) + result = self.master.run_command( + [paths.IPA_CACERT_MANAGE, 'prune'], raiseonerr=False + ).stdout_text + self.master.run_command(['date', '-s', '-15Years']) + + assert isrgrootx1_nick in result