From 4b9ae5ff3fb7fa3f03c8be9308f81a87b89c9a0e Mon Sep 17 00:00:00 2001 From: Alex Kelly Date: Tue, 28 Sep 2021 16:44:52 -0400 Subject: [PATCH] test: add initial test cases --- CHANGELOG.md | 7 +++++++ checkcert/checkcert.py | 3 +++ pyproject.toml | 2 +- tests/__init__.py | 0 tests/test_checkcert.py | 17 +++++++++++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md create mode 100644 tests/__init__.py create mode 100644 tests/test_checkcert.py diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..97cd662 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog + +## Unreleased (2021-09-28) + +#### New Features + +* add option to display the text version of the x509 cert diff --git a/checkcert/checkcert.py b/checkcert/checkcert.py index 2835b0a..4900e97 100644 --- a/checkcert/checkcert.py +++ b/checkcert/checkcert.py @@ -3,8 +3,11 @@ import sys import click import M2Crypto +__version__ = "0.1.0" + @click.command() +@click.version_option(__version__, prog_name="checkcert") @click.option("--san", is_flag=True, help="Output Subject Alternate Names") @click.option( "--dump", is_flag=True, help="Dump the full text version of the x509 certificate" diff --git a/pyproject.toml b/pyproject.toml index 5140adb..db72c66 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,6 +24,6 @@ task-status = 'checkcert.checkcert:main' [tool.semantic_release] version_variable = [ - "task_status/task_status.py:__version__", + "checkcert/checkcert.py:__version__", "pyproject.toml:version" ] diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_checkcert.py b/tests/test_checkcert.py new file mode 100644 index 0000000..835a958 --- /dev/null +++ b/tests/test_checkcert.py @@ -0,0 +1,17 @@ +from checkcert.checkcert import main as cert_main +from checkcert.checkcert import __version__ as cert_version +from click.testing import CliRunner + +runner = CliRunner() + + +def test_main(): + if cert_main: + response = runner.invoke(cert_main, ["www.franklin.edu"]) + assert response.exit_code == 0 + + +def test_version(): + response = runner.invoke(cert_main, ["--version"]) + assert response.exit_code == 0 + assert cert_version in response.output