Skip to content

Commit 5aa283e

Browse files
committed
fix: test for dashboard get user api
1 parent 9b6aa87 commit 5aa283e

File tree

1 file changed

+66
-1
lines changed

1 file changed

+66
-1
lines changed

tests/dashboard/test_dashboard.py

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@
77
from supertokens_python.constants import DASHBOARD_VERSION
88
from supertokens_python.framework import BaseRequest
99
from supertokens_python.framework.fastapi import get_middleware
10-
from supertokens_python.recipe import dashboard, emailpassword, session, usermetadata
10+
from supertokens_python.recipe import (
11+
dashboard,
12+
emailpassword,
13+
session,
14+
usermetadata,
15+
thirdpartypasswordless,
16+
)
17+
import supertokens_python.recipe.thirdpartypasswordless.asyncio as tplasync
1118
from supertokens_python.recipe.dashboard import InputOverrideConfig
1219
from supertokens_python.recipe.dashboard.interfaces import (
1320
RecipeInterface as DashboardRI,
1421
)
1522
from supertokens_python.recipe.dashboard.utils import DashboardConfig
23+
from supertokens_python.recipe.passwordless import ContactEmailOrPhoneConfig
1624
from supertokens_python.recipe.usermetadata.asyncio import update_user_metadata
1725
from tests.utils import (
1826
clean_st,
@@ -203,3 +211,60 @@ async def test_that_first_connection_uri_is_selected_among_multiple_uris(
203211
assert f'window.connectionURI = "{first_connection_uri}"' in str(res.text)
204212
if st_config:
205213
st_config.connection_uri = "http://localhost:3567"
214+
215+
216+
async def test_that_get_user_works_with_combination_recipes(app: TestClient):
217+
def override_dashboard_functions(oi: DashboardRI) -> DashboardRI:
218+
async def should_allow_access(
219+
_request: BaseRequest,
220+
_config: DashboardConfig,
221+
_user_context: Dict[str, Any],
222+
) -> bool:
223+
return True
224+
225+
oi.should_allow_access = should_allow_access
226+
return oi
227+
228+
st_args = get_st_init_args(
229+
[
230+
session.init(get_token_transfer_method=lambda _, __, ___: "cookie"),
231+
thirdpartypasswordless.init(
232+
contact_config=ContactEmailOrPhoneConfig(),
233+
flow_type="USER_INPUT_CODE",
234+
),
235+
usermetadata.init(),
236+
dashboard.init(
237+
api_key="someKey",
238+
override=InputOverrideConfig(
239+
functions=override_dashboard_functions,
240+
),
241+
),
242+
]
243+
)
244+
init(**st_args)
245+
start_st()
246+
247+
pluser = await tplasync.thirdparty_manually_create_or_update_user(
248+
"public", "google", "googleid", "[email protected]"
249+
)
250+
251+
res = app.get(
252+
url="/auth/dashboard/api/user",
253+
params={
254+
"userId": "randomid",
255+
"recipeId": "thirdparty",
256+
},
257+
)
258+
res_json = res.json()
259+
assert res_json["status"] == "NO_USER_FOUND_ERROR"
260+
261+
res = app.get(
262+
url="/auth/dashboard/api/user",
263+
params={
264+
"userId": pluser.user.user_id,
265+
"recipeId": "thirdparty",
266+
},
267+
)
268+
res_json = res.json()
269+
assert res_json["status"] == "OK"
270+
assert res_json["user"]["id"] == pluser.user.user_id

0 commit comments

Comments
 (0)