def test_export_inactive(): desc = {"kty": "oct", "key": "highestsupersecret", "use": "sig"} kb = KeyBundle([desc]) assert len(kb.keys()) == 1 for k in kb.keys(): kb.mark_as_inactive(k.kid) desc = {"kty": "oct", "key": "highestsupersecret", "use": "enc"} kb.add_jwk_dicts([desc]) res = kb.dump() assert set(res.keys()) == { "cache_time", "etag", "fileformat", "httpc_params", "ignore_errors_until", "ignore_errors_period", "ignore_invalid_keys", "imp_jwks", "keys", "keytype", "keyusage", "last_updated", "last_remote", "last_local", "remote", "local", "source", "time_out", } kb2 = KeyBundle().load(res) assert len(kb2.keys()) == 2 assert len(kb2.active_keys()) == 1
def test_mark_as_inactive(): desc = {"kty": "oct", "key": "highestsupersecret", "use": "sig"} kb = KeyBundle([desc]) assert len(kb.keys()) == 1 for k in kb.keys(): kb.mark_as_inactive(k.kid) desc = {"kty": "oct", "key": "highestsupersecret", "use": "enc"} kb.add_jwk_dicts([desc]) assert len(kb.keys()) == 2 assert len(kb.active_keys()) == 1