use create_test_flow where possible
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
be64296494
commit
aeff24d034
|
@ -5,8 +5,7 @@ from django.urls import reverse
|
||||||
from rest_framework.test import APITestCase
|
from rest_framework.test import APITestCase
|
||||||
|
|
||||||
from authentik.core.models import Application
|
from authentik.core.models import Application
|
||||||
from authentik.core.tests.utils import create_test_admin_user
|
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
||||||
from authentik.flows.models import Flow
|
|
||||||
from authentik.policies.dummy.models import DummyPolicy
|
from authentik.policies.dummy.models import DummyPolicy
|
||||||
from authentik.policies.models import PolicyBinding
|
from authentik.policies.models import PolicyBinding
|
||||||
from authentik.providers.oauth2.models import OAuth2Provider
|
from authentik.providers.oauth2.models import OAuth2Provider
|
||||||
|
@ -20,10 +19,7 @@ class TestApplicationsAPI(APITestCase):
|
||||||
self.provider = OAuth2Provider.objects.create(
|
self.provider = OAuth2Provider.objects.create(
|
||||||
name="test",
|
name="test",
|
||||||
redirect_uris="http://some-other-domain",
|
redirect_uris="http://some-other-domain",
|
||||||
authorization_flow=Flow.objects.create(
|
authorization_flow=create_test_flow(),
|
||||||
name="test",
|
|
||||||
slug="test",
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
self.allowed = Application.objects.create(
|
self.allowed = Application.objects.create(
|
||||||
name="allowed",
|
name="allowed",
|
||||||
|
|
|
@ -4,8 +4,7 @@ from unittest.mock import MagicMock, patch
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from authentik.core.models import Application
|
from authentik.core.models import Application
|
||||||
from authentik.core.tests.utils import create_test_admin_user, create_test_tenant
|
from authentik.core.tests.utils import create_test_admin_user, create_test_flow, create_test_tenant
|
||||||
from authentik.flows.models import Flow, FlowDesignation
|
|
||||||
from authentik.flows.tests import FlowTestCase
|
from authentik.flows.tests import FlowTestCase
|
||||||
from authentik.tenants.models import Tenant
|
from authentik.tenants.models import Tenant
|
||||||
|
|
||||||
|
@ -21,11 +20,7 @@ class TestApplicationsViews(FlowTestCase):
|
||||||
|
|
||||||
def test_check_redirect(self):
|
def test_check_redirect(self):
|
||||||
"""Test redirect"""
|
"""Test redirect"""
|
||||||
empty_flow = Flow.objects.create(
|
empty_flow = create_test_flow()
|
||||||
name="foo",
|
|
||||||
slug="foo",
|
|
||||||
designation=FlowDesignation.AUTHENTICATION,
|
|
||||||
)
|
|
||||||
tenant: Tenant = create_test_tenant()
|
tenant: Tenant = create_test_tenant()
|
||||||
tenant.flow_authentication = empty_flow
|
tenant.flow_authentication = empty_flow
|
||||||
tenant.save()
|
tenant.save()
|
||||||
|
@ -49,11 +44,7 @@ class TestApplicationsViews(FlowTestCase):
|
||||||
def test_check_redirect_auth(self):
|
def test_check_redirect_auth(self):
|
||||||
"""Test redirect"""
|
"""Test redirect"""
|
||||||
self.client.force_login(self.user)
|
self.client.force_login(self.user)
|
||||||
empty_flow = Flow.objects.create(
|
empty_flow = create_test_flow()
|
||||||
name="foo",
|
|
||||||
slug="foo",
|
|
||||||
designation=FlowDesignation.AUTHENTICATION,
|
|
||||||
)
|
|
||||||
tenant: Tenant = create_test_tenant()
|
tenant: Tenant = create_test_tenant()
|
||||||
tenant.flow_authentication = empty_flow
|
tenant.flow_authentication = empty_flow
|
||||||
tenant.save()
|
tenant.save()
|
||||||
|
|
|
@ -6,7 +6,7 @@ from guardian.utils import get_anonymous_user
|
||||||
|
|
||||||
from authentik.core.models import SourceUserMatchingModes, User
|
from authentik.core.models import SourceUserMatchingModes, User
|
||||||
from authentik.core.sources.flow_manager import Action
|
from authentik.core.sources.flow_manager import Action
|
||||||
from authentik.flows.models import Flow, FlowDesignation
|
from authentik.core.tests.utils import create_test_flow
|
||||||
from authentik.lib.generators import generate_id
|
from authentik.lib.generators import generate_id
|
||||||
from authentik.lib.tests.utils import get_request
|
from authentik.lib.tests.utils import get_request
|
||||||
from authentik.policies.denied import AccessDeniedResponse
|
from authentik.policies.denied import AccessDeniedResponse
|
||||||
|
@ -152,9 +152,7 @@ class TestSourceFlowManager(TestCase):
|
||||||
"""Test error handling when a source selected flow is non-applicable due to a policy"""
|
"""Test error handling when a source selected flow is non-applicable due to a policy"""
|
||||||
self.source.user_matching_mode = SourceUserMatchingModes.USERNAME_LINK
|
self.source.user_matching_mode = SourceUserMatchingModes.USERNAME_LINK
|
||||||
|
|
||||||
flow = Flow.objects.create(
|
flow = create_test_flow()
|
||||||
name="test", slug="test", title="test", designation=FlowDesignation.ENROLLMENT
|
|
||||||
)
|
|
||||||
policy = ExpressionPolicy.objects.create(
|
policy = ExpressionPolicy.objects.create(
|
||||||
name="false", expression="""ak_message("foo");return False"""
|
name="false", expression="""ak_message("foo");return False"""
|
||||||
)
|
)
|
||||||
|
|
|
@ -6,10 +6,9 @@ from django.test.client import RequestFactory
|
||||||
from django.urls.base import reverse
|
from django.urls.base import reverse
|
||||||
from rest_framework.test import APITestCase
|
from rest_framework.test import APITestCase
|
||||||
|
|
||||||
from authentik.core.tests.utils import create_test_admin_user
|
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
||||||
from authentik.flows.challenge import ChallengeTypes
|
from authentik.flows.challenge import ChallengeTypes
|
||||||
from authentik.flows.models import Flow, FlowDesignation, FlowStageBinding, InvalidResponseAction
|
from authentik.flows.models import FlowStageBinding, InvalidResponseAction
|
||||||
from authentik.lib.generators import generate_id
|
|
||||||
from authentik.stages.dummy.models import DummyStage
|
from authentik.stages.dummy.models import DummyStage
|
||||||
from authentik.stages.identification.models import IdentificationStage, UserFields
|
from authentik.stages.identification.models import IdentificationStage, UserFields
|
||||||
|
|
||||||
|
@ -24,11 +23,7 @@ class TestFlowInspector(APITestCase):
|
||||||
|
|
||||||
def test(self):
|
def test(self):
|
||||||
"""test inspector"""
|
"""test inspector"""
|
||||||
flow = Flow.objects.create(
|
flow = create_test_flow()
|
||||||
name=generate_id(),
|
|
||||||
slug=generate_id(),
|
|
||||||
designation=FlowDesignation.AUTHENTICATION,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Stage 1 is an identification stage
|
# Stage 1 is an identification stage
|
||||||
ident_stage = IdentificationStage.objects.create(
|
ident_stage = IdentificationStage.objects.create(
|
||||||
|
|
|
@ -8,9 +8,10 @@ from django.urls import reverse
|
||||||
from guardian.shortcuts import get_anonymous_user
|
from guardian.shortcuts import get_anonymous_user
|
||||||
|
|
||||||
from authentik.core.models import User
|
from authentik.core.models import User
|
||||||
|
from authentik.core.tests.utils import create_test_flow
|
||||||
from authentik.flows.exceptions import EmptyFlowException, FlowNonApplicableException
|
from authentik.flows.exceptions import EmptyFlowException, FlowNonApplicableException
|
||||||
from authentik.flows.markers import ReevaluateMarker, StageMarker
|
from authentik.flows.markers import ReevaluateMarker, StageMarker
|
||||||
from authentik.flows.models import Flow, FlowDesignation, FlowStageBinding
|
from authentik.flows.models import FlowStageBinding
|
||||||
from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER, FlowPlanner, cache_key
|
from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER, FlowPlanner, cache_key
|
||||||
from authentik.lib.tests.utils import dummy_get_response
|
from authentik.lib.tests.utils import dummy_get_response
|
||||||
from authentik.policies.dummy.models import DummyPolicy
|
from authentik.policies.dummy.models import DummyPolicy
|
||||||
|
@ -32,11 +33,7 @@ class TestFlowPlanner(TestCase):
|
||||||
|
|
||||||
def test_empty_plan(self):
|
def test_empty_plan(self):
|
||||||
"""Test that empty plan raises exception"""
|
"""Test that empty plan raises exception"""
|
||||||
flow = Flow.objects.create(
|
flow = create_test_flow()
|
||||||
name="test-empty",
|
|
||||||
slug="test-empty",
|
|
||||||
designation=FlowDesignation.AUTHENTICATION,
|
|
||||||
)
|
|
||||||
request = self.request_factory.get(
|
request = self.request_factory.get(
|
||||||
reverse("authentik_api:flow-executor", kwargs={"flow_slug": flow.slug}),
|
reverse("authentik_api:flow-executor", kwargs={"flow_slug": flow.slug}),
|
||||||
)
|
)
|
||||||
|
@ -52,11 +49,7 @@ class TestFlowPlanner(TestCase):
|
||||||
)
|
)
|
||||||
def test_non_applicable_plan(self):
|
def test_non_applicable_plan(self):
|
||||||
"""Test that empty plan raises exception"""
|
"""Test that empty plan raises exception"""
|
||||||
flow = Flow.objects.create(
|
flow = create_test_flow()
|
||||||
name="test-empty",
|
|
||||||
slug="test-empty",
|
|
||||||
designation=FlowDesignation.AUTHENTICATION,
|
|
||||||
)
|
|
||||||
request = self.request_factory.get(
|
request = self.request_factory.get(
|
||||||
reverse("authentik_api:flow-executor", kwargs={"flow_slug": flow.slug}),
|
reverse("authentik_api:flow-executor", kwargs={"flow_slug": flow.slug}),
|
||||||
)
|
)
|
||||||
|
@ -69,11 +62,7 @@ class TestFlowPlanner(TestCase):
|
||||||
@patch("authentik.flows.planner.cache", CACHE_MOCK)
|
@patch("authentik.flows.planner.cache", CACHE_MOCK)
|
||||||
def test_planner_cache(self):
|
def test_planner_cache(self):
|
||||||
"""Test planner cache"""
|
"""Test planner cache"""
|
||||||
flow = Flow.objects.create(
|
flow = create_test_flow()
|
||||||
name="test-cache",
|
|
||||||
slug="test-cache",
|
|
||||||
designation=FlowDesignation.AUTHENTICATION,
|
|
||||||
)
|
|
||||||
FlowStageBinding.objects.create(
|
FlowStageBinding.objects.create(
|
||||||
target=flow, stage=DummyStage.objects.create(name="dummy"), order=0
|
target=flow, stage=DummyStage.objects.create(name="dummy"), order=0
|
||||||
)
|
)
|
||||||
|
@ -92,11 +81,7 @@ class TestFlowPlanner(TestCase):
|
||||||
|
|
||||||
def test_planner_default_context(self):
|
def test_planner_default_context(self):
|
||||||
"""Test planner with default_context"""
|
"""Test planner with default_context"""
|
||||||
flow = Flow.objects.create(
|
flow = create_test_flow()
|
||||||
name="test-default-context",
|
|
||||||
slug="test-default-context",
|
|
||||||
designation=FlowDesignation.AUTHENTICATION,
|
|
||||||
)
|
|
||||||
FlowStageBinding.objects.create(
|
FlowStageBinding.objects.create(
|
||||||
target=flow, stage=DummyStage.objects.create(name="dummy"), order=0
|
target=flow, stage=DummyStage.objects.create(name="dummy"), order=0
|
||||||
)
|
)
|
||||||
|
@ -113,11 +98,7 @@ class TestFlowPlanner(TestCase):
|
||||||
|
|
||||||
def test_planner_marker_reevaluate(self):
|
def test_planner_marker_reevaluate(self):
|
||||||
"""Test that the planner creates the proper marker"""
|
"""Test that the planner creates the proper marker"""
|
||||||
flow = Flow.objects.create(
|
flow = create_test_flow()
|
||||||
name="test-default-context",
|
|
||||||
slug="test-default-context",
|
|
||||||
designation=FlowDesignation.AUTHENTICATION,
|
|
||||||
)
|
|
||||||
|
|
||||||
FlowStageBinding.objects.create(
|
FlowStageBinding.objects.create(
|
||||||
target=flow,
|
target=flow,
|
||||||
|
@ -138,11 +119,7 @@ class TestFlowPlanner(TestCase):
|
||||||
|
|
||||||
def test_planner_reevaluate_actual(self):
|
def test_planner_reevaluate_actual(self):
|
||||||
"""Test planner with re-evaluate"""
|
"""Test planner with re-evaluate"""
|
||||||
flow = Flow.objects.create(
|
flow = create_test_flow()
|
||||||
name="test-default-context",
|
|
||||||
slug="test-default-context",
|
|
||||||
designation=FlowDesignation.AUTHENTICATION,
|
|
||||||
)
|
|
||||||
false_policy = DummyPolicy.objects.create(result=False, wait_min=1, wait_max=2)
|
false_policy = DummyPolicy.objects.create(result=False, wait_min=1, wait_max=2)
|
||||||
|
|
||||||
binding = FlowStageBinding.objects.create(
|
binding = FlowStageBinding.objects.create(
|
||||||
|
|
|
@ -6,7 +6,7 @@ from channels.testing import WebsocketCommunicator
|
||||||
from django.test import TransactionTestCase
|
from django.test import TransactionTestCase
|
||||||
|
|
||||||
from authentik import __version__
|
from authentik import __version__
|
||||||
from authentik.flows.models import Flow, FlowDesignation
|
from authentik.core.tests.utils import create_test_flow
|
||||||
from authentik.outposts.channels import WebsocketMessage, WebsocketMessageInstruction
|
from authentik.outposts.channels import WebsocketMessage, WebsocketMessageInstruction
|
||||||
from authentik.outposts.models import Outpost, OutpostType
|
from authentik.outposts.models import Outpost, OutpostType
|
||||||
from authentik.providers.proxy.models import ProxyProvider
|
from authentik.providers.proxy.models import ProxyProvider
|
||||||
|
@ -21,9 +21,7 @@ class TestOutpostWS(TransactionTestCase):
|
||||||
name="test",
|
name="test",
|
||||||
internal_host="http://localhost",
|
internal_host="http://localhost",
|
||||||
external_host="http://localhost",
|
external_host="http://localhost",
|
||||||
authorization_flow=Flow.objects.create(
|
authorization_flow=create_test_flow(),
|
||||||
name="foo", slug="foo", designation=FlowDesignation.AUTHORIZATION
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
self.outpost: Outpost = Outpost.objects.create(
|
self.outpost: Outpost = Outpost.objects.create(
|
||||||
name="test",
|
name="test",
|
||||||
|
|
|
@ -4,8 +4,8 @@ from unittest.mock import MagicMock, patch
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
from django.urls.base import reverse
|
from django.urls.base import reverse
|
||||||
|
|
||||||
from authentik.core.tests.utils import create_test_admin_user
|
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
||||||
from authentik.flows.models import Flow, FlowStageBinding, NotConfiguredAction
|
from authentik.flows.models import FlowStageBinding, NotConfiguredAction
|
||||||
from authentik.flows.tests import FlowTestCase
|
from authentik.flows.tests import FlowTestCase
|
||||||
from authentik.lib.generators import generate_id
|
from authentik.lib.generators import generate_id
|
||||||
from authentik.stages.authenticator_sms.models import AuthenticatorSMSStage, SMSDevice, SMSProviders
|
from authentik.stages.authenticator_sms.models import AuthenticatorSMSStage, SMSDevice, SMSProviders
|
||||||
|
@ -47,7 +47,7 @@ class AuthenticatorValidateStageSMSTests(FlowTestCase):
|
||||||
device_classes=[DeviceClasses.SMS],
|
device_classes=[DeviceClasses.SMS],
|
||||||
)
|
)
|
||||||
stage.configuration_stages.set([ident_stage])
|
stage.configuration_stages.set([ident_stage])
|
||||||
flow = Flow.objects.create(name="test", slug="test", title="test")
|
flow = create_test_flow()
|
||||||
FlowStageBinding.objects.create(target=flow, stage=ident_stage, order=0)
|
FlowStageBinding.objects.create(target=flow, stage=ident_stage, order=0)
|
||||||
FlowStageBinding.objects.create(target=flow, stage=stage, order=1)
|
FlowStageBinding.objects.create(target=flow, stage=stage, order=1)
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class AuthenticatorValidateStageSMSTests(FlowTestCase):
|
||||||
device_classes=[DeviceClasses.SMS],
|
device_classes=[DeviceClasses.SMS],
|
||||||
)
|
)
|
||||||
stage.configuration_stages.set([ident_stage])
|
stage.configuration_stages.set([ident_stage])
|
||||||
flow = Flow.objects.create(name="test", slug="test", title="test")
|
flow = create_test_flow()
|
||||||
FlowStageBinding.objects.create(target=flow, stage=ident_stage, order=0)
|
FlowStageBinding.objects.create(target=flow, stage=ident_stage, order=0)
|
||||||
FlowStageBinding.objects.create(target=flow, stage=stage, order=1)
|
FlowStageBinding.objects.create(target=flow, stage=stage, order=1)
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ class AuthenticatorValidateStageSMSTests(FlowTestCase):
|
||||||
device_classes=[DeviceClasses.SMS],
|
device_classes=[DeviceClasses.SMS],
|
||||||
)
|
)
|
||||||
stage.configuration_stages.set([ident_stage])
|
stage.configuration_stages.set([ident_stage])
|
||||||
flow = Flow.objects.create(name="test", slug="test", title="test")
|
flow = create_test_flow()
|
||||||
FlowStageBinding.objects.create(target=flow, stage=ident_stage, order=0)
|
FlowStageBinding.objects.create(target=flow, stage=ident_stage, order=0)
|
||||||
FlowStageBinding.objects.create(target=flow, stage=stage, order=1)
|
FlowStageBinding.objects.create(target=flow, stage=stage, order=1)
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ from django.test.client import RequestFactory
|
||||||
from django.urls.base import reverse
|
from django.urls.base import reverse
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
|
|
||||||
from authentik.core.tests.utils import create_test_admin_user
|
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
||||||
from authentik.flows.models import Flow, FlowStageBinding, NotConfiguredAction
|
from authentik.flows.models import FlowStageBinding, NotConfiguredAction
|
||||||
from authentik.flows.stage import StageView
|
from authentik.flows.stage import StageView
|
||||||
from authentik.flows.tests import FlowTestCase
|
from authentik.flows.tests import FlowTestCase
|
||||||
from authentik.flows.views.executor import FlowExecutorView
|
from authentik.flows.views.executor import FlowExecutorView
|
||||||
|
@ -40,7 +40,7 @@ class AuthenticatorValidateStageTests(FlowTestCase):
|
||||||
not_configured_action=NotConfiguredAction.CONFIGURE,
|
not_configured_action=NotConfiguredAction.CONFIGURE,
|
||||||
)
|
)
|
||||||
stage.configuration_stages.set([conf_stage])
|
stage.configuration_stages.set([conf_stage])
|
||||||
flow = Flow.objects.create(name="test", slug="test", title="test")
|
flow = create_test_flow()
|
||||||
FlowStageBinding.objects.create(target=flow, stage=conf_stage, order=0)
|
FlowStageBinding.objects.create(target=flow, stage=conf_stage, order=0)
|
||||||
FlowStageBinding.objects.create(target=flow, stage=stage, order=1)
|
FlowStageBinding.objects.create(target=flow, stage=stage, order=1)
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ from webauthn.helpers.base64url_to_bytes import base64url_to_bytes
|
||||||
from webauthn.helpers.bytes_to_base64url import bytes_to_base64url
|
from webauthn.helpers.bytes_to_base64url import bytes_to_base64url
|
||||||
|
|
||||||
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
||||||
from authentik.flows.models import Flow, FlowStageBinding, NotConfiguredAction
|
from authentik.flows.models import FlowStageBinding, NotConfiguredAction
|
||||||
from authentik.flows.stage import StageView
|
from authentik.flows.stage import StageView
|
||||||
from authentik.flows.tests import FlowTestCase
|
from authentik.flows.tests import FlowTestCase
|
||||||
from authentik.flows.views.executor import FlowExecutorView
|
from authentik.flows.views.executor import FlowExecutorView
|
||||||
|
@ -54,7 +54,7 @@ class AuthenticatorValidateStageWebAuthnTests(FlowTestCase):
|
||||||
)
|
)
|
||||||
sleep(1)
|
sleep(1)
|
||||||
stage.configuration_stages.set([ident_stage])
|
stage.configuration_stages.set([ident_stage])
|
||||||
flow = Flow.objects.create(name="test", slug="test", title="test")
|
flow = create_test_flow()
|
||||||
FlowStageBinding.objects.create(target=flow, stage=ident_stage, order=0)
|
FlowStageBinding.objects.create(target=flow, stage=ident_stage, order=0)
|
||||||
FlowStageBinding.objects.create(target=flow, stage=stage, order=1)
|
FlowStageBinding.objects.create(target=flow, stage=stage, order=1)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ from django.urls import reverse
|
||||||
|
|
||||||
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
||||||
from authentik.flows.challenge import ChallengeTypes
|
from authentik.flows.challenge import ChallengeTypes
|
||||||
from authentik.flows.models import Flow, FlowDesignation, FlowStageBinding
|
from authentik.flows.models import FlowDesignation, FlowStageBinding
|
||||||
from authentik.flows.tests import FlowTestCase
|
from authentik.flows.tests import FlowTestCase
|
||||||
from authentik.sources.oauth.models import OAuthSource
|
from authentik.sources.oauth.models import OAuthSource
|
||||||
from authentik.stages.identification.models import IdentificationStage, UserFields
|
from authentik.stages.identification.models import IdentificationStage, UserFields
|
||||||
|
@ -148,12 +148,7 @@ class TestIdentificationStage(FlowTestCase):
|
||||||
|
|
||||||
def test_enrollment_flow(self):
|
def test_enrollment_flow(self):
|
||||||
"""Test that enrollment flow is linked correctly"""
|
"""Test that enrollment flow is linked correctly"""
|
||||||
flow = Flow.objects.create(
|
flow = create_test_flow()
|
||||||
name="enroll-test",
|
|
||||||
slug="unique-enrollment-string",
|
|
||||||
title="unique-enrollment-string",
|
|
||||||
designation=FlowDesignation.ENROLLMENT,
|
|
||||||
)
|
|
||||||
self.stage.enrollment_flow = flow
|
self.stage.enrollment_flow = flow
|
||||||
self.stage.save()
|
self.stage.save()
|
||||||
FlowStageBinding.objects.create(
|
FlowStageBinding.objects.create(
|
||||||
|
@ -192,11 +187,7 @@ class TestIdentificationStage(FlowTestCase):
|
||||||
|
|
||||||
def test_recovery_flow(self):
|
def test_recovery_flow(self):
|
||||||
"""Test that recovery flow is linked correctly"""
|
"""Test that recovery flow is linked correctly"""
|
||||||
flow = Flow.objects.create(
|
flow = create_test_flow()
|
||||||
name="recovery-test",
|
|
||||||
slug="unique-recovery-string",
|
|
||||||
designation=FlowDesignation.RECOVERY,
|
|
||||||
)
|
|
||||||
self.stage.recovery_flow = flow
|
self.stage.recovery_flow = flow
|
||||||
self.stage.save()
|
self.stage.save()
|
||||||
FlowStageBinding.objects.create(
|
FlowStageBinding.objects.create(
|
||||||
|
|
|
@ -5,9 +5,9 @@ from django.test import RequestFactory
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from rest_framework.exceptions import ErrorDetail, ValidationError
|
from rest_framework.exceptions import ErrorDetail, ValidationError
|
||||||
|
|
||||||
from authentik.core.tests.utils import create_test_admin_user
|
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
||||||
from authentik.flows.markers import StageMarker
|
from authentik.flows.markers import StageMarker
|
||||||
from authentik.flows.models import Flow, FlowDesignation, FlowStageBinding
|
from authentik.flows.models import FlowStageBinding
|
||||||
from authentik.flows.planner import FlowPlan
|
from authentik.flows.planner import FlowPlan
|
||||||
from authentik.flows.tests import FlowTestCase
|
from authentik.flows.tests import FlowTestCase
|
||||||
from authentik.flows.views.executor import SESSION_KEY_PLAN
|
from authentik.flows.views.executor import SESSION_KEY_PLAN
|
||||||
|
@ -24,11 +24,7 @@ class TestPromptStage(FlowTestCase):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.user = create_test_admin_user()
|
self.user = create_test_admin_user()
|
||||||
self.factory = RequestFactory()
|
self.factory = RequestFactory()
|
||||||
self.flow = Flow.objects.create(
|
self.flow = create_test_flow()
|
||||||
name="test-prompt",
|
|
||||||
slug="test-prompt",
|
|
||||||
designation=FlowDesignation.AUTHENTICATION,
|
|
||||||
)
|
|
||||||
username_prompt = Prompt.objects.create(
|
username_prompt = Prompt.objects.create(
|
||||||
field_key="username_prompt",
|
field_key="username_prompt",
|
||||||
label="USERNAME_LABEL",
|
label="USERNAME_LABEL",
|
||||||
|
|
|
@ -7,9 +7,9 @@ from django.urls import reverse
|
||||||
|
|
||||||
from authentik.core.models import USER_ATTRIBUTE_SOURCES, Group, Source, User, UserSourceConnection
|
from authentik.core.models import USER_ATTRIBUTE_SOURCES, Group, Source, User, UserSourceConnection
|
||||||
from authentik.core.sources.stage import PLAN_CONTEXT_SOURCES_CONNECTION
|
from authentik.core.sources.stage import PLAN_CONTEXT_SOURCES_CONNECTION
|
||||||
from authentik.core.tests.utils import create_test_admin_user
|
from authentik.core.tests.utils import create_test_admin_user, create_test_flow
|
||||||
from authentik.flows.markers import StageMarker
|
from authentik.flows.markers import StageMarker
|
||||||
from authentik.flows.models import Flow, FlowDesignation, FlowStageBinding
|
from authentik.flows.models import FlowStageBinding
|
||||||
from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER, FlowPlan
|
from authentik.flows.planner import PLAN_CONTEXT_PENDING_USER, FlowPlan
|
||||||
from authentik.flows.tests import FlowTestCase
|
from authentik.flows.tests import FlowTestCase
|
||||||
from authentik.flows.tests.test_executor import TO_STAGE_RESPONSE_MOCK
|
from authentik.flows.tests.test_executor import TO_STAGE_RESPONSE_MOCK
|
||||||
|
@ -24,11 +24,7 @@ class TestUserWriteStage(FlowTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super().setUp()
|
super().setUp()
|
||||||
self.flow = Flow.objects.create(
|
self.flow = create_test_flow()
|
||||||
name="test-write",
|
|
||||||
slug="test-write",
|
|
||||||
designation=FlowDesignation.AUTHENTICATION,
|
|
||||||
)
|
|
||||||
self.group = Group.objects.create(name="test-group")
|
self.group = Group.objects.create(name="test-group")
|
||||||
self.other_group = Group.objects.create(name="other-group")
|
self.other_group = Group.objects.create(name="other-group")
|
||||||
self.stage = UserWriteStage.objects.create(
|
self.stage = UserWriteStage.objects.create(
|
||||||
|
|
|
@ -10,8 +10,8 @@ from docker.models.containers import Container
|
||||||
from docker.types.healthcheck import Healthcheck
|
from docker.types.healthcheck import Healthcheck
|
||||||
|
|
||||||
from authentik import __version__
|
from authentik import __version__
|
||||||
|
from authentik.core.tests.utils import create_test_flow
|
||||||
from authentik.crypto.models import CertificateKeyPair
|
from authentik.crypto.models import CertificateKeyPair
|
||||||
from authentik.flows.models import Flow, FlowDesignation
|
|
||||||
from authentik.outposts.controllers.docker import DockerController
|
from authentik.outposts.controllers.docker import DockerController
|
||||||
from authentik.outposts.models import (
|
from authentik.outposts.models import (
|
||||||
DockerServiceConnection,
|
DockerServiceConnection,
|
||||||
|
@ -64,9 +64,7 @@ class OutpostDockerTests(ChannelsLiveServerTestCase):
|
||||||
name="test",
|
name="test",
|
||||||
internal_host="http://localhost",
|
internal_host="http://localhost",
|
||||||
external_host="http://localhost",
|
external_host="http://localhost",
|
||||||
authorization_flow=Flow.objects.create(
|
authorization_flow=create_test_flow(),
|
||||||
name="foo", slug="foo", designation=FlowDesignation.AUTHORIZATION
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
authentication_kp = CertificateKeyPair.objects.create(
|
authentication_kp = CertificateKeyPair.objects.create(
|
||||||
name="docker-authentication",
|
name="docker-authentication",
|
||||||
|
|
|
@ -10,8 +10,8 @@ from docker.models.containers import Container
|
||||||
from docker.types.healthcheck import Healthcheck
|
from docker.types.healthcheck import Healthcheck
|
||||||
|
|
||||||
from authentik import __version__
|
from authentik import __version__
|
||||||
|
from authentik.core.tests.utils import create_test_flow
|
||||||
from authentik.crypto.models import CertificateKeyPair
|
from authentik.crypto.models import CertificateKeyPair
|
||||||
from authentik.flows.models import Flow, FlowDesignation
|
|
||||||
from authentik.outposts.models import (
|
from authentik.outposts.models import (
|
||||||
DockerServiceConnection,
|
DockerServiceConnection,
|
||||||
Outpost,
|
Outpost,
|
||||||
|
@ -64,9 +64,7 @@ class TestProxyDocker(ChannelsLiveServerTestCase):
|
||||||
name="test",
|
name="test",
|
||||||
internal_host="http://localhost",
|
internal_host="http://localhost",
|
||||||
external_host="http://localhost",
|
external_host="http://localhost",
|
||||||
authorization_flow=Flow.objects.create(
|
authorization_flow=create_test_flow(),
|
||||||
name="foo", slug="foo", designation=FlowDesignation.AUTHORIZATION
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
authentication_kp = CertificateKeyPair.objects.create(
|
authentication_kp = CertificateKeyPair.objects.create(
|
||||||
name="docker-authentication",
|
name="docker-authentication",
|
||||||
|
|
Reference in a new issue