Skip to content

Commit 7dadddb

Browse files
Merge pull request #423 from supertokens/test-cicd/fix-unit-tests
test: Fix failing unit tests
2 parents f131ac9 + acbca67 commit 7dadddb

File tree

35 files changed

+127
-142
lines changed

35 files changed

+127
-142
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"_comment": "contains a list of frontend-driver interfaces branch names that this core supports",
33
"versions": [
4-
"1.16"
4+
"1.17"
55
]
6-
}
6+
}

supertokens_python/framework/django/django_middleware.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ def __syncMiddleware(request: HttpRequest):
7171
from django.http import HttpResponse
7272

7373
response = DjangoResponse(HttpResponse())
74+
user_context = default_user_context(custom_request)
75+
7476
try:
7577
result: Union[DjangoResponse, None] = async_to_sync(st.middleware)(
76-
custom_request, response
78+
custom_request, response, user_context
7779
)
7880

7981
if result is None:

supertokens_python/recipe/dashboard/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020

2121
from .recipe import DashboardRecipe
2222

23-
if TYPE_CHECKING:
24-
from supertokens_python.recipe.dashboard.utils import InputOverrideConfig
23+
from supertokens_python.recipe.dashboard import utils
24+
25+
InputOverrideConfig = utils.InputOverrideConfig
2526

2627

2728
def init(

supertokens_python/recipe/emailpassword/asyncio/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async def get_user_by_email(
7070
if user_context is None:
7171
user_context = {}
7272
return await EmailPasswordRecipe.get_instance().recipe_implementation.get_user_by_email(
73-
tenant_id, email, user_context
73+
email, tenant_id, user_context
7474
)
7575

7676

@@ -93,7 +93,7 @@ async def reset_password_using_token(
9393
if user_context is None:
9494
user_context = {}
9595
return await EmailPasswordRecipe.get_instance().recipe_implementation.reset_password_using_token(
96-
new_password, tenant_id, token, user_context
96+
token, new_password, tenant_id, user_context
9797
)
9898

9999

supertokens_python/recipe/multitenancy/recipe_implementation.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
from .utils import MultitenancyConfig
4646

4747
from supertokens_python.querier import NormalisedURLPath
48+
from .constants import DEFAULT_TENANT_ID
4849

4950

5051
def parse_tenant_config(tenant: Dict[str, Any]) -> TenantConfigResponse:
@@ -161,7 +162,7 @@ async def get_tenant(
161162
self, tenant_id: Optional[str], user_context: Dict[str, Any]
162163
) -> Optional[GetTenantOkResult]:
163164
res = await self.querier.send_get_request(
164-
NormalisedURLPath(f"{tenant_id}/recipe/multitenancy/tenant"),
165+
NormalisedURLPath(f"{tenant_id or DEFAULT_TENANT_ID}/recipe/multitenancy/tenant"),
165166
)
166167

167168
if res["status"] == "TENANT_NOT_FOUND_ERROR":
@@ -209,7 +210,7 @@ async def create_or_update_third_party_config(
209210
user_context: Dict[str, Any],
210211
) -> CreateOrUpdateThirdPartyConfigOkResult:
211212
response = await self.querier.send_put_request(
212-
NormalisedURLPath(f"{tenant_id}/recipe/multitenancy/config/thirdparty"),
213+
NormalisedURLPath(f"{tenant_id or DEFAULT_TENANT_ID}/recipe/multitenancy/config/thirdparty"),
213214
{
214215
"config": config.to_json(),
215216
"skipValidation": skip_validation is True,
@@ -228,7 +229,7 @@ async def delete_third_party_config(
228229
) -> DeleteThirdPartyConfigOkResult:
229230
response = await self.querier.send_post_request(
230231
NormalisedURLPath(
231-
f"{tenant_id}/recipe/multitenancy/config/thirdparty/remove"
232+
f"{tenant_id or DEFAULT_TENANT_ID}/recipe/multitenancy/config/thirdparty/remove"
232233
),
233234
{
234235
"thirdPartyId": third_party_id,
@@ -240,7 +241,7 @@ async def delete_third_party_config(
240241
)
241242

242243
async def associate_user_to_tenant(
243-
self, tenant_id: str | None, user_id: str, user_context: Dict[str, Any]
244+
self, tenant_id: Optional[str], user_id: str, user_context: Dict[str, Any]
244245
) -> Union[
245246
AssociateUserToTenantOkResult,
246247
AssociateUserToTenantUnknownUserIdError,
@@ -249,7 +250,7 @@ async def associate_user_to_tenant(
249250
AssociateUserToTenantThirdPartyUserAlreadyExistsError,
250251
]:
251252
response: Dict[str, Any] = await self.querier.send_post_request(
252-
NormalisedURLPath(f"{tenant_id}/recipe/multitenancy/tenant/user"),
253+
NormalisedURLPath(f"{tenant_id or DEFAULT_TENANT_ID}/recipe/multitenancy/tenant/user"),
253254
{
254255
"userId": user_id,
255256
},
@@ -277,10 +278,10 @@ async def associate_user_to_tenant(
277278
raise Exception("Should never come here")
278279

279280
async def dissociate_user_from_tenant(
280-
self, tenant_id: str | None, user_id: str, user_context: Dict[str, Any]
281+
self, tenant_id: Optional[str], user_id: str, user_context: Dict[str, Any]
281282
) -> DisassociateUserFromTenantOkResult:
282283
response = await self.querier.send_post_request(
283-
NormalisedURLPath(f"{tenant_id}/recipe/multitenancy/tenant/user/remove"),
284+
NormalisedURLPath(f"{tenant_id or DEFAULT_TENANT_ID}/recipe/multitenancy/tenant/user/remove"),
284285
{
285286
"userId": user_id,
286287
},

supertokens_python/recipe/passwordless/api/implementation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,17 +289,17 @@ async def consume_code_post(
289289
ev_instance = EmailVerificationRecipe.get_instance_optional()
290290
if ev_instance is not None:
291291
token_response = await ev_instance.recipe_implementation.create_email_verification_token(
292-
tenant_id, user.user_id, user.email, user_context
292+
user.user_id, user.email, tenant_id, user_context
293293
)
294294

295295
if isinstance(token_response, CreateEmailVerificationTokenOkResult):
296296
await ev_instance.recipe_implementation.verify_email_using_token(
297-
tenant_id, token_response.token, user_context
297+
token_response.token, tenant_id, user_context
298298
)
299299

300300
session = await create_new_session(
301-
tenant_id=tenant_id,
302301
request=api_options.request,
302+
tenant_id=tenant_id,
303303
user_id=user.user_id,
304304
access_token_payload={},
305305
session_data_in_database={},

supertokens_python/recipe/session/asyncio/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
14-
from typing import Any, Callable, Dict, List, Optional, TypeVar, Union
14+
from __future__ import annotations
15+
from typing import Any, Callable, Dict, List, Optional, TypeVar, Union, TYPE_CHECKING
1516

1617
from supertokens_python.recipe.openid.interfaces import (
1718
GetOpenIdDiscoveryConfigurationResult,
@@ -46,9 +47,12 @@
4647

4748
_T = TypeVar("_T")
4849

50+
if TYPE_CHECKING:
51+
from supertokens_python.framework.request import BaseRequest
52+
4953

5054
async def create_new_session(
51-
request: Any,
55+
request: BaseRequest,
5256
tenant_id: str,
5357
user_id: str,
5458
access_token_payload: Union[Dict[str, Any], None] = None,

supertokens_python/recipe/session/syncio/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
14-
15-
from typing import Any, Dict, List, Union, Callable, Optional, TypeVar
14+
from __future__ import annotations
15+
from typing import Any, Dict, List, Union, Callable, Optional, TypeVar, TYPE_CHECKING
1616

1717
from supertokens_python.async_to_sync_wrapper import sync
1818
from supertokens_python.recipe.openid.interfaces import (
@@ -37,8 +37,12 @@
3737
)
3838

3939

40+
if TYPE_CHECKING:
41+
from supertokens_python.framework.request import BaseRequest
42+
43+
4044
def create_new_session(
41-
request: Any,
45+
request: BaseRequest,
4246
tenant_id: str,
4347
user_id: str,
4448
access_token_payload: Union[Dict[str, Any], None] = None,

supertokens_python/recipe/thirdparty/api/implementation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async def sign_in_up_post(
9191
email=await provider.config.generate_fake_email(
9292
user_info.third_party_user_id, tenant_id, user_context
9393
),
94-
email_verified=True,
94+
is_verified=True,
9595
)
9696

9797
email = user_info.email.id if user_info.email is not None else None
@@ -123,15 +123,15 @@ async def sign_in_up_post(
123123

124124
if isinstance(token_response, CreateEmailVerificationTokenOkResult):
125125
await ev_instance.recipe_implementation.verify_email_using_token(
126-
tenant_id=tenant_id,
127126
token=token_response.token,
127+
tenant_id=tenant_id,
128128
user_context=user_context,
129129
)
130130

131131
user = signinup_response.user
132132
session = await create_new_session(
133-
tenant_id=tenant_id,
134133
request=api_options.request,
134+
tenant_id=tenant_id,
135135
user_id=user.user_id,
136136
user_context=user_context,
137137
)

supertokens_python/recipe/thirdparty/providers/github.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async def get_user_info(
5555
for info in email_info:
5656
if info.get("primary"):
5757
result.email = UserInfoEmail(
58-
email=info.get("email"), email_verified=info.get("verified")
58+
email=info.get("email"), is_verified=info.get("verified")
5959
)
6060

6161
return result

0 commit comments

Comments
 (0)