From 5e51c31ad17b01be65e73b160460ad2446ad9f0e Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Feb 21 2019 22:38:15 +0000 Subject: 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 Reviewed-By: Florence Blanc-Renaud --- diff --git a/ipatests/test_integration/test_commands.py b/ipatests/test_integration/test_commands.py index acb722b..b172a6d 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.pytest_ipa.integration.create_external_ca import ExternalCA +from ipatests.test_ipalib.test_x509 import good_pkcs7, badcert logger = logging.getLogger(__name__) @@ -497,3 +498,37 @@ class TestIPACommand(IntegrationTest): ) assert result.returncode != 0 assert 'HBAC rule not found' in result.stderr_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])