mirror of
https://github.com/certbot/certbot.git
synced 2026-08-03 03:32:13 +02:00
Merge pull request #1160 from kuba/bugs/1149
Standalone verifies ports for supported challenges only (fixes #1149).
This commit is contained in:
@@ -181,6 +181,15 @@ class Authenticator(common.Plugin):
|
|||||||
return set(challenges.Challenge.TYPES[name] for name in
|
return set(challenges.Challenge.TYPES[name] for name in
|
||||||
self.conf("supported-challenges").split(","))
|
self.conf("supported-challenges").split(","))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _necessary_ports(self):
|
||||||
|
necessary_ports = set()
|
||||||
|
if challenges.SimpleHTTP in self.supported_challenges:
|
||||||
|
necessary_ports.add(self.config.simple_http_port)
|
||||||
|
if challenges.DVSNI in self.supported_challenges:
|
||||||
|
necessary_ports.add(self.config.dvsni_port)
|
||||||
|
return necessary_ports
|
||||||
|
|
||||||
def more_info(self): # pylint: disable=missing-docstring
|
def more_info(self): # pylint: disable=missing-docstring
|
||||||
return self.__doc__
|
return self.__doc__
|
||||||
|
|
||||||
@@ -194,8 +203,7 @@ class Authenticator(common.Plugin):
|
|||||||
return chall_pref
|
return chall_pref
|
||||||
|
|
||||||
def perform(self, achalls): # pylint: disable=missing-docstring
|
def perform(self, achalls): # pylint: disable=missing-docstring
|
||||||
if any(util.already_listening(port) for port in
|
if any(util.already_listening(port) for port in self._necessary_ports):
|
||||||
(self.config.dvsni_port, self.config.simple_http_port)):
|
|
||||||
raise errors.MisconfigurationError(
|
raise errors.MisconfigurationError(
|
||||||
"At least one of the (possibly) required ports is "
|
"At least one of the (possibly) required ports is "
|
||||||
"already taken.")
|
"already taken.")
|
||||||
|
|||||||
@@ -107,10 +107,15 @@ class AuthenticatorTest(unittest.TestCase):
|
|||||||
set([challenges.DVSNI, challenges.SimpleHTTP]))
|
set([challenges.DVSNI, challenges.SimpleHTTP]))
|
||||||
|
|
||||||
@mock.patch("letsencrypt.plugins.standalone.util")
|
@mock.patch("letsencrypt.plugins.standalone.util")
|
||||||
def test_perform_misconfiguration(self, mock_util):
|
def test_perform_alredy_listening(self, mock_util):
|
||||||
mock_util.already_listening.return_value = True
|
for chall, port in ((challenges.DVSNI.typ, 1234),
|
||||||
self.assertRaises(errors.MisconfigurationError, self.auth.perform, [])
|
(challenges.SimpleHTTP.typ, 4321)):
|
||||||
mock_util.already_listening.assert_called_once_with(1234)
|
mock_util.already_listening.return_value = True
|
||||||
|
self.config.standalone_supported_challenges = chall
|
||||||
|
self.assertRaises(
|
||||||
|
errors.MisconfigurationError, self.auth.perform, [])
|
||||||
|
mock_util.already_listening.assert_called_once_with(port)
|
||||||
|
mock_util.already_listening.reset_mock()
|
||||||
|
|
||||||
@mock.patch("letsencrypt.plugins.standalone.zope.component.getUtility")
|
@mock.patch("letsencrypt.plugins.standalone.zope.component.getUtility")
|
||||||
def test_perform(self, unused_mock_get_utility):
|
def test_perform(self, unused_mock_get_utility):
|
||||||
|
|||||||
Reference in New Issue
Block a user