authentik.flows.tests.test_stage_views

stage view tests

 1"""stage view tests"""
 2
 3from collections.abc import Callable
 4
 5from django.test import RequestFactory, TestCase
 6
 7from authentik.flows.stage import StageView
 8from authentik.flows.views.executor import FlowExecutorView
 9from authentik.lib.utils.reflection import all_subclasses
10
11
12class TestViews(TestCase):
13    """Generic model properties tests"""
14
15    def setUp(self) -> None:
16        self.factory = RequestFactory()
17        self.exec = FlowExecutorView(request=self.factory.get("/"))
18
19
20def view_tester_factory(view_class: type[StageView]) -> Callable:
21    """Test a form"""
22
23    def tester(self: TestViews):
24        model_class = view_class(self.exec)
25        if not hasattr(model_class, "dispatch"):
26            self.assertIsNotNone(model_class.post)
27            self.assertIsNotNone(model_class.get)
28
29    return tester
30
31
32for view in all_subclasses(StageView):
33    setattr(TestViews, f"test_view_{view.__name__}", view_tester_factory(view))
class TestViews(django.test.testcases.TestCase):
13class TestViews(TestCase):
14    """Generic model properties tests"""
15
16    def setUp(self) -> None:
17        self.factory = RequestFactory()
18        self.exec = FlowExecutorView(request=self.factory.get("/"))

Generic model properties tests

def setUp(self) -> None:
16    def setUp(self) -> None:
17        self.factory = RequestFactory()
18        self.exec = FlowExecutorView(request=self.factory.get("/"))

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

def test_view_AccessDeniedStage(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_AgentAuthFulfillmentStage(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_AuthenticatorDuoStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_AuthenticatorEmailStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_AuthenticatorEndpointStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_AuthenticatorSMSStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_AuthenticatorStaticStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_AuthenticatorTOTPStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_AuthenticatorValidateStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_AuthenticatorWebAuthnStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_AutosubmitStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_CaptchaStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_ChallengeStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_ConsentStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_DenyStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_EmailStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_EmailTokenRevocationConsentStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_EndpointStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_GoogleChromeStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_GroupUpdateStage(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_IdentificationStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_IframeLogoutStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_InvitationStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_MTLSStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_MessageStage(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_NativeLogoutStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_NativeLogoutStageViewBase(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_OAuthDeviceCodeFinishStage(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_OAuthDeviceCodeStage(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_OAuthFulfillmentStage(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_PasswordStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_PostSourceStage(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_PromptStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_RACFinalStage(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_RedirectStage(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_RedirectStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_RedirectToAppStage(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_SAMLFlowFinalView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_SessionEndStage(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_SourceStageFinal(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_SourceStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_TelegramLoginView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_UserDeleteStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_UserLoginStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_UserLogoutStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_UserWriteStageView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def test_view_WSFedFlowFinalView(self: TestViews):
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)

The type of the None singleton.

def view_tester_factory(view_class: type[authentik.flows.stage.StageView]) -> Callable:
21def view_tester_factory(view_class: type[StageView]) -> Callable:
22    """Test a form"""
23
24    def tester(self: TestViews):
25        model_class = view_class(self.exec)
26        if not hasattr(model_class, "dispatch"):
27            self.assertIsNotNone(model_class.post)
28            self.assertIsNotNone(model_class.get)
29
30    return tester

Test a form