diff --git a/letsencrypt/plugins/standalone.py b/letsencrypt/plugins/standalone.py index cb95ec408..e742734a9 100644 --- a/letsencrypt/plugins/standalone.py +++ b/letsencrypt/plugins/standalone.py @@ -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: diff --git a/letsencrypt/plugins/standalone_test.py b/letsencrypt/plugins/standalone_test.py index e99bd473a..b873da6f2 100644 --- a/letsencrypt/plugins/standalone_test.py +++ b/letsencrypt/plugins/standalone_test.py @@ -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]