aboutsummaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorjuerg <juerg@google.com>2023-04-28 23:26:56 -0700
committerCopybara-Service <copybara-worker@google.com>2023-04-28 23:28:08 -0700
commit9210f68d57e0457cb21b69e4f6a750f28ee17457 (patch)
tree574c16f926ae0a120adbb63ee53675d2c407e9a1 /python
parentdcdf3a0e5cb4e4a9dea2c9fbc7819d6ce815d82f (diff)
downloadtink-9210f68d57e0457cb21b69e4f6a750f28ee17457.tar.gz
Encode integers as integers in JWT payload.
- add tests in C++, Go and Python that these languages already do this. - overload the addNumberClaim so that this also works in Java. PiperOrigin-RevId: 528083180
Diffstat (limited to 'python')
-rw-r--r--python/tink/jwt/_raw_jwt_test.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/python/tink/jwt/_raw_jwt_test.py b/python/tink/jwt/_raw_jwt_test.py
index f83b78bac..906bc756c 100644
--- a/python/tink/jwt/_raw_jwt_test.py
+++ b/python/tink/jwt/_raw_jwt_test.py
@@ -289,6 +289,12 @@ class RawJwtTest(absltest.TestCase):
token = jwt.RawJwt._from_json(None, json.dumps(payload))
self.assertEqual(json.loads(token.json_payload()), payload)
+ def test_integer_is_encoded_as_integer(self):
+ token = jwt.new_raw_jwt(
+ without_expiration=True,
+ custom_claims={'num': 1})
+ self.assertEqual(token.json_payload(), '{"num":1}')
+
def test_exp_to_payload(self):
expiration = datetime.datetime.fromtimestamp(2218027244,
datetime.timezone.utc)