diff --git a/checkcert/checkcert.py b/checkcert/checkcert.py index 7b0fb9e..16e378a 100644 --- a/checkcert/checkcert.py +++ b/checkcert/checkcert.py @@ -49,7 +49,7 @@ def get_alt_names(cert): try: ext = cert.extensions.get_extension_for_class(x509.SubjectAlternativeName) return ext.value.get_values_for_type(x509.DNSName) - except x509.ExtensionNotFound: + except x509.ExtensionNotFound: # pragma: no cover return None @@ -63,7 +63,7 @@ def get_common_name(cert): try: names = cert.subject.get_attributes_for_oid(NameOID.COMMON_NAME) return names[0].value - except x509.ExtensionNotFound: + except x509.ExtensionNotFound: # pragma: no cover return None @@ -72,7 +72,7 @@ def get_issuer(cert): try: names = cert.issuer.get_attributes_for_oid(NameOID.COMMON_NAME) return names[0].value - except x509.ExtensionNotFound: + except x509.ExtensionNotFound: # pragma: no cover return None @@ -124,8 +124,6 @@ def main(san, dump, color, hosts): else: click.echo(click.style(output_string)) - # print(f"Certificate for {domain}\nexpires after: {x509.get_not_after()}") - if __name__ == "__main__": main() # pylint: disable=no-value-for-parameter # pragma: no cover diff --git a/tests/test_checkcert.py b/tests/test_checkcert.py index bc5d83c..e962a18 100644 --- a/tests/test_checkcert.py +++ b/tests/test_checkcert.py @@ -11,6 +11,8 @@ def test_main(): assert response.exit_code == 0 response = runner.invoke(cert_main, ["www.franklin.edu:443"]) assert response.exit_code == 0 + response = runner.invoke(cert_main, ["www.franklin.edu", "--no-color"]) + assert response.exit_code == 0 def test_version(): @@ -27,3 +29,8 @@ def test_dump(): def test_san(): response = runner.invoke(cert_main, ["www.franklin.edu", "--san"]) assert response.exit_code == 0 + + +def test_bad_cert(): + response = runner.invoke(cert_main, ["support.bluequill.com", "--san"]) + assert response.exit_code == 0