vary by preconfigured_renewal

and move expiry date to be above the renewal advice
This commit is contained in:
Alex Zorin 2021-02-08 18:33:19 +11:00
parent 13cee5aac9
commit 92cc34b68f
2 changed files with 28 additions and 11 deletions

View file

@ -489,17 +489,19 @@ def _report_new_cert(config, cert_path, fullchain_path, key_path=None):
assert cert_path and fullchain_path, "No certificates saved to report."
expiry = crypto_util.notAfter(cert_path).date()
display_util.notify(
("\nSuccessfully received certificate.\n"
"Certificate is saved at: {cert_path}\n{key_msg}{symlink_msg}"
"This certificate expires on {expiry}.").format(
"Certificate is saved at: {cert_path}\n{key_msg}"
"This certificate expires on {expiry}.\n"
"{renew_msg}\n").format(
cert_path=fullchain_path,
expiry=expiry,
expiry=crypto_util.notAfter(cert_path).date(),
key_msg="Key is saved at: {}\n".format(key_path) if key_path else "",
symlink_msg="These files will be automatically updated "
"every time the certificate is renewed.\n",
renew_msg="Certbot will automatically renew this certificate in the background."
if config.preconfigured_renewal else
("These files will be updated when the certificate renews. "
f'Run "{cli.cli_constants.cli_command} renew" to renew '
"all expiring certificates.")
)
)

View file

@ -1776,8 +1776,8 @@ class ReportNewCertTest(unittest.TestCase):
'\nSuccessfully received certificate.\n'
'Certificate is saved at: /path/to/fullchain.pem\n'
'Key is saved at: /path/to/privkey.pem\n'
'These files will be automatically updated every time the certificate is renewed.\n'
'This certificate expires on 1970-01-01.'
'This certificate expires on 1970-01-01.\n'
'Certbot will automatically renew this certificate in the background.\n'
)
def test_report_no_key(self):
@ -1788,10 +1788,25 @@ class ReportNewCertTest(unittest.TestCase):
self.mock_notify.assert_called_with(
'\nSuccessfully received certificate.\n'
'Certificate is saved at: /path/to/fullchain.pem\n'
'These files will be automatically updated every time the certificate is renewed.\n'
'This certificate expires on 1970-01-01.'
'This certificate expires on 1970-01-01.\n'
'Certbot will automatically renew this certificate in the background.\n'
)
def test_report_no_preconfigured_renewal(self):
self._call(mock.Mock(dry_run=False, preconfigured_renewal=False),
'/path/to/cert.pem', '/path/to/fullchain.pem',
'/path/to/privkey.pem')
self.mock_notify.assert_called_with(
'\nSuccessfully received certificate.\n'
'Certificate is saved at: /path/to/fullchain.pem\n'
'Key is saved at: /path/to/privkey.pem\n'
'This certificate expires on 1970-01-01.\n'
'These files will be updated when the certificate renews. '
'Run "certbot renew" to renew all expiring certificates.\n'
)
def test_csr_report(self):
self._call_csr(mock.Mock(dry_run=False), '/path/to/cert.pem',
'/path/to/chain.pem', '/path/to/fullchain.pem')