Skip to content

Commit

Permalink
Test unassigning with multiple policies present (SatelliteQE#14058)
Browse files Browse the repository at this point in the history
  • Loading branch information
lhellebr authored and shweta83 committed Apr 10, 2024
1 parent f51a495 commit fe8b004
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions tests/foreman/ui/test_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ def scap_policy(scap_content, target_sat):
return scap_policy


second_scap_policy = scap_policy


@pytest.fixture(scope='module')
def module_global_params(module_target_sat):
"""Create 3 global parameters and clean up at teardown"""
Expand Down Expand Up @@ -317,7 +320,9 @@ def test_positive_assign_taxonomies(

@pytest.mark.skip_if_not_set('oscap')
@pytest.mark.tier2
def test_positive_assign_compliance_policy(session, scap_policy, target_sat, function_host):
def test_positive_assign_compliance_policy(
session, scap_policy, second_scap_policy, target_sat, function_host
):
"""Ensure host compliance Policy can be assigned.
:id: 323661a4-e849-4cc2-aa39-4b4a5fe2abed
Expand All @@ -338,12 +343,13 @@ def test_positive_assign_compliance_policy(session, scap_policy, target_sat, fun
organization=content.organization,
location=content.location,
).update(['organization', 'location'])
for sp in [scap_policy, second_scap_policy]:
target_sat.api.CompliancePolicies(
id=sp['id'],
organization=content.organization,
location=content.location,
).update(['organization', 'location'])

target_sat.api.CompliancePolicies(
id=scap_policy['id'],
organization=content.organization,
location=content.location,
).update(['organization', 'location'])
with session:
session.organization.select(org_name=org.name)
session.location.select(loc_name=loc.name)
Expand All @@ -352,6 +358,9 @@ def test_positive_assign_compliance_policy(session, scap_policy, target_sat, fun
session.host.apply_action(
'Assign Compliance Policy', [function_host.name], {'policy': scap_policy['name']}
)
session.host.apply_action(
'Assign Compliance Policy', [function_host.name], {'policy': second_scap_policy['name']}
)
assert (
session.host.search(f'compliance_policy = {scap_policy["name"]}')[0]['Name']
== function_host.name
Expand All @@ -367,6 +376,10 @@ def test_positive_assign_compliance_policy(session, scap_policy, target_sat, fun
'Unassign Compliance Policy', [function_host.name], {'policy': scap_policy['name']}
)
assert not session.host.search(f'compliance_policy = {scap_policy["name"]}')
assert (
session.host.search(f'compliance_policy = {second_scap_policy["name"]}')[0]['Name']
== function_host.name
)


@pytest.mark.skipif((settings.ui.webdriver != 'chrome'), reason='Only tested on Chrome')
Expand Down

0 comments on commit fe8b004

Please sign in to comment.