From f19cf4652e4dbe7ba9be3c91b5b63d42533761c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20V=C3=B5sandi?= Date: Sun, 18 Sep 2016 18:30:31 +0300 Subject: [PATCH] Clean up tests --- .travis.yml | 14 +++++++++++--- tests/test_ca.py | 14 -------------- tests/test_cli.py | 31 ++++++++----------------------- 3 files changed, 19 insertions(+), 40 deletions(-) delete mode 100644 tests/test_ca.py diff --git a/.travis.yml b/.travis.yml index 23c130e..5432122 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/tests/test_ca.py b/tests/test_ca.py deleted file mode 100644 index 531acc9..0000000 --- a/tests/test_ca.py +++ /dev/null @@ -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 diff --git a/tests/test_cli.py b/tests/test_cli.py index 92b1e4f..1c6343c 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -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)) + result = runner.invoke(cli, ['setup', 'authority']) + assert not result.exception -def test_cli_setup_authority_invalid_name(): - with runner.isolated_filesystem(): - 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) - 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 +