MCPcopy Create free account
hub / github.com/mpdavis/python-jose / test_multiple_keys

Method test_multiple_keys

tests/test_jws.py:28–42  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

26 jws.verify(token, "secret", ["HS256"])
27
28 def test_multiple_keys(self):
29 old_jwk_verify = jwk.HMACKey.verify
30 try:
31 token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoiYiJ9.jiMyrsmD8AoHWeQgmxZ5yq8z0lXS67_QGs52AzC8Ru8"
32
33 def raise_exception(self, msg, sig):
34 if self.prepared_key == b"incorrect":
35 raise Exception("Mocked function jose.jwk.HMACKey.verify")
36 else:
37 return True
38
39 jwk.HMACKey.verify = raise_exception
40 jws.verify(token, {"keys": ["incorrect", "secret"]}, ["HS256"])
41 finally:
42 jwk.HMACKey.verify = old_jwk_verify
43
44 def test_invalid_algorithm(self):
45 token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoiYiJ9.jiMyrsmD8AoHWeQgmxZ5yq8z0lXS67_QGs52AzC8Ru8"

Callers

nothing calls this directly

Calls 1

verifyMethod · 0.45

Tested by

no test coverage detected