From 4470fcba1dc6fa1c812a0b4ca69578a886261d9b Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 14 May 2026 02:31:03 +0200 Subject: [PATCH] fix more Signed-off-by: Jens Langhammer --- authentik/flows/tests/__init__.py | 3 ++- authentik/stages/authenticator_validate/tests/test_email.py | 6 +++--- .../stages/authenticator_validate/tests/test_webauthn.py | 1 - 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/authentik/flows/tests/__init__.py b/authentik/flows/tests/__init__.py index 4aa11374c2..fbc20cf234 100644 --- a/authentik/flows/tests/__init__.py +++ b/authentik/flows/tests/__init__.py @@ -2,6 +2,7 @@ from collections.abc import Callable, Generator from contextlib import contextmanager +from http import HTTPStatus from json import loads from typing import Any from unittest.mock import MagicMock, patch @@ -27,7 +28,7 @@ class FlowTestCase(APITestCase): **kwargs, ) -> dict[str, Any]: """Assert various attributes of a stage response""" - self.assertEqual(response.status_code, 200) + self.assertIn(response.status_code, [HTTPStatus.OK, HTTPStatus.BAD_REQUEST]) raw_response = loads(response.content.decode()) self.assertIsNotNone(raw_response["component"]) if flow: diff --git a/authentik/stages/authenticator_validate/tests/test_email.py b/authentik/stages/authenticator_validate/tests/test_email.py index 03f32f993a..3f3d00c8ca 100644 --- a/authentik/stages/authenticator_validate/tests/test_email.py +++ b/authentik/stages/authenticator_validate/tests/test_email.py @@ -8,6 +8,7 @@ from authentik.flows.models import FlowStageBinding, NotConfiguredAction from authentik.flows.tests import FlowTestCase from authentik.lib.generators import generate_id from authentik.lib.utils.email import mask_email +from authentik.stages.authenticator.models import Device from authentik.stages.authenticator_email.models import AuthenticatorEmailStage, EmailDevice from authentik.stages.authenticator_validate.models import AuthenticatorValidateStage, DeviceClasses from authentik.stages.identification.models import IdentificationStage, UserFields @@ -50,7 +51,7 @@ class AuthenticatorValidateStageEmailTests(FlowTestCase): self.assertEqual(response.status_code, 200) return response - def _send_challenge(self, device): + def _send_challenge(self, device: Device): """Helper to send challenge for device""" response = self.client.post( reverse("authentik_api:flow-executor", kwargs={"flow_slug": self.flow.slug}), @@ -64,7 +65,7 @@ class AuthenticatorValidateStageEmailTests(FlowTestCase): }, }, ) - self.assertEqual(response.status_code, 200) + self.assertEqual(response.status_code, 400) return response def test_happy_path(self): @@ -125,7 +126,6 @@ class AuthenticatorValidateStageEmailTests(FlowTestCase): reverse("authentik_api:flow-executor", kwargs={"flow_slug": flow.slug}), {"component": "ak-stage-authenticator-validate"}, ) - self.assertEqual(response.status_code, 200) response_data = self.assertStageResponse( response, flow=flow, diff --git a/authentik/stages/authenticator_validate/tests/test_webauthn.py b/authentik/stages/authenticator_validate/tests/test_webauthn.py index 4b8a51f77a..5cab036b62 100644 --- a/authentik/stages/authenticator_validate/tests/test_webauthn.py +++ b/authentik/stages/authenticator_validate/tests/test_webauthn.py @@ -501,7 +501,6 @@ class AuthenticatorValidateStageWebAuthnTests(FlowTestCase): SERVER_NAME="localhost", SERVER_PORT="9000", ) - self.assertEqual(response.status_code, 200) self.assertStageResponse( response, flow,