1
0
mirror of https://github.com/laurivosandi/certidude synced 2024-11-16 18:06:44 +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 - codecov
virtualenv: virtualenv:
system_site_packages: true system_site_packages: true
#before_install:
# - apt-get install -qq python-configparser python-setuptools
# - pip install codecov pytest-cov
install: install:
- pip install -r requirements.txt - pip install -r requirements.txt
- pip install --editable . - pip install --editable .
@ -18,3 +15,14 @@ script:
cache: cache:
directories: directories:
- $HOME/.cache/pip - $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 click.testing import CliRunner
from certidude.cli import entry_point as cli from certidude.cli import entry_point as cli
from datetime import datetime, timedelta
runner = CliRunner() runner = CliRunner()
@ -13,28 +13,13 @@ def test_cli_setup_authority():
# {crl-distribution,ocsp-responder}-url # {crl-distribution,ocsp-responder}-url
# email-address # email-address
# inbox, outbox # inbox, outbox
with runner.isolated_filesystem():
result = runner.invoke(cli, ['setup', 'authority', 'ca'])
assert not result.exception result = runner.invoke(cli, ['setup', 'authority'])
# Check whether required files were generated assert not result.exception
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(): from certidude import authority
with runner.isolated_filesystem(): assert authority.certificate.serial_number == '0000000000000000000000000000000000000001'
result = runner.invoke(cli, ['setup', 'authority']) assert authority.certificate.signed < datetime.now()
assert result.exception assert authority.certificate.expires > datetime.now() + timedelta(days=7000)
result = runner.invoke(cli, ['setup', 'authority', '""'])
assert result.exception
def test_cli_setup_authority_overwrite():
with runner.isolated_filesystem():
os.mkdir('foo')
result = runner.invoke(cli, ['setup', 'authority', 'foo'])
assert result.exception