mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Create helper function to upload to temp file
upload_temp_contents() generates a temporary file on the remote side and uploads content to that temporary file. The file name is returned. Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
@@ -1313,6 +1313,20 @@ def run_certutil(host, args, reqdir, dbtype=None,
|
||||
stdin_text=stdin)
|
||||
|
||||
|
||||
def upload_temp_contents(host, contents, encoding='utf-8'):
|
||||
"""Upload contents to a temporary file
|
||||
|
||||
:param host: Remote host instance
|
||||
:param contents: file content (str, bytes)
|
||||
:param encoding: file encoding
|
||||
:return: Temporary file name
|
||||
"""
|
||||
result = host.run_command(['mktemp'])
|
||||
tmpname = result.stdout_text.strip()
|
||||
host.put_file_contents(tmpname, contents, encoding=encoding)
|
||||
return tmpname
|
||||
|
||||
|
||||
def assert_error(result, stderr_text, returncode=None):
|
||||
"Assert that `result` command failed and its stderr contains `stderr_text`"
|
||||
assert stderr_text in result.stderr_text, result.stderr_text
|
||||
|
||||
Reference in New Issue
Block a user