MCPcopy Create free account
hub / github.com/authlib/authlib / test_function_key

Function test_function_key

tests/jose/test_jws.py:145–168  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

143
144
145def test_function_key():
146 protected = {"alg": "HS256"}
147 header = [
148 {"protected": protected, "header": {"kid": "a"}},
149 {"protected": protected, "header": {"kid": "b"}},
150 ]
151
152 def load_key(header, payload):
153 assert payload == b"hello"
154 kid = header.get("kid")
155 if kid == "a":
156 return "secret-a"
157 return "secret-b"
158
159 jws = JsonWebSignature()
160 s = jws.serialize(header, b"hello", load_key)
161 assert isinstance(s, dict)
162 assert "signatures" in s
163
164 data = jws.deserialize(json.dumps(s), load_key)
165 header, payload = data["header"], data["payload"]
166 assert payload == b"hello"
167 assert header[0]["alg"] == "HS256"
168 assert "signature" not in data
169
170
171def test_serialize_json_empty_payload():

Callers

nothing calls this directly

Calls 3

serializeMethod · 0.95
deserializeMethod · 0.95
JsonWebSignatureClass · 0.90

Tested by

no test coverage detected