From 3e8f550c29bb984a87309514d277683bf2e75012 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Wed, 17 Oct 2018 18:12:52 -0400 Subject: [PATCH] Add tests for ipa-cacert-manage install Some basic tests like re-loading a certificate, loading a PKCS#7 cert and bad cert handling. Signed-off-by: Rob Crittenden https://pagure.io/freeipa/issue/7579 Reviewed-By: Florence Blanc-Renaud --- ipatests/test_integration/test_commands.py | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/ipatests/test_integration/test_commands.py b/ipatests/test_integration/test_commands.py index 1aa1bb331..cfb2fa48d 100644 --- a/ipatests/test_integration/test_commands.py +++ b/ipatests/test_integration/test_commands.py @@ -27,6 +27,7 @@ from ipaplatform.paths import paths from ipatests.test_integration.base import IntegrationTest from ipatests.pytest_ipa.integration import tasks from ipatests.create_external_ca import ExternalCA +from ipatests.test_ipalib.test_x509 import good_pkcs7, badcert logger = logging.getLogger(__name__) @@ -460,3 +461,37 @@ class TestIPACommand(IntegrationTest): ['sudo', '-u', IPAAPI_USER, '--'] + cmd ) assert uid in result.stdout_text + + def test_ipa_cacert_manage_install(self): + # Re-install the IPA CA + self.master.run_command([ + paths.IPA_CACERT_MANAGE, + 'install', + paths.IPA_CA_CRT]) + + # Test a non-existent file + result = self.master.run_command([ + paths.IPA_CACERT_MANAGE, + 'install', + '/var/run/cert_not_found'], raiseonerr=False) + assert result.returncode == 1 + + cmd = self.master.run_command(['mktemp']) + filename = cmd.stdout_text.strip() + + for contents in (good_pkcs7,): + self.master.put_file_contents(filename, contents) + result = self.master.run_command([ + paths.IPA_CACERT_MANAGE, + 'install', + filename]) + + for contents in (badcert,): + self.master.put_file_contents(filename, contents) + result = self.master.run_command([ + paths.IPA_CACERT_MANAGE, + 'install', + filename], raiseonerr=False) + assert result.returncode == 1 + + self.master.run_command(['rm', '-f', filename])