def test_phishing_timeout(self, mock_rq_enqueue_in, mock_ping, mock_rq_schedule, mock_rq_enqueue): """ Test phishing workflow """ ReportWorkflowFactory.instance.read_worflows_available() from worker import report mock_rq_enqueue_in.return_value = None mock_ping.return_value = PingResponse(100, '404', 'Not Found', 'Not Found for test_phishing_timeout', False) mock_rq_schedule.return_value = FakeJob() mock_rq_enqueue.return_value = FakeJob() sample = self._samples['sample6'] content = sample.read() report.create_from_email(email_content=content, send_ack=False) # Reopening ticket cerberus_report = Report.objects.last() cerberus_report.status = 'Attached' cerberus_report.ticket.status = 'WaitingAnswer' cerberus_report.ticket.snoozeDuration = 1 cerberus_report.ticket.snoozeStart = datetime.now() - timedelta(days=1) cerberus_report.ticket.save() cerberus_report.save() from worker import ticket as ticket_func ticket_func.update_waiting() ticket = Ticket.objects.get(id=cerberus_report.ticket.id) self.assertEqual('Alarm', ticket.status) ticket_func.timeout(ticket.id) ticket = Ticket.objects.get(id=cerberus_report.ticket.id) self.assertEqual('Closed', ticket.status) self.assertEqual(settings.CODENAMES['fixed_customer'], ticket.resolution.codename) # Reopening ticket UrlStatus.objects.all().delete() mock_ping.return_value = PingResponse(0, '200', 'UP', 'UP for test_phishing_timeout', False) cerberus_report = Report.objects.last() cerberus_report.status = 'Attached' cerberus_report.ticket.status = 'WaitingAnswer' cerberus_report.ticket.snoozeDuration = 1 cerberus_report.ticket.snoozeStart = datetime.now() - timedelta(days=1) cerberus_report.ticket.save() cerberus_report.save() ticket_func.update_waiting() ticket = Ticket.objects.get(id=cerberus_report.ticket.id) self.assertEqual('Alarm', ticket.status) ticket_func.timeout(ticket.id) ticket = Ticket.objects.get(id=cerberus_report.ticket.id) self.assertEqual('Closed', ticket.status) self.assertEqual(settings.CODENAMES['fixed'], ticket.resolution.codename)
def test_copyright_specific_workflow(self, mock_rq_enqueue_in, mock_rq_schedule, mock_rq_enqueue): """ Test copyright timeout """ ReportWorkflowFactory.instance.read_worflows_available() from worker import report mock_rq_enqueue_in.return_value = None mock_rq_schedule.return_value = FakeJob() mock_rq_enqueue.return_value = FakeJob() sample = self._samples['sample18'] content = sample.read() report.create_from_email(email_content=content, send_ack=False) cerberus_report = Report.objects.last() cerberus_report.reportItemRelatedReport.all().update(fqdnResolved='1.2.3.4') self.assertEqual('Attached', cerberus_report.status) self.assertTrue(cerberus_report.ticket) self.assertIn('report:copyright_report_workflow', cerberus_report.tags.all().values_list('name', flat=True)) cerberus_report.status = 'Attached' cerberus_report.ticket.status = 'WaitingAnswer' cerberus_report.ticket.snoozeDuration = 1 cerberus_report.ticket.snoozeStart = datetime.now() - timedelta(days=1) cerberus_report.ticket.save() cerberus_report.save() from worker import ticket as ticket_func ticket_func.update_waiting() ticket = Ticket.objects.get(id=cerberus_report.ticket.id) self.assertEqual('Alarm', ticket.status) ticket_func.timeout(ticket.id) ticket = Ticket.objects.get(id=cerberus_report.ticket.id) self.assertEqual('Closed', ticket.status) self.assertEqual(settings.CODENAMES['fixed'], ticket.resolution.codename) # Check if not trusted Report.objects.all().delete() Ticket.objects.all().delete() content = content.replace("Test-Magic-Smtp-Header: it's here", "") report.create_from_email(email_content=content, send_ack=False) cerberus_report = Report.objects.last() self.assertEqual('New', cerberus_report.status)