MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / test_simple

Method test_simple

test/mitmproxy/test_certs.py:277–322  ·  view source on GitHub ↗
(self, tdata)

Source from the content-addressed store, hash-verified

275
276class TestCert:
277 def test_simple(self, tdata):
278 with open(tdata.path("mitmproxy/net/data/text_cert"), "rb") as f:
279 d = f.read()
280 c1 = certs.Cert.from_pem(d)
281 assert c1.cn == "google.com"
282 assert len(c1.altnames) == 436
283 assert c1.organization == "Google Inc"
284 assert hash(c1)
285
286 with open(tdata.path("mitmproxy/net/data/text_cert_2"), "rb") as f:
287 d = f.read()
288 c2 = certs.Cert.from_pem(d)
289 assert c2.cn == "www.inode.co.nz"
290 assert len(c2.altnames) == 2
291 assert c2.fingerprint()
292 assert c2.public_key()
293 assert c2.notbefore == datetime(
294 year=2010,
295 month=1,
296 day=11,
297 hour=19,
298 minute=27,
299 second=36,
300 tzinfo=timezone.utc,
301 )
302 assert c2.notafter == datetime(
303 year=2011,
304 month=1,
305 day=12,
306 hour=9,
307 minute=14,
308 second=55,
309 tzinfo=timezone.utc,
310 )
311 assert c2.subject
312 assert c2.keyinfo == ("RSA", 2048)
313 assert c2.serial
314 assert c2.issuer
315 assert c2.to_pem()
316 assert c2.has_expired() is not None
317 assert (
318 repr(c2)
319 == "<Cert(cn='www.inode.co.nz', altnames=['www.inode.co.nz', 'inode.co.nz'])>"
320 )
321
322 assert c1 != c2
323
324 def test_convert(self, tdata):
325 with open(tdata.path("mitmproxy/net/data/text_cert"), "rb") as f:

Callers

nothing calls this directly

Calls 8

hashFunction · 0.85
from_pemMethod · 0.80
fingerprintMethod · 0.80
public_keyMethod · 0.80
to_pemMethod · 0.80
has_expiredMethod · 0.80
pathMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected