From 59b45b16dd091367c3bef6f6707a097f9acae5e3 Mon Sep 17 00:00:00 2001 From: Matthew Elwell Date: Tue, 30 Jul 2024 12:29:33 +0100 Subject: [PATCH] Fix unit tests --- api/e2etests/middleware.py | 5 ++++- .../e2etests/end_to_end/test_integration_e2e_tests.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api/e2etests/middleware.py b/api/e2etests/middleware.py index 3d1b7c1011b9e..c57c3aeef4ec8 100644 --- a/api/e2etests/middleware.py +++ b/api/e2etests/middleware.py @@ -7,7 +7,10 @@ def __init__(self, get_response): def __call__(self, request): request.is_e2e = False - if request.META.get("E2E_TEST_AUTH_TOKEN") == settings.E2E_TEST_AUTH_TOKEN: + if ( + request.META.get("HTTP_X_E2E_TEST_AUTH_TOKEN") + == settings.E2E_TEST_AUTH_TOKEN + ): request.is_e2e = True return self.get_response(request) diff --git a/api/tests/integration/e2etests/end_to_end/test_integration_e2e_tests.py b/api/tests/integration/e2etests/end_to_end/test_integration_e2e_tests.py index 7ebb0115e98cc..731ffe28d3a25 100644 --- a/api/tests/integration/e2etests/end_to_end/test_integration_e2e_tests.py +++ b/api/tests/integration/e2etests/end_to_end/test_integration_e2e_tests.py @@ -15,8 +15,8 @@ def test_e2e_teardown(settings, db) -> None: token = "test-token" register_url = "/api/v1/auth/users/" settings.ENABLE_FE_E2E = True - - os.environ["E2E_TEST_AUTH_TOKEN"] = token + settings.E2E_TEST_AUTH_TOKEN = token + settings.MIDDLEWARE.append("e2etests.middleware.E2ETestMiddleware") client = APIClient(HTTP_X_E2E_TEST_AUTH_TOKEN=token)