def test_creat_jwks_sym(): a = {"kty": "oct", "key": "highestsupersecret", "use": "sig"} kb = KeyBundle([a]) _jwks = kb.jwks() _loc = json.loads(_jwks) assert list(_loc.keys()) == ["keys"] assert set(_loc["keys"][0].keys()) == {"kty", "use", "k", "kid"}
def test_dump_jwk(): kb = KeyBundle() kb.append(RSAKey(pub_key=import_rsa_key_from_cert_file(CERT))) jwks = kb.jwks() _wk = json.loads(jwks) assert list(_wk.keys()) == ["keys"] assert len(_wk["keys"]) == 1 assert set(_wk["keys"][0].keys()) == {"kty", "e", "n"} kb2 = KeyBundle(_wk) assert len(kb2) == 1 key = kb2.get("rsa")[0] assert key.kty == "RSA" assert isinstance(key.public_key(), rsa.RSAPublicKey)