test: update tests to handle all branches
chore: ignore the except clauses for coverage
This commit is contained in:
parent
9a1a960641
commit
26638e7e73
2 changed files with 10 additions and 5 deletions
|
@ -49,7 +49,7 @@ def get_alt_names(cert):
|
||||||
try:
|
try:
|
||||||
ext = cert.extensions.get_extension_for_class(x509.SubjectAlternativeName)
|
ext = cert.extensions.get_extension_for_class(x509.SubjectAlternativeName)
|
||||||
return ext.value.get_values_for_type(x509.DNSName)
|
return ext.value.get_values_for_type(x509.DNSName)
|
||||||
except x509.ExtensionNotFound:
|
except x509.ExtensionNotFound: # pragma: no cover
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ def get_common_name(cert):
|
||||||
try:
|
try:
|
||||||
names = cert.subject.get_attributes_for_oid(NameOID.COMMON_NAME)
|
names = cert.subject.get_attributes_for_oid(NameOID.COMMON_NAME)
|
||||||
return names[0].value
|
return names[0].value
|
||||||
except x509.ExtensionNotFound:
|
except x509.ExtensionNotFound: # pragma: no cover
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ def get_issuer(cert):
|
||||||
try:
|
try:
|
||||||
names = cert.issuer.get_attributes_for_oid(NameOID.COMMON_NAME)
|
names = cert.issuer.get_attributes_for_oid(NameOID.COMMON_NAME)
|
||||||
return names[0].value
|
return names[0].value
|
||||||
except x509.ExtensionNotFound:
|
except x509.ExtensionNotFound: # pragma: no cover
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,8 +124,6 @@ def main(san, dump, color, hosts):
|
||||||
else:
|
else:
|
||||||
click.echo(click.style(output_string))
|
click.echo(click.style(output_string))
|
||||||
|
|
||||||
# print(f"Certificate for {domain}\nexpires after: {x509.get_not_after()}")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main() # pylint: disable=no-value-for-parameter # pragma: no cover
|
main() # pylint: disable=no-value-for-parameter # pragma: no cover
|
||||||
|
|
|
@ -11,6 +11,8 @@ def test_main():
|
||||||
assert response.exit_code == 0
|
assert response.exit_code == 0
|
||||||
response = runner.invoke(cert_main, ["www.franklin.edu:443"])
|
response = runner.invoke(cert_main, ["www.franklin.edu:443"])
|
||||||
assert response.exit_code == 0
|
assert response.exit_code == 0
|
||||||
|
response = runner.invoke(cert_main, ["www.franklin.edu", "--no-color"])
|
||||||
|
assert response.exit_code == 0
|
||||||
|
|
||||||
|
|
||||||
def test_version():
|
def test_version():
|
||||||
|
@ -27,3 +29,8 @@ def test_dump():
|
||||||
def test_san():
|
def test_san():
|
||||||
response = runner.invoke(cert_main, ["www.franklin.edu", "--san"])
|
response = runner.invoke(cert_main, ["www.franklin.edu", "--san"])
|
||||||
assert response.exit_code == 0
|
assert response.exit_code == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_bad_cert():
|
||||||
|
response = runner.invoke(cert_main, ["support.bluequill.com", "--san"])
|
||||||
|
assert response.exit_code == 0
|
||||||
|
|
Loading…
Reference in a new issue