From fccb9530505bc59919d9aa3c7f53600bd60cdcc6 Mon Sep 17 00:00:00 2001 From: Lukas Hellebrandt Date: Fri, 22 Dec 2023 13:07:58 +0100 Subject: [PATCH] bz2220965 --- pytest_fixtures/core/ui.py | 9 ++++++++- tests/foreman/ui/test_remoteexecution.py | 14 ++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/pytest_fixtures/core/ui.py b/pytest_fixtures/core/ui.py index 298632f59f6..81dbbaa6e8e 100644 --- a/pytest_fixtures/core/ui.py +++ b/pytest_fixtures/core/ui.py @@ -18,9 +18,12 @@ def ui_user(request, module_org, module_location, module_target_sat): test_module_name = request.module.__name__.split('.')[-1].split('_', 1)[-1] login = f"{test_module_name}_{gen_string('alphanumeric')}" password = gen_string('alphanumeric') + admin = request.param.get('admin', True) logger.debug('Creating session user %r', login) user = module_target_sat.api.User( - admin=True, + admin=admin, + organization=[module_org], + location=[module_location], default_organization=module_org, default_location=module_location, description=f'created automatically by airgun for module "{test_module_name}"', @@ -28,6 +31,10 @@ def ui_user(request, module_org, module_location, module_target_sat): password=password, ).create() user.password = password + if not admin: + # give all the permissions + user.role = module_target_sat.api.Role().search(query={'per_page': 'all'}) + user.update(['role']) yield user try: logger.debug('Deleting session user %r', user.login) diff --git a/tests/foreman/ui/test_remoteexecution.py b/tests/foreman/ui/test_remoteexecution.py index 5d9f3900f9a..e1e08d070e7 100644 --- a/tests/foreman/ui/test_remoteexecution.py +++ b/tests/foreman/ui/test_remoteexecution.py @@ -76,7 +76,12 @@ def test_positive_run_default_job_template_by_ip(session, rex_contenthost, modul @pytest.mark.skip_if_open('BZ:2182353') @pytest.mark.rhel_ver_match('8') @pytest.mark.tier3 -def test_positive_run_custom_job_template_by_ip(session, module_org, rex_contenthost): +@pytest.mark.parametrize( + 'ui_user', [{'admin': True}, {'admin': False}], indirect=True, ids=['adminuser', 'nonadminuser'] +) +def test_positive_run_custom_job_template_by_ip( + session, module_org, target_sat, default_location, ui_user, rex_contenthost +): """Run a job template on a host connected by ip :id: 3a59eb15-67c4-46e1-ba5f-203496ec0b0c @@ -93,8 +98,13 @@ def test_positive_run_custom_job_template_by_ip(session, module_org, rex_content :expectedresults: Verify the job was successfully ran against the host :parametrized: yes - """ + :bz: 2220965 + + :customerscenario: true + """ + ui_user.location.append(target_sat.api.Location(id=default_location.id)) + ui_user.update(['location']) hostname = rex_contenthost.hostname job_template_name = gen_string('alpha') with session: