Skip to content

Commit

Permalink
more test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhpoddar committed Oct 3, 2024
1 parent b0b2a5c commit 7b9d23c
Show file tree
Hide file tree
Showing 7 changed files with 713 additions and 68 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@
],
"cwd": "${workspaceFolder}/tests/auth-react/fastapi-server",
"jinja": true
},
{
"name": "Python: Django, supertokens-auth-react tests",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/tests/auth-react/django3x/manage.py",
"args": [
"runserver",
"0.0.0.0:8083"
],
"env": {
"PYTHONPATH": "${workspaceFolder}"
},
"cwd": "${workspaceFolder}/tests/auth-react/django3x",
"jinja": true
}
]
}
1 change: 1 addition & 0 deletions tests/auth-react/django3x/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


def main():
os.environ.setdefault("SUPERTOKENS_ENV", "testing")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
try:
from django.core.management import execute_from_command_line
Expand Down
2 changes: 1 addition & 1 deletion tests/auth-react/django3x/mysite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

custom_init(None, None)
custom_init()

ALLOWED_HOSTS = ["localhost"]

Expand Down
28 changes: 18 additions & 10 deletions tests/auth-react/django3x/mysite/store.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
from typing import Any, Dict, List, Union
from typing import Any, Dict, List, Literal, Optional, Union

_LATEST_URL_WITH_TOKEN = None
latest_url_with_token = ""


def save_url_with_token(url_with_token: str):
global _LATEST_URL_WITH_TOKEN
_LATEST_URL_WITH_TOKEN = url_with_token # type: ignore
global latest_url_with_token
latest_url_with_token = url_with_token


def get_url_with_token() -> str:
return _LATEST_URL_WITH_TOKEN # type: ignore
return latest_url_with_token


_CODE_STORE: Dict[str, List[Dict[str, Any]]] = {}
code_store: Dict[str, List[Dict[str, Any]]] = {}
accountlinking_config: Dict[str, Any] = {}
enabled_providers: Optional[List[Any]] = None
enabled_recipes: Optional[List[Any]] = None
mfa_info: Dict[str, Any] = {}
contact_method: Union[None, Literal["PHONE", "EMAIL", "EMAIL_OR_PHONE"]] = None
flow_type: Union[
None, Literal["USER_INPUT_CODE", "MAGIC_LINK", "USER_INPUT_CODE_AND_MAGIC_LINK"]
] = None


def save_code(
pre_auth_session_id: str,
url_with_link_code: Union[str, None],
user_input_code: Union[str, None],
):
global _CODE_STORE
codes = _CODE_STORE.get(pre_auth_session_id, [])
global code_store
codes = code_store.get(pre_auth_session_id, [])
# replace sub string in url_with_link_code
if url_with_link_code:
url_with_link_code = url_with_link_code.replace(
Expand All @@ -30,8 +38,8 @@ def save_code(
codes.append(
{"urlWithLinkCode": url_with_link_code, "userInputCode": user_input_code}
)
_CODE_STORE[pre_auth_session_id] = codes
code_store[pre_auth_session_id] = codes


def get_codes(pre_auth_session_id: str) -> List[Dict[str, Any]]:
return _CODE_STORE.get(pre_auth_session_id, [])
return code_store.get(pre_auth_session_id, [])
Loading

0 comments on commit 7b9d23c

Please sign in to comment.