Add a test for selecting images to be scanned
This commit is contained in:
parent
3dea6f6c92
commit
a9a75cd4cf
1 changed files with 15 additions and 0 deletions
|
@ -10,6 +10,7 @@ from util.secscan.api import SecurityScannerAPI, AnalyzeLayerException
|
||||||
from util.secscan.analyzer import LayerAnalyzer
|
from util.secscan.analyzer import LayerAnalyzer
|
||||||
from util.secscan.notifier import process_notification_data
|
from util.secscan.notifier import process_notification_data
|
||||||
from data import model
|
from data import model
|
||||||
|
from data.database import Image
|
||||||
from workers.security_notification_worker import SecurityNotificationWorker
|
from workers.security_notification_worker import SecurityNotificationWorker
|
||||||
from endpoints.v2 import v2_bp
|
from endpoints.v2 import v2_bp
|
||||||
|
|
||||||
|
@ -587,6 +588,20 @@ class TestSecurityScanner(unittest.TestCase):
|
||||||
self.assertFalse(VulnerabilityFoundEvent().should_perform(event_data, notification))
|
self.assertFalse(VulnerabilityFoundEvent().should_perform(event_data, notification))
|
||||||
|
|
||||||
|
|
||||||
|
def test_select_images_to_scan(self):
|
||||||
|
# Set all images to have a security index of a version to that of the config.
|
||||||
|
expected_version = app.config['SECURITY_SCANNER_ENGINE_VERSION_TARGET']
|
||||||
|
Image.update(security_indexed_engine=expected_version).execute()
|
||||||
|
|
||||||
|
# Ensure no images are available for scanning.
|
||||||
|
self.assertIsNone(model.image.get_min_id_for_sec_scan(expected_version))
|
||||||
|
self.assertTrue(len(model.image.get_images_eligible_for_scan(expected_version)) == 0)
|
||||||
|
|
||||||
|
# Check for a higher version.
|
||||||
|
self.assertIsNotNone(model.image.get_min_id_for_sec_scan(expected_version + 1))
|
||||||
|
self.assertTrue(len(model.image.get_images_eligible_for_scan(expected_version + 1)) > 0)
|
||||||
|
|
||||||
|
|
||||||
def test_notification_worker(self):
|
def test_notification_worker(self):
|
||||||
pages_called = []
|
pages_called = []
|
||||||
|
|
||||||
|
|
Reference in a new issue