Skip to content

Commit 2751f60

Browse files
author
Roland Hedberg
committed
Comparing to binary representations doesn't work.
1 parent ecf8cf2 commit 2751f60

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/jwkest/jwk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ def __eq__(self, other):
300300
assert isinstance(other, Key)
301301
assert self.__dict__.keys() == other.__dict__.keys()
302302

303-
for key, val in self.__dict__.items():
304-
assert getattr(other, key) == val
303+
for key in self.public_members:
304+
assert getattr(other, key) == getattr(self, key)
305305
except AssertionError:
306306
return False
307307
else:

tests/test_0_jwk.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,5 +203,19 @@ def test_cmp_rsa_ec():
203203
else:
204204
assert False
205205

206+
207+
def test_cmp_neq_ec():
208+
priv, pub = P256.key_pair()
209+
_key1 = ECKey(x=pub[0], y=pub[1], d=priv, crv="P-256")
210+
_key2 = ECKey(**ECKEY)
211+
212+
try:
213+
assert _key1 == _key2
214+
except AssertionError:
215+
pass
216+
else:
217+
assert False
218+
219+
206220
if __name__ == "__main__":
207-
test_cmp_rsa_ec()
221+
test_cmp_neq_ec()

0 commit comments

Comments
 (0)