Skip to content

Commit 7f56958

Browse files
ColeHiggins2rmynar
authored andcommitted
Add test for bulk vulnerability analysis (SatelliteQE#20733)
* add test for bulk vulnerability analysis * update id and docstring * update rhel version * update pytest marker * update pytest marker to n-0 * update pytest marker back to 10 * rebase test * pre-commit
1 parent ee7b162 commit 7f56958

1 file changed

Lines changed: 69 additions & 19 deletions

File tree

tests/foreman/ui/test_rhcloud_insights_vulnerability.py

Lines changed: 69 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def setup_content_for_iop(module_target_sat_insights, rhcloud_manifest_org):
7373
@pytest.mark.rhel_ver_match('10')
7474
@pytest.mark.parametrize('module_target_sat_insights', [False], ids=['local'], indirect=True)
7575
def test_rhcloud_insights_vulnerabilities_e2e(
76-
rhel_insights_vm,
76+
vulnerable_rhel_host,
7777
rhcloud_manifest_org,
7878
module_target_sat_insights,
7979
setup_content_for_iop,
@@ -98,23 +98,9 @@ def test_rhcloud_insights_vulnerabilities_e2e(
9898
:verifies: SAT-30762
9999
"""
100100
satellite = module_target_sat_insights
101-
client = rhel_insights_vm
101+
client = vulnerable_rhel_host
102102
hostname = client.hostname
103103

104-
# Remove any static repos and update to the latest packages available from the Satellite
105-
assert (
106-
client.execute(
107-
'find /etc/yum.repos.d/ -type f | grep -vF redhat.repo | xargs -I \'{}\' rm \'{}\''
108-
).status
109-
== 0
110-
)
111-
assert client.execute('dnf -y update').status == 0
112-
113-
# Install vulnerable mariadb version (dnf install with NEVRA handles install/downgrade)
114-
assert client.execute(f'dnf install -y {constants.RHEL10_VULNERABLE_MARIADB_RPM}').status == 0
115-
# Run insights-client to report the vulnerabilities to Satellite
116-
assert client.execute('insights-client').status == 0
117-
118104
with satellite.ui_session() as session:
119105
session.organization.select(org_name=rhcloud_manifest_org.name)
120106

@@ -389,9 +375,9 @@ def test_positive_disable_vulnerability_analysis_for_host(
389375
module_target_sat_insights,
390376
setup_content_for_iop,
391377
):
392-
"""Test disabling vulnerability analysis for a host via kebab menu on All Hosts page
378+
"""Test bulk disabling vulnerability analysis for a host via kebab menu on All Hosts page
393379
394-
:id: 4e7ba195-235d-4f4e-86d0-2ab9b2db4bf0
380+
:id: d086ca66-542a-4492-a079-77ace4658135
395381
396382
:steps:
397383
1. Navigate to All Hosts page
@@ -433,7 +419,6 @@ def test_positive_disable_vulnerability_analysis_for_host(
433419
assert hostname in table_data[0]['Name'], (
434420
f"Expected host {hostname}, but got {host_row['Name']}"
435421
)
436-
437422
session.all_hosts.disable_vulnerability_analysis(hostname)
438423
# Search for the host again and verify status changed
439424
table_data = session.all_hosts.search(hostname)
@@ -443,3 +428,68 @@ def test_positive_disable_vulnerability_analysis_for_host(
443428
assert hostname in table_data[0]['Name'], (
444429
f"Expected host {hostname}, but got {host_row['Name']}"
445430
)
431+
432+
433+
@pytest.mark.e2e
434+
@pytest.mark.no_containers
435+
@pytest.mark.rhel_ver_match('10')
436+
@pytest.mark.parametrize('module_target_sat_insights', [False], ids=['local'], indirect=True)
437+
def test_positive_bulk_disable_vulnerability_analysis(
438+
vulnerable_rhel_host,
439+
rhcloud_manifest_org,
440+
module_target_sat_insights,
441+
setup_content_for_iop,
442+
):
443+
"""Test bulk disabling vulnerability analysis for a host via kebab menu on All Hosts page
444+
445+
:id: d9d73165-3227-433b-a355-254b3a05a2da
446+
447+
:steps:
448+
1. Navigate to All Hosts page
449+
2. Add "Total CVEs" column from Red Hat Lightspeed section
450+
3. Search for the registered insights RHEL host
451+
4. Verify the Total CVEs value is greater than 1
452+
5. Use bulk action to select all hosts and disable vulnerability analysis
453+
6. Verify the Total CVEs column now shows "Analysis disabled"
454+
455+
:expectedresults:
456+
1. Total CVEs column is successfully added and displayed
457+
2. Host shows CVE count greater than 1 initially
458+
3. After bulk disable action, Total CVEs column shows "Analysis disabled"
459+
460+
:Verifies: SAT-40203
461+
"""
462+
satellite = module_target_sat_insights
463+
client = vulnerable_rhel_host
464+
hostname = client.hostname
465+
466+
with satellite.ui_session() as session:
467+
# Select the correct organization
468+
session.organization.select(org_name=rhcloud_manifest_org.name)
469+
session.all_hosts.get_displayed_table_headers()
470+
session.all_hosts.manage_table_columns({'Total CVEs': True})
471+
472+
# Verify the column is displayed
473+
displayed_columns = session.all_hosts.get_displayed_table_headers()
474+
assert 'Total CVEs' in displayed_columns, (
475+
f"Total CVEs column not found. Available columns: {displayed_columns}"
476+
)
477+
478+
# Search for the registered host and total cves
479+
table_data = session.all_hosts.search(hostname)
480+
assert len(table_data) > 0, f"Host {hostname} not found after search"
481+
assert int(table_data[0]['Total CVEs']) > 1
482+
host_row = table_data[0]
483+
assert hostname in table_data[0]['Name'], (
484+
f"Expected host {hostname}, but got {host_row['Name']}"
485+
)
486+
487+
# Use bulk action to disable vulnerability analysis for all hosts
488+
session.all_hosts.manage_vulnerability_analysis('Disable')
489+
490+
# Search for the host again and verify status changed to "Analysis disabled"
491+
table_data = session.all_hosts.search(hostname)
492+
assert len(table_data) > 0, f"Host {hostname} not found after search"
493+
assert table_data[0]['Total CVEs'] == 'Analysis disabled', (
494+
f"Expected 'Analysis disabled' but got '{table_data[0]['Total CVEs']}'"
495+
)

0 commit comments

Comments
 (0)