7 from cam import openssl_wrap
10 logging.basicConfig(level=logging.DEBUG)
13 class CertStub(object):
15 def __init__(self, name, cn, tmpdir):
21 self.public_key_file = os.path.join(tmpdir, '%s.pub' % name)
22 self.private_key_file = os.path.join(tmpdir, '%s.priv' % name)
24 def get_expiration_date(self):
28 class CATest(unittest.TestCase):
31 self.tmpdir = tempfile.mkdtemp()
32 self.ca = ca.CA(self.tmpdir,
33 {'cn': 'test ca', 'org': 'test',
34 'bits': '1024', 'email': 'test@test.com'},
39 shutil.rmtree(self.tmpdir)
41 def test_create(self):
43 self.assertTrue(os.path.exists(os.path.join(self.tmpdir, 'conf/ca.conf')))
45 def test_create_cert(self):
47 cert = CertStub('test', 'www.test.com', self.tmpdir)
48 self.ca.generate(cert)
49 self.assertTrue(os.path.exists(cert.public_key_file))
50 self.assertTrue(os.path.exists(cert.private_key_file))
52 def test_revoke(self):
54 cert = CertStub('test', 'www.test.com', self.tmpdir)
55 self.ca.generate(cert)
57 self.assertTrue(os.path.exists(os.path.join(self.tmpdir, 'public/crl.pem')))