Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Failing unit tests #444

Merged
merged 3 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion supertokens_python/recipe/session/session_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
rishabhpoddar marked this conversation as resolved.
Show resolved Hide resolved
pass
await self.merge_into_access_token_payload(
validate_claim_res.access_token_payload_update, user_context
Expand Down
13 changes: 12 additions & 1 deletion tests/sessions/claims/test_assert_claims.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
Loading