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()