mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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 <fcami@redhat.com> Reviewed-By: Michal Polovka <mpolovka@redhat.com> Reviewed-By: Robbie Harwood <rharwood@redhat.com>
This commit is contained in:
parent
be47ec9799
commit
e7319f628f
@ -1920,7 +1920,7 @@ def ldapsearch_dm(host, base, ldap_args, scope='sub', **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def create_temp_file(host, directory=None, create_file=True):
|
def create_temp_file(host, directory=None, create_file=True):
|
||||||
"""Creates temproray file using mktemp."""
|
"""Creates temporary file using mktemp."""
|
||||||
cmd = ['mktemp']
|
cmd = ['mktemp']
|
||||||
if create_file is False:
|
if create_file is False:
|
||||||
cmd += ['--dry-run']
|
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',
|
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"""
|
"""Create user and do login to set password"""
|
||||||
temp_password = 'Secret456789'
|
temp_password = 'Secret456789'
|
||||||
kinit_admin(host)
|
kinit_admin(host)
|
||||||
user_add(host, login, first=first, last=last, extra_args=extra_args,
|
user_add(host, login, first=first, last=last, extra_args=extra_args,
|
||||||
password=temp_password)
|
password=temp_password)
|
||||||
host.run_command(
|
if krb5_trace:
|
||||||
['kinit', login],
|
host.run_command(
|
||||||
stdin_text='{0}\n{1}\n{1}\n'.format(temp_password, password))
|
"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)
|
kdestroy_all(host)
|
||||||
|
|
||||||
|
|
||||||
@ -1960,8 +1967,14 @@ def run_command_as_user(host, user, command, *args, **kwargs):
|
|||||||
return host.run_command(command, *args, **kwargs)
|
return host.run_command(command, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def kinit_as_user(host, user, password):
|
def kinit_as_user(host, user, password, krb5_trace=False):
|
||||||
host.run_command(['kinit', user], stdin_text=password + '\n')
|
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',
|
KeyEntry = collections.namedtuple('KeyEntry',
|
||||||
|
Loading…
Reference in New Issue
Block a user