mirror of
https://github.com/laurivosandi/certidude
synced 2024-12-22 16:25:17 +00:00
Add basic tests for CA
This commit is contained in:
parent
244919ba92
commit
9a845fc009
@ -123,12 +123,7 @@ class CertificateAuthorityConfig(object):
|
||||
"""
|
||||
Returns sorted list of CA-s defined in the configuration file.
|
||||
"""
|
||||
l = [s[3:] for s in self._config if s.startswith("CA_")]
|
||||
# Sanity check for duplicates (although ConfigParser fails earlier)
|
||||
if len(l) != len(set(l)):
|
||||
raise ValueError
|
||||
return sorted(l)
|
||||
|
||||
return sorted([s[3:] for s in self._config if s.startswith("CA_")])
|
||||
|
||||
def pop_certificate_authority(self):
|
||||
def wrapper(func):
|
||||
|
25
tests/test_ca.py
Normal file
25
tests/test_ca.py
Normal file
@ -0,0 +1,25 @@
|
||||
from click.testing import CliRunner
|
||||
from certidude.cli import entry_point as cli
|
||||
|
||||
|
||||
from certidude.wrappers import CertificateAuthorityConfig
|
||||
|
||||
runner = CliRunner()
|
||||
|
||||
def test_ca_config():
|
||||
# Authority setup
|
||||
with runner.isolated_filesystem():
|
||||
result = runner.invoke(cli, ['setup', 'authority', 'xca'])
|
||||
assert not result.exception
|
||||
|
||||
# Load CA
|
||||
conf = CertificateAuthorityConfig('./xca/openssl.cnf.example')
|
||||
|
||||
assert conf.ca_list == ['xca']
|
||||
|
||||
ca = conf.instantiate_authority('xca')
|
||||
|
||||
cert = ca.certificate
|
||||
|
||||
assert cert.serial_number == '0000000000000000000000000000000000000001'
|
||||
# TODO: Figure out a way to properly test cert.signed, cert.expires, cert.digest, etc
|
@ -1,6 +1,4 @@
|
||||
import os
|
||||
import pwd
|
||||
import pytest
|
||||
from click.testing import CliRunner
|
||||
from certidude.cli import entry_point as cli
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user