diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2013-01-06 01:15:53 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2013-01-06 01:16:25 +1300 |
commit | 72032d7fe75fae1bc1318cf0390e55af6a93ff4d (patch) | |
tree | 6029800cf4ecfab9753eab2d541297a64732e6c5 /test/test_certutils.py | |
parent | a9a4064ff94abdddabc22789a9c32f0cb02c55cb (diff) | |
download | mitmproxy-72032d7fe75fae1bc1318cf0390e55af6a93ff4d.tar.gz mitmproxy-72032d7fe75fae1bc1318cf0390e55af6a93ff4d.tar.bz2 mitmproxy-72032d7fe75fae1bc1318cf0390e55af6a93ff4d.zip |
Basic certificate store implementation and cert utils API cleanup.
Diffstat (limited to 'test/test_certutils.py')
-rw-r--r-- | test/test_certutils.py | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/test/test_certutils.py b/test/test_certutils.py index 9b8e7085..9b917dc6 100644 --- a/test/test_certutils.py +++ b/test/test_certutils.py @@ -16,36 +16,40 @@ def test_dummy_ca(): assert os.path.exists(os.path.join(d, "foo/cert2-cert.p12")) +class TestCertStore: + def test_create_explicit(self): + with tutils.tmpdir() as d: + ca = os.path.join(d, "ca") + assert certutils.dummy_ca(ca) + c = certutils.CertStore(d) + c.cleanup() + assert os.path.exists(d) + + def test_create_tmp(self): + with tutils.tmpdir() as d: + ca = os.path.join(d, "ca") + assert certutils.dummy_ca(ca) + c = certutils.CertStore() + assert not c.get_cert("foo.com", []) + assert c.get_cert("foo.com", [], ca) + assert c.get_cert("foo.com", [], ca) + c.cleanup() + + class TestDummyCert: def test_with_ca(self): with tutils.tmpdir() as d: - cacert = os.path.join(d, "foo/cert.cnf") + cacert = os.path.join(d, "cacert") assert certutils.dummy_ca(cacert) - p = certutils.dummy_cert( - os.path.join(d, "foo"), + p = os.path.join(d, "foo") + certutils.dummy_cert( + file(p, "w"), cacert, "foo.com", ["one.com", "two.com", "*.three.com"] ) - assert os.path.exists(p) - - # Short-circuit - assert certutils.dummy_cert( - os.path.join(d, "foo"), - cacert, - "foo.com", - [] - ) + assert file(p).read() - def test_no_ca(self): - with tutils.tmpdir() as d: - p = certutils.dummy_cert( - d, - None, - "foo.com", - [] - ) - assert os.path.exists(p) class TestSSLCert: |