From 1f55ef0a803679dbcaa82b541acd1980c2708668 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Tue, 15 Jun 2021 21:26:36 +0200 Subject: [PATCH] jwe finally works --- testjwe.py | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/testjwe.py b/testjwe.py index 6c6b53e..c6306cd 100644 --- a/testjwe.py +++ b/testjwe.py @@ -1,9 +1,28 @@ +import unittest from jose import jwe - +import os +import json JWT_PUB_KEY = os.environ["JWT_PUB_KEY"] +JWT_PRIV_KEY = os.environ["JWT_PRIV_KEY"] -plainText = "BlaBlaBla123" -cryptText = jwe.encrypt(plainText, JWT_PUB_KEY, "A256GCM", "RSA-OAEP") +class JweTestMethods(unittest.TestCase): + def test_encryptDecrypt(self): + inObj = {"key1":"value1", "key2":"value2"} + plainText = json.dumps(inObj) -print(cryptText) \ No newline at end of file + cryptText = jwe.encrypt(plainText, JWT_PUB_KEY, "A256GCM", "RSA-OAEP") + 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()