mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
Add basic unit tests for module_utils/acme.py. (#49103)
This commit is contained in:
committed by
John R Barker
parent
729c3a6767
commit
1e0ab16247
@@ -795,7 +795,7 @@ def cryptography_get_csr_domains(module, csr_filename):
|
||||
return domains
|
||||
|
||||
|
||||
def cryptography_get_cert_days(module, cert_file):
|
||||
def cryptography_get_cert_days(module, cert_file, now=None):
|
||||
'''
|
||||
Return the days the certificate in cert_file remains valid and -1
|
||||
if the file was not found. If cert_file contains more than one
|
||||
@@ -808,7 +808,8 @@ def cryptography_get_cert_days(module, cert_file):
|
||||
cert = cryptography.x509.load_pem_x509_certificate(read_file(cert_file), _cryptography_backend)
|
||||
except Exception as e:
|
||||
raise ModuleFailException('Cannot parse certificate {0}: {1}'.format(cert_file, e))
|
||||
now = datetime.datetime.now()
|
||||
if now is None:
|
||||
now = datetime.datetime.now()
|
||||
return (cert.not_valid_after - now).days
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user