From f3cdf8b2f555b94cb55ab3e32cb2ef9ae531d9d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hellebrandt?= Date: Thu, 22 Feb 2024 15:06:14 +0100 Subject: [PATCH] Add a new test for password reset to user-specified password (#14070) --- tests/foreman/destructive/test_auth.py | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/foreman/destructive/test_auth.py b/tests/foreman/destructive/test_auth.py index 95da3c5ccce..06a59097434 100644 --- a/tests/foreman/destructive/test_auth.py +++ b/tests/foreman/destructive/test_auth.py @@ -46,3 +46,30 @@ def test_positive_password_reset(target_sat): result = target_sat.cli.Auth.with_user().status() assert LOGEDIN_MSG.format(settings.server.admin_username) in result.split("\n")[1] assert target_sat.cli.Org.with_user().list() + + +def test_positive_password_reset_chosen(target_sat): + """Reset admin password to specified password using foreman rake and update the hammer config. Verify the new password is working. + + :id: e8f13a26-2299-4a6b-a2f7-8cb17389d400 + + :expectedresults: New specified password is set. + + :CaseImportance: High + """ + new_password = gen_string('alpha') + result = target_sat.execute(f'foreman-rake permissions:reset password={new_password}') + assert result.status == 0 + reset_password = result.stdout.splitlines()[0].split('password: ')[1] + assert reset_password == new_password + result = target_sat.execute( + f'''sed -i -e '/username/d;/password/d;/use_sessions/d' {HAMMER_CONFIG};\ + echo ' :use_sessions: true' >> {HAMMER_CONFIG}''' + ) + assert result.status == 0 + target_sat.cli.AuthLogin.basic( + {'username': settings.server.admin_username, 'password': new_password} + ) + result = target_sat.cli.Auth.with_user().status() + assert LOGEDIN_MSG.format(settings.server.admin_username) in result.split("\n")[1] + assert target_sat.cli.Org.with_user().list()