Skip to content

Commit

Permalink
Merge branch 'master' into create_report_w/o_name
Browse files Browse the repository at this point in the history
  • Loading branch information
amolpati30 authored Feb 14, 2024
2 parents d0397be + ab2a9dc commit c4ad609
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
16 changes: 10 additions & 6 deletions tests/foreman/cli/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,10 @@ def test_positive_session_survives_unauthenticated_call(admin_user, target_sat):
:steps:
1. Set use_sessions
2. Authenticate, assert credentials are not demanded
on next command run
3. Run `hammer ping`
2. Authenticate
3. Run an authenticated call, assert credentials are not demanded
4. Run `hammer ping`, an unauthenticated call
5. Run an authenticated call, assert credentials are not demanded
:CaseImportance: Medium
Expand Down Expand Up @@ -230,11 +231,14 @@ def test_positive_session_survives_failed_login(admin_user, non_admin_user, targ
:steps:
1. Set use_sessions
2. Authenticate, assert credentials are not demanded
on next command run
3. Run login with invalid credentials
2. Authenticate
3. Run an authenticated command, assert credentials are not demanded
4. Run login with invalid credentials
5. Run an authenticated command, assert credentials are not demanded
:expectedresults: The session is unchanged
:CaseImportance: High
"""
result = configure_sessions(target_sat)
assert result == 0, 'Failed to configure hammer sessions'
Expand Down
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 c4ad609

Please sign in to comment.