* events: add ASN Database reader Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix test config generator Signed-off-by: Jens Langhammer <jens@goauthentik.io> * de-duplicate code Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add enrich_context Signed-off-by: Jens Langhammer <jens@goauthentik.io> * rename to context processors? Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix cache Signed-off-by: Jens Langhammer <jens@goauthentik.io> * use config deprecation system, update docs Signed-off-by: Jens Langhammer <jens@goauthentik.io> * update more docs and tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add test asn db Signed-off-by: Jens Langhammer <jens@goauthentik.io> * re-build schema with latest versions Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
25 lines
657 B
Python
25 lines
657 B
Python
"""Test ASN Wrapper"""
|
|
from django.test import TestCase
|
|
|
|
from authentik.events.context_processors.asn import ASNContextProcessor
|
|
|
|
|
|
class TestASN(TestCase):
|
|
"""Test ASN Wrapper"""
|
|
|
|
def setUp(self) -> None:
|
|
self.reader = ASNContextProcessor()
|
|
|
|
def test_simple(self):
|
|
"""Test simple asn wrapper"""
|
|
# IPs from
|
|
# https://github.com/maxmind/MaxMind-DB/blob/main/source-data/GeoLite2-ASN-Test.json
|
|
self.assertEqual(
|
|
self.reader.asn_dict("1.0.0.1"),
|
|
{
|
|
"asn": 15169,
|
|
"as_org": "Google Inc.",
|
|
"network": "1.0.0.0/24",
|
|
},
|
|
)
|