def test_sign_verify(): 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'] _jws = bundle.create_signed_bundle() bundle2 = JWKSBundle(ISS2) verify_keys = public_keys_keyjar(SIGN_KEYS.copy(), '', None, ISS) bundle2.upload_signed_bundle(_jws, verify_keys) assert set(bundle.keys()) == set(bundle2.keys()) # Again can't compare straight off because bundle contains private keys # while bundle2 contains the public equivalents. for iss, kj in bundle.items(): assert len(kj.get_issuer_keys(iss)) == len( bundle2[iss].get_issuer_keys(iss))
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))