Skip to content

Commit b9d007c

Browse files
committed
fixes a few tests
1 parent eaa2fa8 commit b9d007c

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ You will need to setup the [supertokens-core](https://github.com/supertokens/sup
4747
3. Open a new terminal and navigate to the `supertokens-python` respositry.
4848
4. Use `export SUPERTOKENS_PATH=path/to/supertokens-root` (**MANDATORY**)
4949
4. To run all tests, while ensuring the test environment is running on a different terminal, use `make test`.
50-
5. To run individual tests, use `pytest ./tests/path/to/test/file.py -k test_function_name` OR use your IDE's in-built UI for running python tests. You may read [VSCode Python Testing](https://code.visualstudio.com/docs/python/testing) and [PyCharm Testing](https://www.jetbrains.com/help/pycharm/testing-your-first-python-application.html#debug-test) for more info.
50+
5. To run individual tests, use `INSTALL_DIR=../supertokens-root pytest ./tests/path/to/test/file.py::test_function_name` OR use your IDE's in-built UI for running python tests. You may read [VSCode Python Testing](https://code.visualstudio.com/docs/python/testing) and [PyCharm Testing](https://www.jetbrains.com/help/pycharm/testing-your-first-python-application.html#debug-test) for more info.
5151

5252
## Pull Request
5353

supertokens_python/recipe/session/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,12 @@ def validate_and_normalise_user_input(
428428
if expose_access_token_to_frontend_in_cookie_based_auth is None:
429429
expose_access_token_to_frontend_in_cookie_based_auth = False
430430

431+
if cookie_same_site is not None:
432+
# this is just so that we check that the user has provided the right
433+
# values, since normalise_same_site throws an error if the user
434+
# as provided an empty string.
435+
_ = normalise_same_site(cookie_same_site)
436+
431437
def get_cookie_same_site(
432438
request: Optional[BaseRequest], user_context: Dict[str, Any]
433439
) -> Literal["lax", "strict", "none"]:

tests/test_config.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ async def test_config_values():
418418
)
419419

420420
assert SessionRecipe.get_instance().config.get_cookie_same_site(None, {}) == "lax"
421-
assert SessionRecipe.get_instance().config.anti_csrf_function_or_string == "NONE"
421+
anti_csrf = SessionRecipe.get_instance().config.anti_csrf_function_or_string
422+
assert not isinstance(anti_csrf, str) and anti_csrf(None, {}) == "NONE"
422423
assert SessionRecipe.get_instance().config.cookie_secure
423424

424425
reset()
@@ -439,10 +440,8 @@ async def test_config_values():
439440
)
440441

441442
assert SessionRecipe.get_instance().config.get_cookie_same_site(None, {}) == "none"
442-
assert (
443-
SessionRecipe.get_instance().config.anti_csrf_function_or_string
444-
== "VIA_CUSTOM_HEADER"
445-
)
443+
anti_csrf = SessionRecipe.get_instance().config.anti_csrf_function_or_string
444+
assert not isinstance(anti_csrf, str) and anti_csrf(None, {}) == "VIA_CUSTOM_HEADER"
446445
assert SessionRecipe.get_instance().config.cookie_secure
447446

448447
reset()
@@ -463,7 +462,8 @@ async def test_config_values():
463462
)
464463

465464
assert SessionRecipe.get_instance().config.get_cookie_same_site(None, {}) == "lax"
466-
assert SessionRecipe.get_instance().config.anti_csrf_function_or_string == "NONE"
465+
anti_csrf = SessionRecipe.get_instance().config.anti_csrf_function_or_string
466+
assert not isinstance(anti_csrf, str) and anti_csrf(None, {}) == "NONE"
467467
assert SessionRecipe.get_instance().config.cookie_secure
468468

469469
reset()
@@ -484,7 +484,8 @@ async def test_config_values():
484484
)
485485

486486
assert SessionRecipe.get_instance().config.get_cookie_same_site(None, {}) == "lax"
487-
assert SessionRecipe.get_instance().config.anti_csrf_function_or_string == "NONE"
487+
anti_csrf = SessionRecipe.get_instance().config.anti_csrf_function_or_string
488+
assert not isinstance(anti_csrf, str) and anti_csrf(None, {}) == "NONE"
488489
assert not SessionRecipe.get_instance().config.cookie_secure
489490

490491
reset()
@@ -527,10 +528,8 @@ async def test_config_values():
527528
)
528529

529530
assert SessionRecipe.get_instance().config.get_cookie_same_site(None, {}) == "none"
530-
assert (
531-
SessionRecipe.get_instance().config.anti_csrf_function_or_string
532-
== "VIA_CUSTOM_HEADER"
533-
)
531+
anti_csrf = SessionRecipe.get_instance().config.anti_csrf_function_or_string
532+
assert not isinstance(anti_csrf, str) and anti_csrf(None, {}) == "VIA_CUSTOM_HEADER"
534533
assert SessionRecipe.get_instance().config.cookie_secure
535534

536535
reset()
@@ -551,7 +550,8 @@ async def test_config_values():
551550
)
552551

553552
assert SessionRecipe.get_instance().config.get_cookie_same_site(None, {}) == "lax"
554-
assert SessionRecipe.get_instance().config.anti_csrf_function_or_string == "NONE"
553+
anti_csrf = SessionRecipe.get_instance().config.anti_csrf_function_or_string
554+
assert not isinstance(anti_csrf, str) and anti_csrf(None, {}) == "NONE"
555555
assert not SessionRecipe.get_instance().config.cookie_secure
556556

557557
reset()

0 commit comments

Comments
 (0)