diff --git a/tests/foreman/ui/test_ansible.py b/tests/foreman/ui/test_ansible.py index 9754e3dafae..eb8777cee74 100644 --- a/tests/foreman/ui/test_ansible.py +++ b/tests/foreman/ui/test_ansible.py @@ -400,6 +400,53 @@ def test_positive_set_ansible_role_order_per_hostgroup(self): :CaseAutomation: NotAutomated """ + @pytest.mark.tier2 + def test_positive_assign_and_remove_role_to_hostgroup( + self, target_sat, module_org, module_location + ): + """Add and remove functionality for ansible roles in hostgroup + + :id: 5d94a484-92c1-4387-ab92-0649e4c4f907 + + :steps: + 1. Import all roles available by default. + 2. Create a hostgroup + 3. Assign hostgroup to the host + 4. Register a RHEL host to Satellite with given hostgroup. + 5. Navigate to the new UI for the given hostgroup. + 6. Add an ansible roles to the hostgroup + 7. Remove the added ansible roles from the hostgroup + + :expectedresults: The Ansible Role is successfully assign/add/remove from the hostgroup, and no longer shows + up on the UI + """ + SELECTED_ROLE = 'RedHatInsights.insights-client' + hostgroup = target_sat.api.HostGroup( + location=[module_location], + organization=[module_org], + ).create() + host = target_sat.api.Host( + organization=module_org, location=module_location, hostgroup=hostgroup + ).create() + location = host.location.read() + organization = host.organization.read() + with target_sat.ui_session() as session: + session.location.select(location.name) + session.organization.select(organization.name) + # assign ansible role to host-group + target_sat.api.AnsibleRoles().sync( + data={'proxy_id': target_sat.nailgun_smart_proxy.id, 'role_names': [SELECTED_ROLE]} + ) + session.host_new.assign_role_to_hostgroup(host.name) + # verify ansible role assigned to new UI for given host-group + assert ( + session.hostgroup.read( + host.hostgroup.read().name, widget_names='ansible_roles.assigned_role' + )['ansible_roles']['assigned_role'].split('. ')[1] + ) == SELECTED_ROLE + # remove ansible role to host-group + session.host_new.remove_hostgroup_role(host.name) + class TestAnsibleREX: """Test class for remote execution via Ansible @@ -635,4 +682,4 @@ def test_positive_schedule_recurring_hostgroup_job(self): 7. Navigate to Job Invocations. :expectedresults: Scheduled Job appears in the Job Invocation list at the appointed time - """ \ No newline at end of file + """