<commit_before># -*- coding: utf-8 -*-

import os
import unittest

import intelmq.lib.test as test
import intelmq.lib.utils as utils
from intelmq.bots.parsers.bambenek.parser_dgafeed import BambenekDGAfeedParserBot

with open(os.path.join(os.path.dirname(__file__), 'dga-feed.txt')) as handle:
    EXAMPLE_FILE = handle.read()

EXAMPLE_REPORT = {"feed.name": "Bambenek DGA Domain Feed",
                  "feed.url": "http://osint.bambenekconsulting.com/feeds/dga-feed.txt",
                  "raw": utils.base64_encode(EXAMPLE_FILE),
                  "__type": "Report",
                  "time.observation": "2016-01-01T00:00:00+00:00",
                 }
EVENTS = [{"feed.name": "Bambenek DGA Domain Feed",
           "feed.url": "http://osint.bambenekconsulting.com/feeds/dga-feed.txt",
           "__type": "Event",
           "time.source": "2016-11-10T00:00:00+00:00",
           "destination.fqdn": "xqmclnusaswvof.com",
           "classification.type": "ransomeware",
           "time.observation": "2016-01-01T00:00:00+00:00",
           "event_description.text": "Domain used by Cryptolocker - Flashback DGA for 10 Nov 2016",
           "event_description.url": "http://osint.bambenekconsulting.com/manual/cl.txt",
           "raw": "eHFtY2xudXNhc3d2b2YuY29tLERvbWFpbiB1c2VkIGJ5IENyeXB0b2xvY2tlciAtIEZsYXNoYmFjayBER0EgZm9yIDEwIE5vdiAyMDE2LDIwMTYtMTEtMTAsaHR0cD<KEY>
          }]

class TestBambenekDGAfeedParserBot(test.BotTestCase, unittest.TestCase):
    """
    A TestCase for BambenekDGAfeedParserBot
    """

    @classmethod
    def set_bot(cls):
        cls.bot_reference = BambenekDGAfeedParserBot
        cls.default_input_message = EXAMPLE_REPORT

    def test_event(self):
        """ Test if correct Event has been produced. """
        self.run_bot()
        self.assertMessageEqual(0, EVENTS[0])<commit_msg>Added Bambenek corrected test files<commit_after># -*- coding: utf-8 -*-

import os
import unittest

import intelmq.lib.test as test
import intelmq.lib.utils as utils
from intelmq.bots.parsers.bambenek.parser_dgafeed import BambenekDGAfeedParserBot

with open(os.path.join(os.path.dirname(__file__), 'dga-feed.txt')) as handle:
    EXAMPLE_FILE = handle.read()

EXAMPLE_REPORT = {"feed.name": "Bambenek DGA Domain Feed",
                  "feed.url": "http://osint.bambenekconsulting.com/feeds/dga-feed.txt",
                  "raw": utils.base64_encode(EXAMPLE_FILE),
                  "__type": "Report",
                  "time.observation": "2016-01-01T00:00:00+00:00",
                 }
EVENTS = [{"feed.name": "Bambenek DGA Domain Feed",
           "feed.url": "http://osint.bambenekconsulting.com/feeds/dga-feed.txt",
           "__type": "Event",
           "time.source": "2016-11-10T00:00:00+00:00",
           "destination.fqdn": "xqmclnusaswvof.com",
           "classification.type": "ransomware",
           "time.observation": "2016-01-01T00:00:00+00:00",
           "event_description.text": "Domain used by Cryptolocker - Flashback DGA for 10 Nov 2016",
           "event_description.url": "http://osint.bambenekconsulting.com/manual/cl.txt",
           "raw": "<KEY>
          }]

class TestBambenekDGAfeedParserBot(test.BotTestCase, unittest.TestCase):
    """
    A TestCase for BambenekDGAfeedParserBot
    """

    @classmethod
    def set_bot(cls):
        cls.bot_reference = BambenekDGAfeedParserBot
        cls.default_input_message = EXAMPLE_REPORT

    def test_event(self):
        """ Test if correct Event has been produced. """
        self.run_bot()
        self.assertMessageEqual(0, EVENTS[0])
{'fraction_non_alphanumeric': 0.13191131069323603, 'fraction_numerical': 0.0412573673870334, 'mean_word_length': 2.8950819672131147, 'pattern_counts': {'":': 30, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3016887', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1259, 'n_words': 201}