1
0
mirror of https://github.com/laurivosandi/certidude synced 2024-12-23 00:25:18 +00:00

Clean up tests

This commit is contained in:
Lauri Võsandi 2016-09-18 18:30:31 +03:00
parent 65b401538e
commit f19cf4652e
3 changed files with 19 additions and 40 deletions

View File

@ -7,9 +7,6 @@ after_success:
- codecov
virtualenv:
system_site_packages: true
#before_install:
# - apt-get install -qq python-configparser python-setuptools
# - pip install codecov pytest-cov
install:
- pip install -r requirements.txt
- pip install --editable .
@ -18,3 +15,14 @@ script:
cache:
directories:
- $HOME/.cache/pip
addons:
apt:
packages:
- python-configparser
- python-setuptools
- python-ldap
- python-mysql.connector
- python-pysqlite2
- python-cffi
- cython
# - pip install codecov pytest-cov

View File

@ -1,14 +0,0 @@
from click.testing import CliRunner
from certidude.cli import entry_point as cli
runner = CliRunner()
def test_ca_config():
# Authority setup
with runner.isolated_filesystem():
result = runner.invoke(cli, ['setup', 'authority'])
assert not result.exception
from certidude import authority
assert authority.certificate.serial_number == '0000000000000000000000000000000000000001'
# TODO: Figure out a way to properly test cert.signed, cert.expires, cert.digest, etc

View File

@ -1,6 +1,6 @@
import os
from click.testing import CliRunner
from certidude.cli import entry_point as cli
from datetime import datetime, timedelta
runner = CliRunner()
@ -13,28 +13,13 @@ def test_cli_setup_authority():
# {crl-distribution,ocsp-responder}-url
# email-address
# inbox, outbox
with runner.isolated_filesystem():
result = runner.invoke(cli, ['setup', 'authority', 'ca'])
assert not result.exception
# Check whether required files were generated
for f in ('ca_key.pem', 'ca_crt.pem', 'ca_crl.pem',
'serial', 'openssl.cnf.example'):
assert os.path.isfile(os.path.join('ca', f))
for d in ('requests', 'revoked', 'signed'):
assert os.path.isdir(os.path.join('ca', d))
def test_cli_setup_authority_invalid_name():
with runner.isolated_filesystem():
result = runner.invoke(cli, ['setup', 'authority'])
assert result.exception
assert not result.exception
result = runner.invoke(cli, ['setup', 'authority', '""'])
assert result.exception
from certidude import authority
assert authority.certificate.serial_number == '0000000000000000000000000000000000000001'
assert authority.certificate.signed < datetime.now()
assert authority.certificate.expires > datetime.now() + timedelta(days=7000)
def test_cli_setup_authority_overwrite():
with runner.isolated_filesystem():
os.mkdir('foo')
result = runner.invoke(cli, ['setup', 'authority', 'foo'])
assert result.exception