Skip to content

Commit 6df23ca

Browse files
authored
[6.19.z] Update IoP Vulnerability e2e test to apply erratum and verify remediation (#21186)
1 parent cda83ea commit 6df23ca

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

robottelo/constants/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,7 @@
991991
# Vulnerability testing constants for RHEL 10
992992
RHEL10_VULNERABLE_MARIADB_RPM = 'mariadb-3:10.11.11-1.el10.x86_64'
993993
RHEL10_VULNERABLE_MARIADB_CVES = ['CVE-2023-52969', 'CVE-2023-52970', 'CVE-2023-52971']
994+
RHEL10_MARIADB_ERRATUM = 'RHSA-2026:0136'
994995
# Use the first CVE as the primary one for single-CVE tests
995996
RHEL10_VULNERABILITY_CVE_ID = RHEL10_VULNERABLE_MARIADB_CVES[0]
996997
FAKE_1_YUM_REPOS_COUNT = 32

tests/foreman/ui/test_rhcloud_insights_vulnerability.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
1313
"""
1414

15+
from datetime import UTC, datetime, timedelta
16+
1517
import pytest
18+
from wait_for import wait_for
1619

1720
from robottelo import constants
1821

@@ -90,10 +93,13 @@ def test_rhcloud_insights_vulnerabilities_e2e(
9093
4. Downgrade package on host to create vulnerability for detection by vulnerability engine.
9194
5. In Satellite UI, go to Vulnerabilities tab on Host Details page and validate the data.
9295
6. In Satellite UI, go to Vulnerability page and validate the data.
96+
7. Remediate the vulnerability from the Satellite UI.
97+
8. Verify that the vulnerabilities created in step 4 no longer affect the host.
9398
9499
:expectedresults:
95100
1. Local insights vulnerability engine detects the new vulnerabilities.
96101
2. Vulnerability data is displayed correctly for impacted host in Satellite.
102+
3. Vulnerabilities are no longer displayed after remediation.
97103
98104
:verifies: SAT-30762
99105
"""
@@ -126,6 +132,37 @@ def test_rhcloud_insights_vulnerabilities_e2e(
126132
vuln.get('CVE ID') == constants.RHEL10_VULNERABILITY_CVE_ID for vuln in vulnerabilities
127133
)
128134

135+
# Apply the erratum that mitigates the CVEs
136+
timestamp = (datetime.now(UTC) - timedelta(minutes=2)).strftime('%Y-%m-%d %H:%M')
137+
session.host_new.apply_erratas(
138+
entity_name=hostname,
139+
search=f'errata_id == {constants.RHEL10_MARIADB_ERRATUM}',
140+
)
141+
142+
# Wait for applicability to generate on the host after remediation
143+
wait_for(
144+
lambda: (
145+
satellite.api.ForemanTask()
146+
.search(
147+
query={
148+
'search': f'label = Actions::RemoteExecution::RunHostsJob '
149+
f'and started_at >= "{timestamp}"'
150+
}
151+
)[0]
152+
.result
153+
== 'success'
154+
),
155+
timeout=400,
156+
delay=15,
157+
silent_failure=True,
158+
handle_exception=True,
159+
)
160+
161+
vulnerabilities = session.host_new.get_vulnerabilities(hostname)
162+
cve_ids = [vuln['CVE ID'] for vuln in vulnerabilities]
163+
for mariadb_cve in constants.RHEL10_VULNERABLE_MARIADB_CVES:
164+
assert mariadb_cve not in cve_ids
165+
129166

130167
@pytest.mark.e2e
131168
@pytest.mark.no_containers

0 commit comments

Comments
 (0)