Пример #1
0
    def test_list_shows_matches_only_by_default(self):
        # Create one entry without matches
        ScannerResult.objects.create(scanner=YARA)
        # Create one entry with matches
        with_matches = ScannerResult(scanner=YARA)
        with_matches.add_match(rule='some-rule')
        with_matches.save()

        response = self.client.get(self.list_url)
        assert response.status_code == 200
        html = pq(response.content)
        assert html('#result_list tbody tr').length == 1
Пример #2
0
    def test_list_can_show_all_entries(self):
        # Create one entry without matches
        ScannerResult.objects.create(scanner=YARA)
        # Create one entry with matches
        with_matches = ScannerResult(scanner=YARA)
        with_matches.add_match(rule='some-rule')
        with_matches.save()

        response = self.client.get(self.list_url,
                                   {MatchesFilter.parameter_name: 'all'})
        assert response.status_code == 200
        html = pq(response.content)
        expected_length = ScannerResult.objects.count()
        assert html('#result_list tbody tr').length == expected_length
Пример #3
0
    def test_formatted_matches(self):
        result = ScannerResult()
        result.add_match(rule='some-rule')

        assert self.admin.formatted_matches(result) == format_html(
            '<pre>{}</pre>', json.dumps(result.matches, indent=4))