mirror of
https://github.com/certbot/certbot.git
synced 2026-07-27 08:09:10 +02:00
standalone2: move alread_listening to perform
This commit is contained in:
@@ -182,11 +182,7 @@ class Authenticator(common.Plugin):
|
||||
return self.__doc__
|
||||
|
||||
def prepare(self): # pylint: disable=missing-docstring
|
||||
if any(util.already_listening(port) for port in
|
||||
(self.config.dvsni_port, self.config.simple_http_port)):
|
||||
raise errors.MisconfigurationError(
|
||||
"At least one of the (possibly) required ports is "
|
||||
"already taken.")
|
||||
pass
|
||||
|
||||
def get_chall_pref(self, domain):
|
||||
# pylint: disable=unused-argument,missing-docstring
|
||||
@@ -195,6 +191,12 @@ class Authenticator(common.Plugin):
|
||||
return chall_pref
|
||||
|
||||
def perform(self, achalls): # pylint: disable=missing-docstring
|
||||
if any(util.already_listening(port) for port in
|
||||
(self.config.dvsni_port, self.config.simple_http_port)):
|
||||
raise errors.MisconfigurationError(
|
||||
"At least one of the (possibly) required ports is "
|
||||
"already taken.")
|
||||
|
||||
try:
|
||||
return self.perform2(achalls)
|
||||
except errors.StandaloneBindError as error:
|
||||
|
||||
@@ -101,16 +101,16 @@ class AuthenticatorTest(unittest.TestCase):
|
||||
def test_more_info(self):
|
||||
self.assertTrue(isinstance(self.auth.more_info(), six.string_types))
|
||||
|
||||
@mock.patch("letsencrypt.plugins.standalone.util")
|
||||
def test_prepare_misconfiguration(self, mock_util):
|
||||
mock_util.already_listening.return_value = True
|
||||
self.assertRaises(errors.MisconfigurationError, self.auth.prepare)
|
||||
mock_util.already_listening.assert_called_once_with(1234)
|
||||
|
||||
def test_get_chall_pref(self):
|
||||
self.assertEqual(set(self.auth.get_chall_pref(domain=None)),
|
||||
set([challenges.DVSNI, challenges.SimpleHTTP]))
|
||||
|
||||
@mock.patch("letsencrypt.plugins.standalone.util")
|
||||
def test_perform_misconfiguration(self, mock_util):
|
||||
mock_util.already_listening.return_value = True
|
||||
self.assertRaises(errors.MisconfigurationError, self.auth.perform, [])
|
||||
mock_util.already_listening.assert_called_once_with(1234)
|
||||
|
||||
@mock.patch("letsencrypt.plugins.standalone.zope.component.getUtility")
|
||||
def test_perform(self, unused_mock_get_utility):
|
||||
achalls = [1, 2, 3]
|
||||
|
||||
Reference in New Issue
Block a user