12
12
# License for the specific language governing permissions and limitations
13
13
# under the License.
14
14
import json
15
- from typing import Any , Union
15
+ from typing import Any
16
16
17
17
from fastapi import FastAPI
18
- from fastapi .requests import Request
19
18
from fastapi .testclient import TestClient
20
19
from pytest import fixture , mark
21
20
from supertokens_python import InputAppInfo , SupertokensConfig , init
22
21
from supertokens_python .framework .fastapi import get_middleware
23
22
from supertokens_python .recipe import emailpassword , emailverification , session
24
- from supertokens_python .recipe .session import SessionContainer
25
- from supertokens_python .recipe .session .asyncio import (
26
- create_new_session ,
27
- get_session ,
28
- refresh_session ,
29
- )
30
23
from tests .utils import (
31
24
setup_function ,
32
25
sign_up_request ,
@@ -46,45 +39,6 @@ async def driver_config_client():
46
39
app = FastAPI ()
47
40
app .add_middleware (get_middleware ())
48
41
49
- @app .get ("/login" )
50
- async def login (request : Request ): # type: ignore
51
- user_id = "userId"
52
- await create_new_session (request , user_id , {}, {})
53
- return {"userId" : user_id }
54
-
55
- @app .post ("/refresh" )
56
- async def custom_refresh (request : Request ): # type: ignore
57
- await refresh_session (request )
58
- return {} # type: ignore
59
-
60
- @app .get ("/info" )
61
- async def info_get (request : Request ): # type: ignore
62
- await get_session (request , True )
63
- return {} # type: ignore
64
-
65
- @app .get ("/custom/info" )
66
- def custom_info (_ ): # type: ignore
67
- return {} # type: ignore
68
-
69
- @app .options ("/custom/handle" )
70
- def custom_handle_options (_ ): # type: ignore
71
- return {"method" : "option" }
72
-
73
- @app .get ("/handle" )
74
- async def handle_get (request : Request ): # type: ignore
75
- session : Union [SessionContainer , None ] = await get_session (request , True )
76
- if session is None :
77
- raise Exception ("Should never come here" )
78
- return {"s" : session .get_handle ()}
79
-
80
- @app .post ("/logout" )
81
- async def custom_logout (request : Request ): # type: ignore
82
- session : Union [SessionContainer , None ] = await get_session (request , True )
83
- if session is None :
84
- raise Exception ("Should never come here" )
85
- await session .revoke_session ()
86
- return {} # type: ignore
87
-
88
42
return TestClient (app )
89
43
90
44
0 commit comments