Beispiel #1
0
 def test_rsa_encode_decode(self):
     jws = JWS(algorithms=JWS_ALGORITHMS)
     s = jws.encode({'alg': 'RS256'}, 'hello',
                    read_file_path('rsa_private.pem'))
     header, payload = jws.decode(s, read_file_path('rsa_public.pem'))
     self.assertEqual(payload, b'hello')
     self.assertEqual(header['alg'], 'RS256')
Beispiel #2
0
 def test_success_encode_decode(self):
     jws = JWS(algorithms=JWS_ALGORITHMS)
     s = jws.encode({'alg': 'HS256'}, 'hello', 'secret')
     header, payload = jws.decode(s, 'secret')
     self.assertEqual(payload, b'hello')
     self.assertEqual(header['alg'], 'HS256')
Beispiel #3
0
 def test_rsa_encode_decode(self):
     jws = JWS(algorithms=JWS_ALGORITHMS)
     s = jws.encode({'alg': 'RS256'}, 'hello', get_rsa_private_key())
     header, payload = jws.decode(s, get_rsa_public_key())
     self.assertEqual(payload, b'hello')
     self.assertEqual(header['alg'], 'RS256')