mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Add basic unit tests for module_utils/acme.py. (#49103)
This commit is contained in:
parent
729c3a6767
commit
1e0ab16247
2 changed files with 204 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue