mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 08:08:00 +02:00
Merge pull request #2093 from watercrossing/mixedListenFix
Fix for another apache configuration `Listen` special case
This commit is contained in:
@@ -558,6 +558,8 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
# In case no Listens are set (which really is a broken apache config)
|
# In case no Listens are set (which really is a broken apache config)
|
||||||
if not listens:
|
if not listens:
|
||||||
listens = ["80"]
|
listens = ["80"]
|
||||||
|
if port in listens:
|
||||||
|
return
|
||||||
for listen in listens:
|
for listen in listens:
|
||||||
# For any listen statement, check if the machine also listens on Port 443.
|
# For any listen statement, check if the machine also listens on Port 443.
|
||||||
# If not, add such a listen statement.
|
# If not, add such a listen statement.
|
||||||
|
|||||||
@@ -461,6 +461,25 @@ class TwoVhost80Test(util.ApacheTest):
|
|||||||
self.assertEqual(mock_add_dir.call_args_list[1][0][2], ["[::1]:8080", "https"])
|
self.assertEqual(mock_add_dir.call_args_list[1][0][2], ["[::1]:8080", "https"])
|
||||||
self.assertEqual(mock_add_dir.call_args_list[2][0][2], ["1.1.1.1:8080", "https"])
|
self.assertEqual(mock_add_dir.call_args_list[2][0][2], ["1.1.1.1:8080", "https"])
|
||||||
|
|
||||||
|
def test_prepare_server_https_mixed_listen(self):
|
||||||
|
|
||||||
|
mock_find = mock.Mock()
|
||||||
|
mock_find.return_value = ["test1", "test2"]
|
||||||
|
mock_get = mock.Mock()
|
||||||
|
mock_get.side_effect = ["1.2.3.4:8080", "443"]
|
||||||
|
mock_add_dir = mock.Mock()
|
||||||
|
mock_enable = mock.Mock()
|
||||||
|
|
||||||
|
self.config.parser.find_dir = mock_find
|
||||||
|
self.config.parser.get_arg = mock_get
|
||||||
|
self.config.parser.add_dir_to_ifmodssl = mock_add_dir
|
||||||
|
self.config.enable_mod = mock_enable
|
||||||
|
|
||||||
|
# Test Listen statements with specific ip listeed
|
||||||
|
self.config.prepare_server_https("443")
|
||||||
|
# Should only be 2 here, as the third interface already listens to the correct port
|
||||||
|
self.assertEqual(mock_add_dir.call_count, 0)
|
||||||
|
|
||||||
def test_make_vhost_ssl(self):
|
def test_make_vhost_ssl(self):
|
||||||
ssl_vhost = self.config.make_vhost_ssl(self.vh_truth[0])
|
ssl_vhost = self.config.make_vhost_ssl(self.vh_truth[0])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user