Skip to content

Commit 6734b73

Browse files
authored
Merge pull request #187 from jschlyter/kid_compare
2 parents a1b9611 + cb0e50c commit 6734b73

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/cryptojwt/jwk/ec.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,20 @@ def __eq__(self, other):
243243
if self.__class__ != other.__class__:
244244
return False
245245

246+
if self.use and other.use:
247+
if self.use != other.use:
248+
return False
249+
250+
if self.kid:
251+
if other.kid:
252+
if self.kid != other.kid:
253+
return False
254+
else:
255+
return False
256+
else:
257+
if other.kid:
258+
return False
259+
246260
if cmp_keys(self.pub_key, other.pub_key, ec.EllipticCurvePublicKey):
247261
if other.private_key():
248262
if cmp_keys(self.priv_key, other.priv_key, ec.EllipticCurvePrivateKey):

tests/test_02_jwk.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,22 @@ def test_cmp_eq_ec():
216216
assert _key1 == _key2
217217

218218

219+
def test_cmp_eq_ec_kid():
220+
ec_key = new_ec_key("P-256")
221+
_key1 = ECKey(priv_key=ec_key.priv_key, kid="foo")
222+
_key2 = ECKey(priv_key=ec_key.priv_key, kid="bar")
223+
224+
assert _key1 != _key2
225+
226+
227+
def test_cmp_eq_rsa_kid():
228+
rsa_key = new_rsa_key()
229+
_key1 = RSAKey(priv_key=rsa_key.priv_key, kid="foo")
230+
_key2 = RSAKey(priv_key=rsa_key.priv_key, kid="bar")
231+
232+
assert _key1 != _key2
233+
234+
219235
def test_get_key():
220236
ec_key = new_ec_key("P-256")
221237
asym_private_key = ECKey(priv_key=ec_key.priv_key)

0 commit comments

Comments
 (0)