def test_dump_load(): jb = make_jwks_bundle('', ['fo0', 'fo1', 'fo2', 'fo3'], None, KEYDEFS) bs = jb.dumps() receiver = JWKSBundle('') receiver.loads(bs) assert len(receiver.keys()) == 4 assert set(receiver.keys()) == {'fo0', 'fo1', 'fo2', 'fo3'}
def test_dumps_loads(): bundle = JWKSBundle(ISS, SIGN_KEYS) bundle['https://www.swamid.se'] = KEYJAR['https://www.swamid.se'] bundle['https://www.sunet.se'] = KEYJAR['https://www.sunet.se'] bundle['https://www.feide.no'] = KEYJAR['https://www.feide.no'] _str = bundle.dumps() fp = open('bundle.json', 'w') fp.write(_str) fp.close() bundle2 = JWKSBundle(ISS, SIGN_KEYS) bundle2.loads(_str) # bundle contains private keys # bundle2 contains the public keys # This comparision could be made better for fo, kj in bundle.items(): assert len(kj.get_issuer_keys(fo)) == len( bundle2[fo].get_issuer_keys(fo))