From 8bb2d1af9b53c846f0f56432d8d509013cf38f85 Mon Sep 17 00:00:00 2001 From: KShivendu Date: Mon, 10 Jul 2023 13:23:52 +0530 Subject: [PATCH 1/2] test: Fix frontend integration tests failure --- tests/frontendIntegration/django2x/polls/urls.py | 1 + tests/frontendIntegration/django2x/polls/views.py | 5 +++++ tests/frontendIntegration/django3x/polls/urls.py | 1 + tests/frontendIntegration/django3x/polls/views.py | 5 +++++ tests/frontendIntegration/fastapi-server/app.py | 5 +++++ tests/frontendIntegration/flask-server/app.py | 5 +++++ 6 files changed, 22 insertions(+) diff --git a/tests/frontendIntegration/django2x/polls/urls.py b/tests/frontendIntegration/django2x/polls/urls.py index 0ac62fb25..c5e764cf8 100644 --- a/tests/frontendIntegration/django2x/polls/urls.py +++ b/tests/frontendIntegration/django2x/polls/urls.py @@ -14,6 +14,7 @@ name="multipleInterceptors", ), path("", views.get_info, name="/"), # type: ignore + path("check-rid-no-session", views.check_rid_no_session, name="check-rid-no-session"), # type: ignore path("update-jwt", views.update_jwt, name="update_jwt"), # type: ignore path("update-jwt-with-handle", views.update_jwt_with_handle, name="update_jwt_with_handle"), # type: ignore path("session-claims-error", views.session_claim_error_api, name="session_claim_error_api"), # type: ignore diff --git a/tests/frontendIntegration/django2x/polls/views.py b/tests/frontendIntegration/django2x/polls/views.py index f044ce808..a6f45c12b 100644 --- a/tests/frontendIntegration/django2x/polls/views.py +++ b/tests/frontendIntegration/django2x/polls/views.py @@ -434,6 +434,11 @@ def get_info(request: HttpRequest): return HttpResponse("") +def check_rid_no_session(request: HttpRequest): + rid = request.headers.get("rid") # type: ignore + return HttpResponse("fail" if rid is None else "success") + + @custom_decorator_for_update_jwt() @verify_session() def update_jwt(request: HttpRequest): diff --git a/tests/frontendIntegration/django3x/polls/urls.py b/tests/frontendIntegration/django3x/polls/urls.py index 0ac62fb25..c5e764cf8 100644 --- a/tests/frontendIntegration/django3x/polls/urls.py +++ b/tests/frontendIntegration/django3x/polls/urls.py @@ -14,6 +14,7 @@ name="multipleInterceptors", ), path("", views.get_info, name="/"), # type: ignore + path("check-rid-no-session", views.check_rid_no_session, name="check-rid-no-session"), # type: ignore path("update-jwt", views.update_jwt, name="update_jwt"), # type: ignore path("update-jwt-with-handle", views.update_jwt_with_handle, name="update_jwt_with_handle"), # type: ignore path("session-claims-error", views.session_claim_error_api, name="session_claim_error_api"), # type: ignore diff --git a/tests/frontendIntegration/django3x/polls/views.py b/tests/frontendIntegration/django3x/polls/views.py index 5c86f330f..05fd0b33f 100644 --- a/tests/frontendIntegration/django3x/polls/views.py +++ b/tests/frontendIntegration/django3x/polls/views.py @@ -438,6 +438,11 @@ async def get_info(request: HttpRequest): return HttpResponse("") +def check_rid_no_session(request: HttpRequest): + rid = request.headers.get("rid") # type: ignore + return HttpResponse("fail" if rid is None else "success") + + @custom_decorator_for_update_jwt() @verify_session() async def update_jwt(request: HttpRequest): diff --git a/tests/frontendIntegration/fastapi-server/app.py b/tests/frontendIntegration/fastapi-server/app.py index 56792896b..a0f810183 100644 --- a/tests/frontendIntegration/fastapi-server/app.py +++ b/tests/frontendIntegration/fastapi-server/app.py @@ -316,6 +316,11 @@ async def get_info(r_session: SessionContainer = Depends(verify_session())): content=r_session.get_user_id(), headers={"Cache-Control": "no-cache, private"} ) +@app.get("/check-rid-no-session") +def check_rid_no_session_api(request: Request): + rid = request.headers.get("rid") + return PlainTextResponse("fail" if rid is None else "success") + @app.options("/update-jwt") def update_options(): diff --git a/tests/frontendIntegration/flask-server/app.py b/tests/frontendIntegration/flask-server/app.py index 3a4c9442c..b5f34759b 100644 --- a/tests/frontendIntegration/flask-server/app.py +++ b/tests/frontendIntegration/flask-server/app.py @@ -335,6 +335,11 @@ def get_info(): resp.headers["Cache-Control"] = "no-cache, private" return resp +@app.route("/check-rid-no-session", methods=["GET"]) # type: ignore +def check_rid_no_session(): + rid = request.headers.get("rid") + return "fail" if rid is None or not rid.startswith("anti-csrf") else "success" + @app.route("/update-jwt", methods=["OPTIONS"]) # type: ignore def update_options(): From b9dd9219c59e29c9d39da4e6730ff2cf43109d1e Mon Sep 17 00:00:00 2001 From: KShivendu Date: Mon, 10 Jul 2023 13:27:39 +0530 Subject: [PATCH 2/2] chores: Format --- tests/frontendIntegration/fastapi-server/app.py | 1 + tests/frontendIntegration/flask-server/app.py | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/frontendIntegration/fastapi-server/app.py b/tests/frontendIntegration/fastapi-server/app.py index a0f810183..66fc798fc 100644 --- a/tests/frontendIntegration/fastapi-server/app.py +++ b/tests/frontendIntegration/fastapi-server/app.py @@ -316,6 +316,7 @@ async def get_info(r_session: SessionContainer = Depends(verify_session())): content=r_session.get_user_id(), headers={"Cache-Control": "no-cache, private"} ) + @app.get("/check-rid-no-session") def check_rid_no_session_api(request: Request): rid = request.headers.get("rid") diff --git a/tests/frontendIntegration/flask-server/app.py b/tests/frontendIntegration/flask-server/app.py index b5f34759b..91d223ec2 100644 --- a/tests/frontendIntegration/flask-server/app.py +++ b/tests/frontendIntegration/flask-server/app.py @@ -335,6 +335,7 @@ def get_info(): resp.headers["Cache-Control"] = "no-cache, private" return resp + @app.route("/check-rid-no-session", methods=["GET"]) # type: ignore def check_rid_no_session(): rid = request.headers.get("rid")