jwe finally works
This commit is contained in:
25
testjwe.py
25
testjwe.py
@ -1,9 +1,28 @@
|
|||||||
|
import unittest
|
||||||
from jose import jwe
|
from jose import jwe
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
|
||||||
JWT_PUB_KEY = os.environ["JWT_PUB_KEY"]
|
JWT_PUB_KEY = os.environ["JWT_PUB_KEY"]
|
||||||
|
JWT_PRIV_KEY = os.environ["JWT_PRIV_KEY"]
|
||||||
|
|
||||||
|
class JweTestMethods(unittest.TestCase):
|
||||||
|
def test_encryptDecrypt(self):
|
||||||
|
inObj = {"key1":"value1", "key2":"value2"}
|
||||||
|
plainText = json.dumps(inObj)
|
||||||
|
|
||||||
plainText = "BlaBlaBla123"
|
|
||||||
cryptText = jwe.encrypt(plainText, JWT_PUB_KEY, "A256GCM", "RSA-OAEP")
|
cryptText = jwe.encrypt(plainText, JWT_PUB_KEY, "A256GCM", "RSA-OAEP")
|
||||||
|
|
||||||
print(cryptText)
|
print(cryptText)
|
||||||
|
|
||||||
|
clearText = jwe.decrypt(cryptText, JWT_PRIV_KEY)
|
||||||
|
print(clearText)
|
||||||
|
|
||||||
|
outObj = json.loads(clearText)
|
||||||
|
print(outObj)
|
||||||
|
|
||||||
|
self.assertEqual(outObj, inObj)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user