mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipatests: TestMultipleExternalCA: Create tempfiles on remote host
Previously, `test_master_install_ca1` and `test_master_install_ca2` attempt to create tempdirs on local host and later write some content into the returned paths on remote host. This fails if a remote host is a local one. The existent `create_temp_file` function has been extended to support `suffix` option of `mktemp`. Fixes: https://pagure.io/freeipa/issue/9013 Signed-off-by: Stanislav Levin <slev@altlinux.org> Reviewed-By: Mohammad Rizwan <myusuf@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
parent
5856f10733
commit
18456e71a1
@ -2099,13 +2099,15 @@ def ldapsearch_dm(host, base, ldap_args, scope='sub', **kwargs):
|
|||||||
return host.run_command(args, **kwargs)
|
return host.run_command(args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def create_temp_file(host, directory=None, create_file=True):
|
def create_temp_file(host, directory=None, suffix=None, create_file=True):
|
||||||
"""Creates temporary file using mktemp."""
|
"""Creates temporary file using mktemp. See `man 1 mktemp`."""
|
||||||
cmd = ['mktemp']
|
cmd = ['mktemp']
|
||||||
if create_file is False:
|
if create_file is False:
|
||||||
cmd += ['--dry-run']
|
cmd += ['--dry-run']
|
||||||
if directory is not None:
|
if directory is not None:
|
||||||
cmd += ['-p', directory]
|
cmd += ['-p', directory]
|
||||||
|
if suffix is not None:
|
||||||
|
cmd.extend(["--suffix", suffix])
|
||||||
return host.run_command(cmd).stdout_text.strip()
|
return host.run_command(cmd).stdout_text.strip()
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ from __future__ import absolute_import
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import tempfile
|
|
||||||
|
|
||||||
from cryptography import x509
|
from cryptography import x509
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
@ -464,8 +463,12 @@ class TestMultipleExternalCA(IntegrationTest):
|
|||||||
def test_master_install_ca1(self):
|
def test_master_install_ca1(self):
|
||||||
install_server_external_ca_step1(self.master)
|
install_server_external_ca_step1(self.master)
|
||||||
# Sign CA, transport it to the host and get ipa a root ca paths.
|
# Sign CA, transport it to the host and get ipa a root ca paths.
|
||||||
root_ca_fname1 = tempfile.mkdtemp(suffix='root_ca.crt', dir=paths.TMP)
|
root_ca_fname1 = tasks.create_temp_file(
|
||||||
ipa_ca_fname1 = tempfile.mkdtemp(suffix='ipa_ca.crt', dir=paths.TMP)
|
self.master, directory=paths.TMP, suffix="root_ca.crt"
|
||||||
|
)
|
||||||
|
ipa_ca_fname1 = tasks.create_temp_file(
|
||||||
|
self.master, directory=paths.TMP, suffix="ipa_ca.crt"
|
||||||
|
)
|
||||||
|
|
||||||
ipa_csr = self.master.get_file_contents(paths.ROOT_IPA_CSR)
|
ipa_csr = self.master.get_file_contents(paths.ROOT_IPA_CSR)
|
||||||
|
|
||||||
@ -485,8 +488,12 @@ class TestMultipleExternalCA(IntegrationTest):
|
|||||||
assert "CN=RootCA1" in result.stdout_text
|
assert "CN=RootCA1" in result.stdout_text
|
||||||
|
|
||||||
def test_master_install_ca2(self):
|
def test_master_install_ca2(self):
|
||||||
root_ca_fname2 = tempfile.mkdtemp(suffix='root_ca.crt', dir=paths.TMP)
|
root_ca_fname2 = tasks.create_temp_file(
|
||||||
ipa_ca_fname2 = tempfile.mkdtemp(suffix='ipa_ca.crt', dir=paths.TMP)
|
self.master, directory=paths.TMP, suffix="root_ca.crt"
|
||||||
|
)
|
||||||
|
ipa_ca_fname2 = tasks.create_temp_file(
|
||||||
|
self.master, directory=paths.TMP, suffix="ipa_ca.crt"
|
||||||
|
)
|
||||||
|
|
||||||
self.master.run_command([
|
self.master.run_command([
|
||||||
paths.IPA_CACERT_MANAGE, 'renew', '--external-ca'])
|
paths.IPA_CACERT_MANAGE, 'renew', '--external-ca'])
|
||||||
|
Loading…
Reference in New Issue
Block a user