add Cert.__repr__ to ease debugging

This commit is contained in:
Maximilian Hils 2021-07-19 15:18:13 +02:00
parent c718d4f7b0
commit 34774885e0
2 changed files with 4 additions and 0 deletions

View File

@ -49,6 +49,9 @@ class Cert(serializable.Serializable):
def __eq__(self, other): def __eq__(self, other):
return self.fingerprint() == other.fingerprint() return self.fingerprint() == other.fingerprint()
def __repr__(self):
return f"<Cert(cn={self.cn!r}, altnames={self.altnames!r})>"
@classmethod @classmethod
def from_state(cls, state): def from_state(cls, state):
return cls.from_pem(state) return cls.from_pem(state)

View File

@ -180,6 +180,7 @@ class TestCert:
assert c2.issuer assert c2.issuer
assert c2.to_pem() assert c2.to_pem()
assert c2.has_expired() is not None assert c2.has_expired() is not None
assert repr(c2) == "<Cert(cn='www.inode.co.nz', altnames=['www.inode.co.nz', 'inode.co.nz'])>"
assert c1 != c2 assert c1 != c2