From 01f27e292211e949c1ee2de727a203503ddfffa8 Mon Sep 17 00:00:00 2001 From: François Cami Date: Jun 08 2020 20:58:37 +0000 Subject: tasks.py: add krb5_trace to create_active_user and kinit_as_user The test test_adtrust_install.py::TestIpaAdTrustInstall::test_add_agent_not_allowed sometimes fails when resetting a user's password using kinit in create_active_user. Add krb5_trace (default: False) to create_active_user and kinit_as_user. Related-to: https://pagure.io/freeipa/issue/8353 Related-to: https://pagure.io/freeipa/issue/8271 Signed-off-by: François Cami Reviewed-By: Michal Polovka Reviewed-By: Robbie Harwood --- diff --git a/ipatests/pytest_ipa/integration/tasks.py b/ipatests/pytest_ipa/integration/tasks.py index c54e1f5..f240aaa 100755 --- a/ipatests/pytest_ipa/integration/tasks.py +++ b/ipatests/pytest_ipa/integration/tasks.py @@ -1920,7 +1920,7 @@ def ldapsearch_dm(host, base, ldap_args, scope='sub', **kwargs): def create_temp_file(host, directory=None, create_file=True): - """Creates temproray file using mktemp.""" + """Creates temporary file using mktemp.""" cmd = ['mktemp'] if create_file is False: cmd += ['--dry-run'] @@ -1930,15 +1930,22 @@ def create_temp_file(host, directory=None, create_file=True): def create_active_user(host, login, password, first='test', last='user', - extra_args=()): + extra_args=(), krb5_trace=False): """Create user and do login to set password""" temp_password = 'Secret456789' kinit_admin(host) user_add(host, login, first=first, last=last, extra_args=extra_args, password=temp_password) - host.run_command( - ['kinit', login], - stdin_text='{0}\n{1}\n{1}\n'.format(temp_password, password)) + if krb5_trace: + host.run_command( + "KRB5_TRACE=/dev/stdout kinit %s" % login, + stdin_text='{0}\n{1}\n{1}\n'.format(temp_password, password) + ) + else: + host.run_command( + ['kinit', login], + stdin_text='{0}\n{1}\n{1}\n'.format(temp_password, password) + ) kdestroy_all(host) @@ -1960,8 +1967,14 @@ def run_command_as_user(host, user, command, *args, **kwargs): return host.run_command(command, *args, **kwargs) -def kinit_as_user(host, user, password): - host.run_command(['kinit', user], stdin_text=password + '\n') +def kinit_as_user(host, user, password, krb5_trace=False): + if krb5_trace: + host.run_command( + "KRB5_TRACE=/dev/stdout kinit %s" % user, + stdin_text='{0}\n'.format(password) + ) + else: + host.run_command(['kinit', user], stdin_text='{0}\n'.format(password)) KeyEntry = collections.namedtuple('KeyEntry',