(self, tdata)
| 275 | |
| 276 | class 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: |
nothing calls this directly
no test coverage detected