File scanning: validate wheel digests against pypi.org #199

Merged
Oleg-Komarov merged 5 commits from validate-wheels into main 2024-07-11 10:45:24 +02:00
Showing only changes of commit ad86cf5bec - Show all commits

View File

@ -38,12 +38,12 @@ class FileScanTest(TestCase):
# A background task should have been created # A background task should have been created
task = Task.objects.created_by(creator=file).first() task = Task.objects.created_by(creator=file).first()
self.assertIsNotNone(task) self.assertIsNotNone(task)
self.assertEqual(task.task_name, 'files.tasks.clamdscan') self.assertEqual(task.task_name, 'files.tasks.scan_file')
self.assertEqual(task.task_params, f'[[], {{"file_id": {file.pk}}}]') self.assertEqual(task.task_params, f'[[], {{"file_id": {file.pk}}}]')
# Actually run the task as if by background runner # Actually run the task as if by background runner
task_args, task_kwargs = task.params() task_args, task_kwargs = task.params()
files.tasks.clamdscan.task_function(*task_args, **task_kwargs) files.tasks.scan_file.task_function(*task_args, **task_kwargs)
file.refresh_from_db() file.refresh_from_db()
self.assertFalse(file.validation.is_ok) self.assertFalse(file.validation.is_ok)
@ -68,12 +68,12 @@ class FileScanTest(TestCase):
# A background task should have been created # A background task should have been created
task = Task.objects.created_by(creator=file).first() task = Task.objects.created_by(creator=file).first()
self.assertIsNotNone(task) self.assertIsNotNone(task)
self.assertEqual(task.task_name, 'files.tasks.clamdscan') self.assertEqual(task.task_name, 'files.tasks.scan_file')
self.assertEqual(task.task_params, f'[[], {{"file_id": {file.pk}}}]') self.assertEqual(task.task_params, f'[[], {{"file_id": {file.pk}}}]')
# Actually run the task as if by background runner # Actually run the task as if by background runner
task_args, task_kwargs = task.params() task_args, task_kwargs = task.params()
files.tasks.clamdscan.task_function(*task_args, **task_kwargs) files.tasks.scan_file.task_function(*task_args, **task_kwargs)
self.assertFalse(file.validation.is_ok) self.assertFalse(file.validation.is_ok)
file.validation.refresh_from_db() file.validation.refresh_from_db()
@ -95,12 +95,12 @@ class FileScanTest(TestCase):
# A background task should have been created # A background task should have been created
task = Task.objects.created_by(creator=file).first() task = Task.objects.created_by(creator=file).first()
self.assertIsNotNone(task) self.assertIsNotNone(task)
self.assertEqual(task.task_name, 'files.tasks.clamdscan') self.assertEqual(task.task_name, 'files.tasks.scan_file')
self.assertEqual(task.task_params, f'[[], {{"file_id": {file.pk}}}]') self.assertEqual(task.task_params, f'[[], {{"file_id": {file.pk}}}]')
# Actually run the task as if by background runner # Actually run the task as if by background runner
task_args, task_kwargs = task.params() task_args, task_kwargs = task.params()
files.tasks.clamdscan.task_function(*task_args, **task_kwargs) files.tasks.scan_file.task_function(*task_args, **task_kwargs)
file.refresh_from_db() file.refresh_from_db()
self.assertTrue(file.validation.is_ok) self.assertTrue(file.validation.is_ok)