mirror of
https://github.com/certbot/certbot.git
synced 2026-08-03 00:22:04 +02:00
Merge pull request #1591 from letsencrypt/simple-log
Log, not fail (fixes #1585)
This commit is contained in:
@@ -173,17 +173,12 @@ s.serve_forever()" """
|
|||||||
uri=achall.chall.uri(achall.domain),
|
uri=achall.chall.uri(achall.domain),
|
||||||
ct=achall.CONTENT_TYPE, command=command))
|
ct=achall.CONTENT_TYPE, command=command))
|
||||||
|
|
||||||
if response.simple_verify(
|
if not response.simple_verify(
|
||||||
achall.chall, achall.domain,
|
achall.chall, achall.domain,
|
||||||
achall.account_key.public_key(), self.config.http01_port):
|
achall.account_key.public_key(), self.config.http01_port):
|
||||||
|
logger.warning("Self-verify of challenge failed.")
|
||||||
|
|
||||||
return response
|
return response
|
||||||
else:
|
|
||||||
logger.error(
|
|
||||||
"Self-verify of challenge failed, authorization abandoned.")
|
|
||||||
if self.conf("test-mode") and self._httpd.poll() is not None:
|
|
||||||
# simply verify cause command failure...
|
|
||||||
return False
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _notify_and_wait(self, message): # pylint: disable=no-self-use
|
def _notify_and_wait(self, message): # pylint: disable=no-self-use
|
||||||
# TODO: IDisplay wraps messages, breaking the command
|
# TODO: IDisplay wraps messages, breaking the command
|
||||||
|
|||||||
@@ -61,7 +61,9 @@ class AuthenticatorTest(unittest.TestCase):
|
|||||||
self.assertTrue(self.achalls[0].chall.encode("token") in message)
|
self.assertTrue(self.achalls[0].chall.encode("token") in message)
|
||||||
|
|
||||||
mock_verify.return_value = False
|
mock_verify.return_value = False
|
||||||
self.assertEqual([None], self.auth.perform(self.achalls))
|
with mock.patch("letsencrypt.plugins.manual.logger") as mock_logger:
|
||||||
|
self.auth.perform(self.achalls)
|
||||||
|
mock_logger.warning.assert_called_once_with(mock.ANY)
|
||||||
|
|
||||||
@mock.patch("letsencrypt.plugins.manual.zope.component.getUtility")
|
@mock.patch("letsencrypt.plugins.manual.zope.component.getUtility")
|
||||||
@mock.patch("letsencrypt.plugins.manual.Authenticator._notify_and_wait")
|
@mock.patch("letsencrypt.plugins.manual.Authenticator._notify_and_wait")
|
||||||
@@ -87,20 +89,6 @@ class AuthenticatorTest(unittest.TestCase):
|
|||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
errors.Error, self.auth_test_mode.perform, self.achalls)
|
errors.Error, self.auth_test_mode.perform, self.achalls)
|
||||||
|
|
||||||
@mock.patch("letsencrypt.plugins.manual.socket.socket")
|
|
||||||
@mock.patch("letsencrypt.plugins.manual.time.sleep", autospec=True)
|
|
||||||
@mock.patch("acme.challenges.HTTP01Response.simple_verify",
|
|
||||||
autospec=True)
|
|
||||||
@mock.patch("letsencrypt.plugins.manual.subprocess.Popen", autospec=True)
|
|
||||||
def test_perform_test_mode(self, mock_popen, mock_verify, mock_sleep,
|
|
||||||
mock_socket):
|
|
||||||
mock_popen.return_value.poll.side_effect = [None, 10]
|
|
||||||
mock_popen.return_value.pid = 1234
|
|
||||||
mock_verify.return_value = False
|
|
||||||
self.assertEqual([False], self.auth_test_mode.perform(self.achalls))
|
|
||||||
self.assertEqual(1, mock_sleep.call_count)
|
|
||||||
self.assertEqual(1, mock_socket.call_count)
|
|
||||||
|
|
||||||
def test_cleanup_test_mode_already_terminated(self):
|
def test_cleanup_test_mode_already_terminated(self):
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
self.auth_test_mode._httpd = httpd = mock.Mock()
|
self.auth_test_mode._httpd = httpd = mock.Mock()
|
||||||
|
|||||||
Reference in New Issue
Block a user