-
-
Notifications
You must be signed in to change notification settings - Fork 8
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(registry): treat null claim value as missing #14
Conversation
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #14 +/- ##
=======================================
Coverage 99.80% 99.80%
=======================================
Files 44 44
Lines 2548 2548
Branches 371 309 -62
=======================================
Hits 2543 2543
Misses 1 1
Partials 4 4
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Assert the following to be true: essential allow_blank value result True False missing MissingClaimError True False null MissingClaimError True False "" InvalidClaimError True False "x" Accepted True True missing MissingClaimError True True null MissingClaimError True True "" Accepted True True "x" Accepted Code: def test_essential_empty_value(self): claims_requests = jwt.JWTClaimsRegistry(sub={"essential": True}) self.assertRaises(MissingClaimError, claims_requests.validate, {"sub": None}) Signed-off-by: Alon Bar-Lev <[email protected]>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
raise MissingClaimError(",".join(missed_key)) | ||
missed_keys = {key for key in self.essential_keys if claims.get(key) is None} | ||
if missed_keys: | ||
raise MissingClaimError(",".join(sorted(missed_keys))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to sort keys here? I'm ok with the sorting. But is there a reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is human readable message, it should be deterministic. As set order is not deterministic we should sort it.
Assert the following to be true:
Code:
@lepture : please tell me if you want to treat this as MissingClaimError or InvalidClaimError, I believe that JSON null value should be treated as missing.