Skip to content

Commit 23f5b05

Browse files
committed
test: Fix failing tests for flask
1 parent ebda7bc commit 23f5b05

File tree

1 file changed

+19
-18
lines changed
  • tests/auth-react/flask-server

1 file changed

+19
-18
lines changed

tests/auth-react/flask-server/app.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from dotenv import load_dotenv
1818
from flask import Flask, g, jsonify, make_response, request
1919
from flask_cors import CORS
20-
2120
from supertokens_python import (
2221
InputAppInfo,
2322
Supertokens,
@@ -50,19 +49,19 @@
5049
User,
5150
)
5251
from supertokens_python.recipe.emailverification import (
53-
EmailVerificationRecipe,
5452
EmailVerificationClaim,
53+
EmailVerificationRecipe,
5554
)
5655
from supertokens_python.recipe.emailverification import (
5756
InputOverrideConfig as EVInputOverrideConfig,
5857
)
59-
from supertokens_python.recipe.emailverification.asyncio import unverify_email
6058
from supertokens_python.recipe.emailverification.interfaces import (
6159
APIInterface as EmailVerificationAPIInterface,
6260
)
6361
from supertokens_python.recipe.emailverification.interfaces import (
6462
APIOptions as EVAPIOptions,
6563
)
64+
from supertokens_python.recipe.emailverification.syncio import unverify_email
6665
from supertokens_python.recipe.emailverification.types import User as EVUser
6766
from supertokens_python.recipe.jwt import JWTRecipe
6867
from supertokens_python.recipe.passwordless import (
@@ -81,10 +80,12 @@
8180
from supertokens_python.recipe.session.framework.flask import verify_session
8281
from supertokens_python.recipe.session.interfaces import (
8382
APIInterface as SessionAPIInterface,
84-
SessionContainer,
85-
SessionClaimValidator,
8683
)
8784
from supertokens_python.recipe.session.interfaces import APIOptions as SAPIOptions
85+
from supertokens_python.recipe.session.interfaces import (
86+
SessionClaimValidator,
87+
SessionContainer,
88+
)
8889
from supertokens_python.recipe.thirdparty import ThirdPartyRecipe
8990
from supertokens_python.recipe.thirdparty.interfaces import (
9091
APIInterface as ThirdpartyAPIInterface,
@@ -113,13 +114,13 @@
113114
APIInterface as ThirdpartyPasswordlessAPIInterface,
114115
)
115116
from supertokens_python.recipe.userroles import (
116-
UserRoleClaim,
117117
PermissionClaim,
118+
UserRoleClaim,
118119
UserRolesRecipe,
119120
)
120-
from supertokens_python.recipe.userroles.asyncio import (
121-
create_new_role_or_add_permissions,
121+
from supertokens_python.recipe.userroles.syncio import (
122122
add_role_to_user,
123+
create_new_role_or_add_permissions,
123124
)
124125
from supertokens_python.types import GeneralErrorResponse
125126
from typing_extensions import Literal
@@ -1011,7 +1012,7 @@ def before_each():
10111012

10121013

10131014
@app.route("/test/setFlow", methods=["POST"]) # type: ignore
1014-
async def test_set_flow():
1015+
def test_set_flow():
10151016
body: Union[Any, None] = request.get_json()
10161017
if body is None:
10171018
raise Exception("Should never come here")
@@ -1039,22 +1040,22 @@ def test_feature_flags():
10391040

10401041
@app.get("/unverifyEmail") # type: ignore
10411042
@verify_session()
1042-
async def unverify_email_api():
1043+
def unverify_email_api():
10431044
session_: SessionContainer = g.supertokens # type: ignore
1044-
await unverify_email(session_.get_user_id())
1045-
await session_.fetch_and_set_claim(EmailVerificationClaim)
1045+
unverify_email(session_.get_user_id())
1046+
session_.sync_fetch_and_set_claim(EmailVerificationClaim)
10461047
return jsonify({"status": "OK"})
10471048

10481049

10491050
@app.route("/setRole", methods=["POST"]) # type: ignore
10501051
@verify_session()
1051-
async def verify_email_api():
1052+
def verify_email_api():
10521053
session_: SessionContainer = g.supertokens # type: ignore
10531054
body: Dict[str, Any] = request.get_json() # type: ignore
1054-
await create_new_role_or_add_permissions(body["role"], body["permissions"])
1055-
await add_role_to_user(session_.get_user_id(), body["role"])
1056-
await session_.fetch_and_set_claim(UserRoleClaim)
1057-
await session_.fetch_and_set_claim(PermissionClaim)
1055+
create_new_role_or_add_permissions(body["role"], body["permissions"])
1056+
add_role_to_user(session_.get_user_id(), body["role"])
1057+
session_.sync_fetch_and_set_claim(UserRoleClaim)
1058+
session_.sync_fetch_and_set_claim(PermissionClaim)
10581059
return jsonify({"status": "OK"})
10591060

10601061

@@ -1082,7 +1083,7 @@ async def override_global_claim_validators(
10821083

10831084
@app.route("/checkRole", methods=["POST"]) # type: ignore
10841085
@verify_session(override_global_claim_validators=override_global_claim_validators)
1085-
async def check_role_api():
1086+
def check_role_api():
10861087
return jsonify({"status": "OK"})
10871088

10881089

0 commit comments

Comments
 (0)