Пример #1
0
    def test_get_results_200_success(self, mock_get):
        '''
        Tests Metadefender._parse_scan_result()'s handling of a complete
        analysis report
        '''
        print('Running test_get_results_200_success')
        report_resp = Metadefender._retrieve_scan_results(
            'results_url', SCAN_IDS[0])
        is_scan_complete, parsed_resp = Metadefender._parse_scan_result(
            report_resp)
        self.assertEquals(is_scan_complete, True)
        self.assertEquals(parsed_resp['overall_status'],
                          Metadefender.STATUS_SUCCESS)

        engine_results = parsed_resp['engine_results']
        for engine_result in engine_results:
            engine_name = engine_result['engine_name']
            scan_result = engine_result['scan_result']
            threat_found = engine_result['threat_found']
            if engine_name == 'ClamAV':
                self.assertEquals(scan_result, 'Infected/Known')
                self.assertEquals(threat_found,
                                  'Heuristics.PDF.ObfuscatedNameObject')
            elif engine_name == 'Ahnlab':
                self.assertEquals(scan_result, 'Infected/Known')
                self.assertEquals(threat_found, 'Trojan/Win32.Inject.C1515213')
            elif engine_name == 'ESET':
                self.assertEquals(scan_result, 'No threats Found')
                self.assertEquals(threat_found, '')
            elif engine_name == 'Avira':
                self.assertEquals(scan_result, 'No threats Found')
                self.assertEquals(threat_found, '')
            else:
                self.fail('Unexpected Engine: %s' % engine_name)
    def test_get_results_200_success(self, mock_get):
        '''
        Tests Metadefender._parse_scan_result()'s handling of a complete
        analysis report
        '''
        print('Running test_get_results_200_success')
        report_resp = Metadefender._retrieve_scan_results('results_url', SCAN_IDS[0])
        is_scan_complete, parsed_resp = Metadefender._parse_scan_result(report_resp)
        self.assertEquals(is_scan_complete, True)
        self.assertEquals(parsed_resp['overall_status'], Metadefender.STATUS_SUCCESS)

        engine_results = parsed_resp['engine_results']
        for engine_result in engine_results:
            engine_name = engine_result['engine_name']
            scan_result = engine_result['scan_result']
            threat_found = engine_result['threat_found']
            if engine_name == 'ClamAV':
                self.assertEquals(scan_result, 'Infected/Known')
                self.assertEquals(threat_found, 'Heuristics.PDF.ObfuscatedNameObject')
            elif engine_name == 'Ahnlab':
                self.assertEquals(scan_result, 'Infected/Known')
                self.assertEquals(threat_found, 'Trojan/Win32.Inject.C1515213')
            elif engine_name == 'ESET':
                self.assertEquals(scan_result, 'No threats Found')
                self.assertEquals(threat_found, '')
            elif engine_name == 'Avira':
                self.assertEquals(scan_result, 'No threats Found')
                self.assertEquals(threat_found, '')
            else:
                self.fail('Unexpected Engine: %s' % engine_name)
    def test_get_results_200_not_found(self, mock_get):
        '''
        Tests Metadefender._parse_scan_result()'s handling of a 200 response
        where the scan ID was not found. The module is supposed to interpret
        this to mean that the analysis is 'pending'
        '''
        print('Running test_get_results_200_not_found')
        report_resp = Metadefender._retrieve_scan_results('results_url', SCAN_IDS[0])
        is_scan_complete, parsed_resp = Metadefender._parse_scan_result(report_resp)
        self.assertEquals(is_scan_complete, False)
        self.assertEquals(parsed_resp['overall_status'], Metadefender.STATUS_PENDING)

        engine_results = parsed_resp['engine_results']
        if len(engine_results) != 0:
            self.fail('Engine result list should be empty')
 def test_get_results_200_succes_in_progress(self, mock_get):
     '''
     Tests Metadefender._parse_scan_result()'s handling of a 200 response
     where the scan ID was found but the scan is not complete
     '''
     print('Running test_get_results_200_succes_in_progress')
     report_resp = Metadefender._retrieve_scan_results('results_url', SCAN_IDS[0])
     is_scan_complete, parsed_resp = Metadefender._parse_scan_result(report_resp)
     self.assertEquals(is_scan_complete, False)
     self.assertEquals(parsed_resp['overall_status'], Metadefender.STATUS_PENDING)
     msg = parsed_resp['msg']
     if 'percent complete: 10' not in msg:
         self.fail('Progress percentage not present')
     engine_results = parsed_resp['engine_results']
     if len(engine_results) != 0:
         self.fail('Engine result list should be empty')
Пример #5
0
    def test_get_results_200_not_found(self, mock_get):
        '''
        Tests Metadefender._parse_scan_result()'s handling of a 200 response
        where the scan ID was not found. The module is supposed to interpret
        this to mean that the analysis is 'pending'
        '''
        print('Running test_get_results_200_not_found')
        report_resp = Metadefender._retrieve_scan_results(
            'results_url', SCAN_IDS[0])
        is_scan_complete, parsed_resp = Metadefender._parse_scan_result(
            report_resp)
        self.assertEquals(is_scan_complete, False)
        self.assertEquals(parsed_resp['overall_status'],
                          Metadefender.STATUS_PENDING)

        engine_results = parsed_resp['engine_results']
        if len(engine_results) != 0:
            self.fail('Engine result list should be empty')
Пример #6
0
 def test_get_results_200_succes_in_progress(self, mock_get):
     '''
     Tests Metadefender._parse_scan_result()'s handling of a 200 response
     where the scan ID was found but the scan is not complete
     '''
     print('Running test_get_results_200_succes_in_progress')
     report_resp = Metadefender._retrieve_scan_results(
         'results_url', SCAN_IDS[0])
     is_scan_complete, parsed_resp = Metadefender._parse_scan_result(
         report_resp)
     self.assertEquals(is_scan_complete, False)
     self.assertEquals(parsed_resp['overall_status'],
                       Metadefender.STATUS_PENDING)
     msg = parsed_resp['msg']
     if 'percent complete: 10' not in msg:
         self.fail('Progress percentage not present')
     engine_results = parsed_resp['engine_results']
     if len(engine_results) != 0:
         self.fail('Engine result list should be empty')