Skip to content

Commit 1e499b1

Browse files
committed
feat: update Litestar middleware integration and enhance session handling
1 parent dabb1dd commit 1e499b1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tests/Litestar/test_litestar.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# under the License.
1414
from typing import Any, Dict, Union
1515

16-
from litestar import Litestar, MediaType, Request, get, post
16+
from litestar import Litestar, MediaType, Request, Response, get, post
1717
from litestar.di import Provide
1818
from litestar.testing import TestClient
1919
from pytest import fixture, mark
@@ -70,10 +70,14 @@ async def login(request: Request[Any, Any, Any]) -> dict[str, Any]:
7070
return {"userId": user_id}
7171

7272
@post("/refresh")
73-
async def custom_refresh(request: Request[Any, Any, Any]) -> dict[str, Any]:
74-
result = await refresh_session(request)
75-
print(f"The result is {result}")
76-
return {}
73+
async def custom_refresh(
74+
request: Request[Any, Any, Any],
75+
) -> dict[str, Any] | Response[Any]:
76+
try:
77+
await refresh_session(request)
78+
return Response(content=None)
79+
except UnauthorisedError:
80+
return Response(content={"message": "Unauthorized"}, status_code=401)
7781

7882
@get("/info")
7983
async def info_get(request: Request[Any, Any, Any]) -> dict[str, Any]:
@@ -163,6 +167,7 @@ def apis_override_session(param: APIInterface):
163167
return param
164168

165169

170+
#
166171
# @mark.asyncio
167172
# async def test_login_refresh(driver_config_client: TestClient[Litestar]):
168173
# init(

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy