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

import unittest

import intelmq.lib.test as test
from intelmq.bots.experts.cymru_whois.expert import CymruExpertBot

EXAMPLE_INPUT = {"__type": "Event",
                 "source.ip": "172.16.31.10",  # example.com
                 "time.observation": "2015-01-01T00:00:00+00:00",
                 }
EXAMPLE_OUTPUT = {"__type": "Event",
                  "source.ip": "172.16.31.10",
                  "source.geolocation.cc": "EU",
                  "source.registry": "RIPE",
                  "source.network": "192.168.127.12/24",
                  "source.allocated": "2008-06-02T00:00:00+00:00",
                  "source.asn": 15133,
                  "source.as_name": "EDGECAST - MCI Communications Services, Inc. d/b/a Verizon Business, US",
                  "time.observation": "2015-01-01T00:00:00+00:00",
                  }
EXAMPLE_INPUT6 = {"__type": "Event",
                  "destination.ip": "fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b",  # iana.org
                  "time.observation": "2015-01-01T00:00:00+00:00",
                  }
EXAMPLE_OUTPUT6 = {"__type": "Event",
                   "destination.ip": "fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b",  # iana.org
                   "destination.registry": "ARIN",
                   "destination.allocated": "2010-02-18T00:00:00+00:00",
                   "destination.as_name": "ICANN-DC - ICANN, US",
                   "destination.geolocation.cc": "US",
                   "time.observation": "2015-01-01T00:00:00+00:00",
                   "destination.asn": 16876,
                   "destination.network": "2001:500:88::/48",
                   }
UNICODE_INPUT = {"__type": "Event",
                 "destination.ip": "172.16.17.32",
                 "time.observation": "2015-01-01T00:00:00+00:00",
                 }
UNICODE_OUTPUT = {"__type": "Event",
                  "destination.ip": "172.16.17.32",
                  "time.observation": "2015-01-01T00:00:00+00:00",
                  "destination.registry": "LACNIC",
                  "destination.allocated": "2000-02-15T00:00:00+00:00",
                  "destination.as_name": "Fundação de Desenvolvimento da Pesquisa, BR",
                  "destination.geolocation.cc": "BR",
                  "destination.asn": 10417,
                  "destination.network": "192.168.3.11/18",
                  }
EMPTY_INPUT = {"__type": "Event",
               "source.ip": "172.16.17.32",  # no result
               "time.observation": "2015-01-01T00:00:00+00:00",
               }
NO_ASN_INPUT = {"__type": "Event",
                "source.ip": "172.16.31.10",
                "time.observation": "2015-01-01T00:00:00+00:00",
                }
NO_ASN_OUTPUT = {"__type": "Event",
                 "source.ip": "172.16.31.10",
                 "time.observation": "2015-01-01T00:00:00+00:00",
                 "source.asn": 23456,
                 "source.geolocation.cc": 'RU',
                 "source.ip": '172.16.31.10',
                 "source.network": '172.16.31.10/24',
                 "source.registry": 'RIPE',
                 }
EXAMPLE_6TO4_INPUT = {"__type": "Event",
                 "source.ip": "fc00:db20:35b:7399::5",
                 "time.observation": "2015-01-01T00:00:00+00:00",
                 }
EXAMPLE_6TO4_OUTPUT = {"__type": "Event",
                  "source.ip": "fc00:db20:35b:7399::5",
                  "source.network": "2002::/16",
                  "source.asn": 6939,
                  "source.as_name": "HURRICANE - Hurricane Electric, Inc., US",
                  "time.observation": "2015-01-01T00:00:00+00:00",
                  }

@test.skip_redis()
@test.skip_internet()
@unittest.skip('cymru is currently unreachable')
class TestCymruExpertBot(test.BotTestCase, unittest.TestCase):
    """
    A TestCase for AbusixExpertBot.
    """

    @classmethod<commit_msg>Revert "Revert "TST: cymru: fix changed ASN""<commit_after># -*- coding: utf-8 -*-

import unittest

import intelmq.lib.test as test
from intelmq.bots.experts.cymru_whois.expert import CymruExpertBot

