2013-10-22 13:00:18 -05:00
|
|
|
#
|
2017-09-08 01:52:38 -05:00
|
|
|
# Copyright (C) 2017 FreeIPA Contributors see COPYING for license
|
|
|
|
#
|
2013-10-22 13:00:18 -05:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2017-09-08 01:52:38 -05:00
|
|
|
|
2013-10-22 13:00:18 -05:00
|
|
|
import os
|
|
|
|
|
2017-03-20 05:34:17 -05:00
|
|
|
from ipatests.pytest_plugins.integration import tasks
|
2013-10-22 13:00:18 -05:00
|
|
|
from ipatests.test_integration.base import IntegrationTest
|
2017-09-08 01:52:38 -05:00
|
|
|
from ipatests.test_integration.create_external_ca import ExternalCA
|
2017-09-06 10:22:19 -05:00
|
|
|
from ipatests.util import collect_logs
|
2017-08-09 08:37:28 -05:00
|
|
|
|
|
|
|
|
2013-10-22 13:00:18 -05:00
|
|
|
class TestExternalCA(IntegrationTest):
|
|
|
|
"""
|
|
|
|
Test of FreeIPA server installation with exernal CA
|
|
|
|
"""
|
2017-09-06 10:22:19 -05:00
|
|
|
@collect_logs
|
2013-10-22 13:00:18 -05:00
|
|
|
def test_external_ca(self):
|
|
|
|
# Step 1 of ipa-server-install
|
|
|
|
self.master.run_command([
|
|
|
|
'ipa-server-install', '-U',
|
|
|
|
'-a', self.master.config.admin_password,
|
|
|
|
'-p', self.master.config.dirman_password,
|
|
|
|
'--setup-dns', '--no-forwarders',
|
2016-01-19 08:06:38 -06:00
|
|
|
'-n', self.master.domain.name,
|
|
|
|
'-r', self.master.domain.realm,
|
|
|
|
'--domain-level=%i' % self.master.config.domain_level,
|
2013-10-22 13:00:18 -05:00
|
|
|
'--external-ca'
|
|
|
|
])
|
|
|
|
|
2017-09-08 01:52:38 -05:00
|
|
|
test_dir = self.master.config.test_dir
|
2013-10-22 13:00:18 -05:00
|
|
|
|
2017-09-08 01:52:38 -05:00
|
|
|
# Get IPA CSR as bytes
|
|
|
|
ipa_csr = self.master.get_file_contents('/root/ipa.csr')
|
2013-10-22 13:00:18 -05:00
|
|
|
|
2017-09-08 01:52:38 -05:00
|
|
|
external_ca = ExternalCA()
|
|
|
|
# Create root CA
|
|
|
|
root_ca = external_ca.create_ca()
|
|
|
|
# Sign CSR
|
|
|
|
ipa_ca = external_ca.sign_csr(ipa_csr)
|
2013-10-22 13:00:18 -05:00
|
|
|
|
2017-09-08 01:52:38 -05:00
|
|
|
root_ca_fname = os.path.join(test_dir, 'root_ca.crt')
|
|
|
|
ipa_ca_fname = os.path.join(test_dir, 'ipa_ca.crt')
|
2013-10-22 13:00:18 -05:00
|
|
|
|
2017-09-08 01:52:38 -05:00
|
|
|
# Transport certificates (string > file) to master
|
|
|
|
self.master.put_file_contents(root_ca_fname, root_ca)
|
|
|
|
self.master.put_file_contents(ipa_ca_fname, ipa_ca)
|
2013-10-22 13:00:18 -05:00
|
|
|
|
|
|
|
# Step 2 of ipa-server-install
|
|
|
|
self.master.run_command([
|
|
|
|
'ipa-server-install',
|
|
|
|
'-a', self.master.config.admin_password,
|
|
|
|
'-p', self.master.config.dirman_password,
|
2017-09-08 01:52:38 -05:00
|
|
|
'--external-cert-file', ipa_ca_fname,
|
|
|
|
'--external-cert-file', root_ca_fname
|
2013-10-22 13:00:18 -05:00
|
|
|
])
|
|
|
|
|
|
|
|
# Make sure IPA server is working properly
|
|
|
|
tasks.kinit_admin(self.master)
|
|
|
|
result = self.master.run_command(['ipa', 'user-show', 'admin'])
|
|
|
|
assert 'User login: admin' in result.stdout_text
|