Skip to content

Commit

Permalink
flows: fix execute API endpoint (#9478)
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
  • Loading branch information
BeryJu authored Apr 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent a9c597b commit 6aab505
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion authentik/flows/api/flows.py
Original file line number Diff line number Diff line change
@@ -278,7 +278,7 @@ def set_background_url(self, request: Request, slug: str):
},
)
@action(detail=True, pagination_class=None, filter_backends=[])
def execute(self, request: Request, _slug: str):
def execute(self, request: Request, slug: str):
"""Execute flow for current user"""
# Because we pre-plan the flow here, and not in the planner, we need to manually clear
# the history of the inspector
19 changes: 19 additions & 0 deletions authentik/flows/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
from authentik.core.tests.utils import create_test_admin_user
from authentik.flows.api.stages import StageSerializer, StageViewSet
from authentik.flows.models import Flow, FlowDesignation, FlowStageBinding, Stage
from authentik.lib.generators import generate_id
from authentik.policies.dummy.models import DummyPolicy
from authentik.policies.models import PolicyBinding
from authentik.stages.dummy.models import DummyStage
@@ -101,3 +102,21 @@ def test_types(self):
reverse("authentik_api:stage-types"),
)
self.assertEqual(response.status_code, 200)

def test_execute(self):
"""Test execute endpoint"""
user = create_test_admin_user()
self.client.force_login(user)

flow = Flow.objects.create(
name=generate_id(),
slug=generate_id(),
designation=FlowDesignation.AUTHENTICATION,
)
FlowStageBinding.objects.create(
target=flow, stage=DummyStage.objects.create(name=generate_id()), order=0
)
response = self.client.get(
reverse("authentik_api:flow-execute", kwargs={"slug": flow.slug})
)
self.assertEqual(response.status_code, 200)

0 comments on commit 6aab505

Please sign in to comment.