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:
Stanislav Levin authored and Rob Crittenden committed 2021-10-28 16:29:01 -04:00
1 parent 5856f10733
commit 18456e71a1
2 files changed
+16 -7

No files matched your search

+4 -2
View File
@@ -2099,13 +2099,15 @@ def ldapsearch_dm(host, base, ldap_args, scope='sub', **kwargs):
return host.run_command(args, **kwargs)
def create_temp_file(host, directory=None, create_file=True):
"""Creates temporary file using mktemp."""
def create_temp_file(host, directory=None, suffix=None, create_file=True):
"""Creates temporary file using mktemp. See `man 1 mktemp`."""
cmd = ['mktemp']
if create_file is False:
cmd += ['--dry-run']
if directory is not None:
cmd += ['-p', directory]
if suffix is not None:
cmd.extend(["--suffix", suffix])
return host.run_command(cmd).stdout_text.strip()