|
12 | 12 |
|
13 | 13 | """ |
14 | 14 |
|
| 15 | +from datetime import UTC, datetime, timedelta |
| 16 | + |
15 | 17 | import pytest |
| 18 | +from wait_for import wait_for |
16 | 19 |
|
17 | 20 | from robottelo import constants |
18 | 21 |
|
@@ -90,10 +93,13 @@ def test_rhcloud_insights_vulnerabilities_e2e( |
90 | 93 | 4. Downgrade package on host to create vulnerability for detection by vulnerability engine. |
91 | 94 | 5. In Satellite UI, go to Vulnerabilities tab on Host Details page and validate the data. |
92 | 95 | 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. |
93 | 98 |
|
94 | 99 | :expectedresults: |
95 | 100 | 1. Local insights vulnerability engine detects the new vulnerabilities. |
96 | 101 | 2. Vulnerability data is displayed correctly for impacted host in Satellite. |
| 102 | + 3. Vulnerabilities are no longer displayed after remediation. |
97 | 103 |
|
98 | 104 | :verifies: SAT-30762 |
99 | 105 | """ |
@@ -126,6 +132,37 @@ def test_rhcloud_insights_vulnerabilities_e2e( |
126 | 132 | vuln.get('CVE ID') == constants.RHEL10_VULNERABILITY_CVE_ID for vuln in vulnerabilities |
127 | 133 | ) |
128 | 134 |
|
| 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 | + |
129 | 166 |
|
130 | 167 | @pytest.mark.e2e |
131 | 168 | @pytest.mark.no_containers |
|
0 commit comments