authentik.events.tests.test_enrich_asn

Test ASN Wrapper

 1"""Test ASN Wrapper"""
 2
 3from django.test import TestCase
 4
 5from authentik.events.context_processors.asn import ASNContextProcessor
 6
 7
 8class TestASN(TestCase):
 9    """Test ASN Wrapper"""
10
11    def setUp(self) -> None:
12        self.reader = ASNContextProcessor()
13
14    def test_simple(self):
15        """Test simple asn wrapper"""
16        # IPs from
17        # https://github.com/maxmind/MaxMind-DB/blob/main/source-data/GeoLite2-ASN-Test.json
18        self.assertEqual(
19            self.reader.asn_dict("1.0.0.1"),
20            {
21                "asn": 15169,
22                "as_org": "Google Inc.",
23                "network": "1.0.0.0/24",
24            },
25        )
class TestASN(django.test.testcases.TestCase):
 9class TestASN(TestCase):
10    """Test ASN Wrapper"""
11
12    def setUp(self) -> None:
13        self.reader = ASNContextProcessor()
14
15    def test_simple(self):
16        """Test simple asn wrapper"""
17        # IPs from
18        # https://github.com/maxmind/MaxMind-DB/blob/main/source-data/GeoLite2-ASN-Test.json
19        self.assertEqual(
20            self.reader.asn_dict("1.0.0.1"),
21            {
22                "asn": 15169,
23                "as_org": "Google Inc.",
24                "network": "1.0.0.0/24",
25            },
26        )

Test ASN Wrapper

def setUp(self) -> None:
12    def setUp(self) -> None:
13        self.reader = ASNContextProcessor()

Hook method for setting up the test fixture before exercising it.

def test_simple(self):
15    def test_simple(self):
16        """Test simple asn wrapper"""
17        # IPs from
18        # https://github.com/maxmind/MaxMind-DB/blob/main/source-data/GeoLite2-ASN-Test.json
19        self.assertEqual(
20            self.reader.asn_dict("1.0.0.1"),
21            {
22                "asn": 15169,
23                "as_org": "Google Inc.",
24                "network": "1.0.0.0/24",
25            },
26        )

Test simple asn wrapper