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 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])