authentik.core.tests.test_source_api
1from django.apps import apps 2from django.urls import reverse 3from rest_framework.test import APITestCase 4 5from authentik.core.tests.utils import create_test_admin_user 6 7 8class TestSourceAPI(APITestCase): 9 def setUp(self) -> None: 10 self.user = create_test_admin_user() 11 self.client.force_login(self.user) 12 13 def test_builtin_source_used_by(self): 14 """Test Providers's types endpoint""" 15 apps.get_app_config("authentik_core").source_inbuilt() 16 response = self.client.get( 17 reverse("authentik_api:source-used-by", kwargs={"slug": "authentik-built-in"}), 18 ) 19 self.assertEqual(response.status_code, 200)
class
TestSourceAPI(rest_framework.test.APITestCase):
9class TestSourceAPI(APITestCase): 10 def setUp(self) -> None: 11 self.user = create_test_admin_user() 12 self.client.force_login(self.user) 13 14 def test_builtin_source_used_by(self): 15 """Test Providers's types endpoint""" 16 apps.get_app_config("authentik_core").source_inbuilt() 17 response = self.client.get( 18 reverse("authentik_api:source-used-by", kwargs={"slug": "authentik-built-in"}), 19 ) 20 self.assertEqual(response.status_code, 200)
Similar to TransactionTestCase, but use transaction.atomic() to achieve
test isolation.
In most situations, TestCase should be preferred to TransactionTestCase as it allows faster execution. However, there are some situations where using TransactionTestCase might be necessary (e.g. testing some transactional behavior).
On database backends with no transaction support, TestCase behaves as TransactionTestCase.
def
setUp(self) -> None:
10 def setUp(self) -> None: 11 self.user = create_test_admin_user() 12 self.client.force_login(self.user)
Hook method for setting up the test fixture before exercising it.
def
test_builtin_source_used_by(self):
14 def test_builtin_source_used_by(self): 15 """Test Providers's types endpoint""" 16 apps.get_app_config("authentik_core").source_inbuilt() 17 response = self.client.get( 18 reverse("authentik_api:source-used-by", kwargs={"slug": "authentik-built-in"}), 19 ) 20 self.assertEqual(response.status_code, 200)
Test Providers's types endpoint