Пример #1
0
def test_dump_jwk():
    keylist0 = KEYS()
    keylist0.wrap_add(import_rsa_key_from_cert_file(CERT))
    jwk = keylist0.dump_jwks()

    _wk = json.loads(jwk)
    assert list(_wk.keys()) == ["keys"]
    assert len(_wk["keys"]) == 1
    assert _eq(list(_wk["keys"][0].keys()), ["kty", "e", "n"])
Пример #2
0
def test_load_jwk():
    keylist0 = KEYS()
    keylist0.wrap_add(import_rsa_key_from_cert_file(CERT))
    jwk = keylist0.dump_jwks()

    keylist1 = KEYS()
    keylist1.load_jwks(jwk)

    assert len(keylist1) == 1
    key = keylist1["rsa"][0]
    assert key.kty == 'RSA'
    assert isinstance(key.key, rsa.RSAPublicKey)