test: update tests to handle all branches

chore: ignore the except clauses for coverage
This commit is contained in:
Alex Kelly 2021-09-30 16:23:00 -04:00
parent 9a1a960641
commit 26638e7e73
2 changed files with 10 additions and 5 deletions

View file

@ -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

View file

@ -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