EXAMPLE_INPUT = {"__type": "Event",
                 "source.ip": "172.16.31.10",  # example.com
                 "time.observation": "2015-01-01T00:00:00+00:00",
                 }
EXAMPLE_OUTPUT = {"__type": "Event",
                  "source.ip": "172.16.31.10",
                  "source.geolocation.cc": "EU",
                  "source.registry": "RIPE",
                  "source.network": "192.168.127.12/24",
                  "source.allocated": "2008-06-02T00:00:00+00:00",
                  "source.asn": 15133,
                  "source.as_name": "EDGECAST - MCI Communications Services, Inc. d/b/a Verizon Business, US",
                  "time.observation": "2015-01-01T00:00:00+00:00",
                  }
EXAMPLE_INPUT6 = {"__type": "Event",
                  "destination.ip": "fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b",  # iana.org
                  "time.observation": "2015-01-01T00:00:00+00:00",
                  }
EXAMPLE_OUTPUT6 = {"__type": "Event",
                   "destination.ip": "fd00:c2b6:b24b:be67:2827:688d:e6a1:6a3b",  # iana.org
                   "destination.registry": "ARIN",
                   "destination.allocated": "2010-02-18T00:00:00+00:00",
                   "destination.as_name": "ICANN-DC - ICANN, US",
                   "destination.geolocation.cc": "US",
                   "time.observation": "2015-01-01T00:00:00+00:00",
                   "destination.asn": 16876,
                   "destination.network": "2001:500:88::/48",
                   }
UNICODE_INPUT = {"__type": "Event",
                 "destination.ip": "172.16.17.32",
                 "time.observation": "2015-01-01T00:00:00+00:00",
                 }
UNICODE_OUTPUT = {"__type": "Event",
                  "destination.ip": "172.16.17.32",
                  "time.observation": "2015-01-01T00:00:00+00:00",
                  "destination.registry": "LACNIC",
                  "destination.allocated": "2000-02-15T00:00:00+00:00",
                  "destination.as_name": "Fundação de Desenvolvimento da Pesquisa, BR",
                  "destination.geolocation.cc": "BR",
                  "destination.asn": 10417,
                  "destination.network": "192.168.3.11/18",
                  }
EMPTY_INPUT = {"__type": "Event",
               "source.ip": "172.16.17.32",  # no result
               "time.observation": "2015-01-01T00:00:00+00:00",
               }
NO_ASN_INPUT = {"__type": "Event",
                "source.ip": "172.16.31.10",
                "time.observation": "2015-01-01T00:00:00+00:00",
                }
NO_ASN_OUTPUT = {"__type": "Event",
                 "source.ip": "172.16.31.10",
                 "time.observation": "2015-01-01T00:00:00+00:00",
                 "source.asn": 23456,
                 "source.geolocation.cc": 'RU',
                 "source.ip": '172.16.31.10',
                 "source.network": '172.16.31.10/24',
                 "source.registry": 'RIPE',
                 }
EXAMPLE_6TO4_INPUT = {"__type": "Event",
                 "source.ip": "fc00:db20:35b:7399::5",
                 "time.observation": "2015-01-01T00:00:00+00:00",
                 }
EXAMPLE_6TO4_OUTPUT = {"__type": "Event",
                  "source.ip": "fc00:db20:35b:7399::5",
                  "source.network": "2002::/16",
                  "source.asn": 1103,
                  "source.as_name": "SURFNET-NL SURFnet, The Netherlands, NL",
                  "time.observation": "2015-01-01T00:00:00+00:00",
                  }

@test.skip_redis()
@test.skip_internet()
@unittest.skip('cymru is currently unreachable')
class TestCymruExpertBot(test.BotTestCase, unittest.TestCase):
    """
    A TestCase for AbusixExpertBot.
    """

    @classmethod
{'fraction_non_alphanumeric': 0.16690186016677358, 'fraction_numerical': 0.11982039769082746, 'mean_word_length': 1.7363987363987363, 'pattern_counts': {'":': 118, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 22, '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': '1687768', 'n_tokens_mistral': 3225, 'n_tokens_neox': 2607, 'n_words': 365}