authentik.admin.tests.test_normalize_base_url

Tests for the normalize_base_url helper

 1"""Tests for the normalize_base_url helper"""
 2
 3from django.test import SimpleTestCase
 4
 5from authentik.admin.utils import normalize_base_url
 6
 7
 8class TestNormalizeBaseURL(SimpleTestCase):
 9    """normalize_base_url strips whitespace and trailing slashes"""
10
11    def test_normalize(self):
12        cases = {
13            None: "",
14            "": "",
15            "   ": "",
16            "https://authentik.company": "https://authentik.company",
17            "https://authentik.company/": "https://authentik.company",
18            "https://authentik.company///": "https://authentik.company",
19            "  https://authentik.company/  ": "https://authentik.company",
20            "https://authentik.company/authentik/": "https://authentik.company/authentik",
21        }
22        for value, expected in cases.items():
23            with self.subTest(value=value):
24                self.assertEqual(normalize_base_url(value), expected)
class TestNormalizeBaseURL(django.test.testcases.SimpleTestCase):
 9class TestNormalizeBaseURL(SimpleTestCase):
10    """normalize_base_url strips whitespace and trailing slashes"""
11
12    def test_normalize(self):
13        cases = {
14            None: "",
15            "": "",
16            "   ": "",
17            "https://authentik.company": "https://authentik.company",
18            "https://authentik.company/": "https://authentik.company",
19            "https://authentik.company///": "https://authentik.company",
20            "  https://authentik.company/  ": "https://authentik.company",
21            "https://authentik.company/authentik/": "https://authentik.company/authentik",
22        }
23        for value, expected in cases.items():
24            with self.subTest(value=value):
25                self.assertEqual(normalize_base_url(value), expected)

normalize_base_url strips whitespace and trailing slashes

def test_normalize(self):
12    def test_normalize(self):
13        cases = {
14            None: "",
15            "": "",
16            "   ": "",
17            "https://authentik.company": "https://authentik.company",
18            "https://authentik.company/": "https://authentik.company",
19            "https://authentik.company///": "https://authentik.company",
20            "  https://authentik.company/  ": "https://authentik.company",
21            "https://authentik.company/authentik/": "https://authentik.company/authentik",
22        }
23        for value, expected in cases.items():
24            with self.subTest(value=value):
25                self.assertEqual(normalize_base_url(value), expected)