Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test unassigning with multiple policies present #14058

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading