@@ -18,7 +18,7 @@ def utc_timestamp():
1818class TestJWT (unittest .TestCase ):
1919
2020 def setUp (self ):
21- self .payload = {"iss" : "jeff" , "exp" : utc_timestamp () + 10 ,
21+ self .payload = {"iss" : "jeff" , "exp" : utc_timestamp () + 15 ,
2222 "claim" : "insanity" }
2323
2424 def test_encode_decode (self ):
@@ -76,6 +76,46 @@ def test_decodes_valid_jwt(self):
7676
7777 self .assertEqual (decoded_payload , example_payload )
7878
79+ # 'Control' Elliptic Curve JWT created by another library.
80+ # Used to test for regressions that could affect both
81+ # encoding / decoding operations equally (causing tests
82+ # to still pass).
83+ def test_decodes_valid_es384_jwt (self ):
84+ example_payload = {"hello" : "world" }
85+ example_pubkey = open ('tests/testkey_ec.pub' , 'r' ).read ()
86+ example_jwt = (
87+ b"eyJhbGciOiJFUzM4NCIsInR5cCI6IkpXVCJ9"
88+ b".eyJoZWxsbyI6IndvcmxkIn0"
89+ b".MIGHAkEdh2kR7IRu5w0tGuY6Xz3Vqa7PHHY2DgXWeee"
90+ b"LXotEqpn9udp2NfVL-XFG0TDoCakzXbIGAWg42S69GFl"
91+ b"KZzxhXAJCAPLPuJoKyAixFnXPBkvkti-UzSIj4s6DePe"
92+ b"uTu7102G_QIXiijY5bx6mdmZa3xUuKeu-zobOIOqR8Zw"
93+ b"FqGjBLZum" )
94+ decoded_payload = jwt .decode (example_jwt , example_pubkey )
95+ self .assertEqual (decoded_payload , example_payload )
96+
97+ # 'Control' RSA JWT created by another library.
98+ # Used to test for regressions that could affect both
99+ # encoding / decoding operations equally (causing tests
100+ # to still pass).
101+ def test_decodes_valid_rs384_jwt (self ):
102+ example_payload = {"hello" : "world" }
103+ example_pubkey = open ('tests/testkey_rsa.pub' , 'r' ).read ()
104+ example_jwt = (
105+ b"eyJhbGciOiJSUzM4NCIsInR5cCI6IkpXVCJ9"
106+ b".eyJoZWxsbyI6IndvcmxkIn0"
107+ b".yNQ3nI9vEDs7lEh-Cp81McPuiQ4ZRv6FL4evTYYAh1X"
108+ b"lRTTR3Cz8pPA9Stgso8Ra9xGB4X3rlra1c8Jz10nTUju"
109+ b"O06OMm7oXdrnxp1KIiAJDerWHkQ7l3dlizIk1bmMA457"
110+ b"W2fNzNfHViuED5ISM081dgf_a71qBwJ_yShMMrSOfxDx"
111+ b"mX9c4DjRogRJG8SM5PvpLqI_Cm9iQPGMvmYK7gzcq2cJ"
112+ b"urHRJDJHTqIdpLWXkY7zVikeen6FhuGyn060Dz9gYq9t"
113+ b"uwmrtSWCBUjiN8sqJ00CDgycxKqHfUndZbEAOjcCAhBr"
114+ b"qWW3mSVivUfubsYbwUdUG3fSRPjaUPcpe8A" )
115+ decoded_payload = jwt .decode (example_jwt , example_pubkey )
116+
117+ self .assertEqual (decoded_payload , example_payload )
118+
79119 def test_load_verify_valid_jwt (self ):
80120 example_payload = {"hello" : "world" }
81121 example_secret = "secret"
0 commit comments