From 42b8dc497ea62a35154329642cb5ec497cd5946f Mon Sep 17 00:00:00 2001 From: KShivendu Date: Tue, 12 Sep 2023 17:02:06 +0530 Subject: [PATCH 1/2] fix: Failing unit tests --- supertokens_python/recipe/session/session_class.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supertokens_python/recipe/session/session_class.py b/supertokens_python/recipe/session/session_class.py index e904f14c4..36dfd644e 100644 --- a/supertokens_python/recipe/session/session_class.py +++ b/supertokens_python/recipe/session/session_class.py @@ -207,7 +207,7 @@ async def assert_claims( for k in protected_props: try: del validate_claim_res.access_token_payload_update[k] - except ValueError: + except KeyError: pass await self.merge_into_access_token_payload( validate_claim_res.access_token_payload_update, user_context From 5d6a96e14a5ffd1b1c43cafe9382447937c1b889 Mon Sep 17 00:00:00 2001 From: KShivendu Date: Tue, 12 Sep 2023 17:29:33 +0530 Subject: [PATCH 2/2] test: Add test --- tests/sessions/claims/test_assert_claims.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/sessions/claims/test_assert_claims.py b/tests/sessions/claims/test_assert_claims.py index 71d955a6e..992ae89c4 100644 --- a/tests/sessions/claims/test_assert_claims.py +++ b/tests/sessions/claims/test_assert_claims.py @@ -16,7 +16,9 @@ ) from supertokens_python.recipe.session.session_class import Session from supertokens_python import init -from tests.utils import setup_function, teardown_function, start_st, st_init_common_args +from tests.utils import get_st_init_args, setup_function, teardown_function, start_st, st_init_common_args +from supertokens_python.recipe.session.asyncio import create_new_session_without_request_response +from .utils import TrueClaim _ = setup_function # type:ignore _ = teardown_function # type:ignore @@ -125,3 +127,12 @@ def should_refetch(self, payload: JSONObject, user_context: Dict[str, Any]): assert dummy_claim_validator.validate_calls == {json.dumps(payload): 1} mock.assert_not_called() + + +async def test_assert_claims_should_work(): + init(**get_st_init_args([session.init()])) + start_st() + + validator = TrueClaim.validators.is_true(1) + s = await create_new_session_without_request_response("public", "userid", {}) + await s.assert_claims([validator])