|
13 | 13 | # under the License.
|
14 | 14 | from typing import Any, Dict, Union
|
15 | 15 |
|
16 |
| -from litestar import Litestar, MediaType, Request, get, post |
| 16 | +from litestar import Litestar, MediaType, Request, Response, get, post |
17 | 17 | from litestar.di import Provide
|
18 | 18 | from litestar.testing import TestClient
|
19 | 19 | from pytest import fixture, mark
|
@@ -70,10 +70,14 @@ async def login(request: Request[Any, Any, Any]) -> dict[str, Any]:
|
70 | 70 | return {"userId": user_id}
|
71 | 71 |
|
72 | 72 | @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) |
77 | 81 |
|
78 | 82 | @get("/info")
|
79 | 83 | async def info_get(request: Request[Any, Any, Any]) -> dict[str, Any]:
|
@@ -163,6 +167,7 @@ def apis_override_session(param: APIInterface):
|
163 | 167 | return param
|
164 | 168 |
|
165 | 169 |
|
| 170 | +# |
166 | 171 | # @mark.asyncio
|
167 | 172 | # async def test_login_refresh(driver_config_client: TestClient[Litestar]):
|
168 | 173 | # init(
|
|
0 commit comments