X-Git-Url: https://v.licheni.net/stack/cam.git/blobdiff_plain/09eeaa8aa8624de64ea1860f79a3075dd1875c5f..7e4567f1470bf3a2c134438672247b3041a011c3:/cam/tests/test_ca.py diff --git a/cam/tests/test_ca.py b/cam/tests/test_ca.py index 35c61a3..748326f 100644 --- a/cam/tests/test_ca.py +++ b/cam/tests/test_ca.py @@ -2,6 +2,7 @@ import logging import os import tempfile import shutil +import subprocess import unittest from cam import ca from cam import openssl_wrap @@ -24,6 +25,9 @@ class CertStub(object): def get_expiration_date(self): return 123456789 + def exists(self): + return os.path.exists(self.public_key_file) + class CATest(unittest.TestCase): @@ -49,6 +53,17 @@ class CATest(unittest.TestCase): self.assertTrue(os.path.exists(cert.public_key_file)) self.assertTrue(os.path.exists(cert.private_key_file)) + def test_create_cert_with_sha2_signature(self): + self.ca.config['signature_algorithm'] = 'sha256' + self.ca.create() + cert = CertStub('test', 'www.test.com', self.tmpdir) + self.ca.generate(cert) + self.assertTrue(os.path.exists(cert.public_key_file)) + self.assertTrue(os.path.exists(cert.private_key_file)) + self.assertTrue( + 'Signature Algorithm: sha256WithRSAEncryption' in subprocess.check_output( + ['openssl', 'x509', '-text', '-noout', '-in', cert.public_key_file])) + def test_revoke(self): self.ca.create() cert = CertStub('test', 'www.test.com', self.tmpdir)