Commit c5634e69 authored by Vincent Pelletier's avatar Vincent Pelletier

cli.updater: Make testable.

parent 1fec835c
...@@ -589,7 +589,7 @@ def probe(argv=None): ...@@ -589,7 +589,7 @@ def probe(argv=None):
if https_ca_pem not in (http_ca_pem, http2_ca_pem): if https_ca_pem not in (http_ca_pem, http2_ca_pem):
raise ValueError('http and https do not serve the same caucase database') raise ValueError('http and https do not serve the same caucase database')
def updater(argv=None): def updater(argv=None, until=utils.until):
""" """
Bootstrap certificate and companion files and keep them up-to-date. Bootstrap certificate and companion files and keep them up-to-date.
""" """
...@@ -719,7 +719,7 @@ def updater(argv=None): ...@@ -719,7 +719,7 @@ def updater(argv=None):
# through. # through.
client.getCertificateSigningRequest(csr_id) client.getCertificateSigningRequest(csr_id)
# Still here ? Ok, wait a bit and try again. # Still here ? Ok, wait a bit and try again.
utils.interruptibleSleep(60) until(datetime.datetime.utcnow() + datetime.timedelta(0, 60))
else: else:
with open(args.crt, 'a') as crt_file: with open(args.crt, 'a') as crt_file:
crt_file.write(crt_pem) crt_file.write(crt_pem)
...@@ -731,7 +731,7 @@ def updater(argv=None): ...@@ -731,7 +731,7 @@ def updater(argv=None):
print 'Next wake-up at', next_deadline.strftime( print 'Next wake-up at', next_deadline.strftime(
'%Y-%m-%d %H:%M:%S +0000' '%Y-%m-%d %H:%M:%S +0000'
) )
now = utils.until(next_deadline) now = until(next_deadline)
if args.cas_ca != args.ca and updateCAFile(cas_url, args.cas_ca): if args.cas_ca != args.ca and updateCAFile(cas_url, args.cas_ca):
client = CaucaseClient( client = CaucaseClient(
ca_url=ca_url, ca_url=ca_url,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment