From 72032d7fe75fae1bc1318cf0390e55af6a93ff4d Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 6 Jan 2013 01:15:53 +1300 Subject: Basic certificate store implementation and cert utils API cleanup. --- test/test_certutils.py | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'test/test_certutils.py') 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: -- cgit v1.2.3