ipatests: return result of kinit_as_user, pass raiseonerr parameter

Similar to kinit_admin, this allows to check for error values returned
by kinit.

Reviewed-By: Anuja More <amore@redhat.com>
This commit is contained in:
Sergey Orlov committed 2021-03-18 13:41:49 +01:00
1 parent fb107b9180
commit 38c897f946
1 file changed
+8 -3
+8 -3
View File
@@ -2118,7 +2118,7 @@ def run_command_as_user(host, user, command, *args, **kwargs):
return host.run_command(command, *args, **kwargs)
def kinit_as_user(host, user, password, krb5_trace=False):
def kinit_as_user(host, user, password, krb5_trace=False, raiseonerr=True):
"""Launch kinit as user on host.
If krb5_trace, then set KRB5_TRACE=/dev/stdout and collect
/var/lib/sss/pubconf/kdcinfo.$REALM
@@ -2144,9 +2144,14 @@ def kinit_as_user(host, user, password, krb5_trace=False):
# Retrieve kdc.$REALM after the password change, just in case SSSD
# domain status flipped to online during the password change.
get_kdcinfo(host)
assert result.returncode == 0
if raiseonerr:
assert result.returncode == 0
return result
else:
host.run_command(['kinit', user], stdin_text='{0}\n'.format(password))
return host.run_command(
['kinit', user],
stdin_text='{0}\n'.format(password),
raiseonerr=raiseonerr)
def get_kdcinfo(host):