mirror of
https://github.com/certbot/certbot.git
synced 2026-08-03 00:22:04 +02:00
fixes #998
This commit is contained in:
+16
-1
@@ -329,9 +329,24 @@ class Client(object):
|
|||||||
self.installer.save() # needed by the Apache plugin
|
self.installer.save() # needed by the Apache plugin
|
||||||
|
|
||||||
self.installer.save("Deployed Let's Encrypt Certificate")
|
self.installer.save("Deployed Let's Encrypt Certificate")
|
||||||
# sites may have been enabled / final cleanup
|
|
||||||
|
# sites may have been enabled / final cleanup
|
||||||
|
with error_handler.ErrorHandler(self._rollback_and_restart):
|
||||||
self.installer.restart()
|
self.installer.restart()
|
||||||
|
|
||||||
|
def _rollback_and_restart(self):
|
||||||
|
"""Rollback the most recent checkpoint and restart the webserver"""
|
||||||
|
try:
|
||||||
|
self.installer.rollback_checkpoints()
|
||||||
|
self.installer.restart()
|
||||||
|
except:
|
||||||
|
# TODO: suggest letshelp-letsencypt here
|
||||||
|
logger.critical("Failure to rollback config "
|
||||||
|
"changes and restart your server")
|
||||||
|
logger.critical("Please submit a bug report to "
|
||||||
|
"https://github.com/letsencrypt/letsencrypt")
|
||||||
|
raise
|
||||||
|
|
||||||
def enhance_config(self, domains, redirect=None):
|
def enhance_config(self, domains, redirect=None):
|
||||||
"""Enhance the configuration.
|
"""Enhance the configuration.
|
||||||
|
|
||||||
|
|||||||
@@ -166,6 +166,27 @@ class ClientTest(unittest.TestCase):
|
|||||||
self.assertEqual(installer.save.call_count, 2)
|
self.assertEqual(installer.save.call_count, 2)
|
||||||
installer.restart.assert_called_once_with()
|
installer.restart.assert_called_once_with()
|
||||||
|
|
||||||
|
def test_deploy_certificate_restart_failure_with_recovery(self):
|
||||||
|
installer = mock.MagicMock()
|
||||||
|
installer.restart.side_effect = [errors.PluginError, None]
|
||||||
|
self.client.installer = installer
|
||||||
|
|
||||||
|
self.assertRaises(errors.PluginError, self.client.deploy_certificate,
|
||||||
|
["foo.bar"], "key", "cert", "chain", "fullchain")
|
||||||
|
installer.rollback_checkpoints.assert_called_once_with()
|
||||||
|
self.assertEqual(installer.restart.call_count, 2)
|
||||||
|
|
||||||
|
def test_deploy_certificate_restart_failure_without_recovery(self):
|
||||||
|
installer = mock.MagicMock()
|
||||||
|
installer.restart.side_effect = errors.PluginError
|
||||||
|
installer.rollback_checkpoints.side_effect = errors.ReverterError
|
||||||
|
self.client.installer = installer
|
||||||
|
|
||||||
|
self.assertRaises(errors.PluginError, self.client.deploy_certificate,
|
||||||
|
["foo.bar"], "key", "cert", "chain", "fullchain")
|
||||||
|
installer.rollback_checkpoints.assert_called_once_with()
|
||||||
|
self.assertEqual(installer.restart.call_count, 1)
|
||||||
|
|
||||||
@mock.patch("letsencrypt.client.enhancements")
|
@mock.patch("letsencrypt.client.enhancements")
|
||||||
def test_enhance_config(self, mock_enhancements):
|
def test_enhance_config(self, mock_enhancements):
|
||||||
self.assertRaises(errors.Error,
|
self.assertRaises(errors.Error,
|
||||||
|
|||||||
Reference in New Issue
Block a user