Skip to content

Commit

Permalink
non-admin user acess with usergroup
Browse files Browse the repository at this point in the history
  • Loading branch information
amolpati30 committed Jun 23, 2024
1 parent 95a2ad0 commit a199576
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion tests/foreman/ui/test_ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
:CaseImportance: Critical
"""

from fauxfactory import gen_string
from fauxfactory import gen_email, gen_string
import pytest
from wait_for import wait_for
import yaml
Expand Down Expand Up @@ -449,6 +449,64 @@ def test_positive_assign_and_remove_ansible_role_to_host(self, target_sat, funct
== 'No roles assigned directly to the host'
)

@pytest.mark.tier3
def test_positive_non_admin_access(self, target_sat, test_name, module_location, module_org):
"""Verify non-admin user can access the ansible page on WebUI
:id: 82d30664-1b74-457c-92e2-31a5ba89e826
:BZ: 2158508
:steps:
1. Create user with non-admin (in my case ldap based)
2. Create usergroup with administrator role (in my case ldap based)
3. As user from (1) log in and try to access
WebUI -> Hosts -> select host -> Ansible
:expectedresults: See Ansible page as user should be administrator due to usergroup
"""
name = gen_string('alpha')
hst_grp = gen_string('alpha')
password = gen_string('alpha')
email = gen_email()
login_text_data = gen_string('alpha', 270)
user_group = target_sat.api.UserGroup().create()
with target_sat.ui_session() as session:
session.location.select(module_location.name)
session.organization.select(module_org.name)
session.user.create(
{
'user.login': name,
'user.auth': 'INTERNAL',
'user.password': password,
'user.confirm': password,
'user.mail': email,
'roles.admin': False,
}
)
session.usergroup.create(
{
'usergroup.name': hst_grp,
'usergroup.users': {'assigned': [name]},
'usergroup.usergroups': {'assigned': [user_group.name]},
'roles.admin': True,
'roles.resources': {'assigned': ['Ansible Roles Manager']},
}
)
result = session.login.logout()
assert result["login_text"] == login_text_data
with target_sat.ui_session(test_name, name, password) as newsession:
newsession.location.select(module_location.name)
newsession.organization.select(module_org.name)
values = newsession.host_new.get_details(target_sat.hostname)
assert (
values['ansible']['roles']['noRoleAssign']
== 'No roles assigned directly to the host'
)
with target_sat.ui_session('deletehostsession') as deletehostsession:
deletehostsession.user.delete(name)
assert not deletehostsession.user.search(name)


class TestAnsibleREX:
"""Test class for remote execution via Ansible
Expand Down

0 comments on commit a199576

Please sign in to comment.