aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_certutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_certutils.py')
-rw-r--r--test/test_certutils.py46
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: