mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 19:31:51 +02:00
revert to simple enable_mod, disable_mod, enable_mod
This commit is contained in:
@@ -482,7 +482,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
logger.debug(msg)
|
logger.debug(msg)
|
||||||
self.save_notes += msg
|
self.save_notes += msg
|
||||||
|
|
||||||
def prepare_server_https(self, port):
|
def prepare_server_https(self, port, temp=False):
|
||||||
"""Prepare the server for HTTPS.
|
"""Prepare the server for HTTPS.
|
||||||
|
|
||||||
Make sure that the ssl_module is loaded and that the server
|
Make sure that the ssl_module is loaded and that the server
|
||||||
@@ -493,10 +493,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
"""
|
"""
|
||||||
if "ssl_module" not in self.parser.modules:
|
if "ssl_module" not in self.parser.modules:
|
||||||
logger.info("Loading mod_ssl into Apache Server")
|
logger.info("Loading mod_ssl into Apache Server")
|
||||||
if self.config.func.__name__ == "auth":
|
self.enable_mod("ssl", temp=temp)
|
||||||
self.enable_mod("ssl", temp=True)
|
|
||||||
else:
|
|
||||||
self.enable_mod("ssl", temp=False)
|
|
||||||
|
|
||||||
# Check for Listen <port>
|
# Check for Listen <port>
|
||||||
# Note: This could be made to also look for ip:443 combo
|
# Note: This could be made to also look for ip:443 combo
|
||||||
@@ -955,6 +952,9 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
def enable_site(self, vhost):
|
def enable_site(self, vhost):
|
||||||
"""Enables an available site, Apache restart required.
|
"""Enables an available site, Apache restart required.
|
||||||
|
|
||||||
|
.. note:: Does not make sure that the site correctly works or that all
|
||||||
|
modules are enabled appropriately.
|
||||||
|
|
||||||
.. todo:: This function should number subdomains before the domain vhost
|
.. todo:: This function should number subdomains before the domain vhost
|
||||||
.. todo:: Make sure link is not broken...
|
.. todo:: Make sure link is not broken...
|
||||||
|
|
||||||
@@ -968,12 +968,6 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator):
|
|||||||
if self.is_site_enabled(vhost.filep):
|
if self.is_site_enabled(vhost.filep):
|
||||||
return
|
return
|
||||||
|
|
||||||
if vhost.ssl:
|
|
||||||
# TODO: Make this based on addresses
|
|
||||||
self.prepare_server_https("443")
|
|
||||||
if self.save_notes:
|
|
||||||
self.save()
|
|
||||||
|
|
||||||
if "/sites-available/" in vhost.filep:
|
if "/sites-available/" in vhost.filep:
|
||||||
enabled_path = ("%s/sites-enabled/%s" %
|
enabled_path = ("%s/sites-enabled/%s" %
|
||||||
(self.parser.root, os.path.basename(vhost.filep)))
|
(self.parser.root, os.path.basename(vhost.filep)))
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class ApacheDvsni(common.Dvsni):
|
|||||||
|
|
||||||
# Prepare the server for HTTPS
|
# Prepare the server for HTTPS
|
||||||
self.configurator.prepare_server_https(
|
self.configurator.prepare_server_https(
|
||||||
str(self.configurator.config.dvsni_port))
|
str(self.configurator.config.dvsni_port), True)
|
||||||
|
|
||||||
responses = []
|
responses = []
|
||||||
|
|
||||||
|
|||||||
@@ -207,20 +207,11 @@ class TwoVhost80Test(util.ApacheTest):
|
|||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
errors.MisconfigurationError, self.config.enable_mod, "ssl")
|
errors.MisconfigurationError, self.config.enable_mod, "ssl")
|
||||||
|
|
||||||
@mock.patch("letsencrypt.le_util.run_script")
|
def test_enable_site(self):
|
||||||
@mock.patch("letsencrypt.le_util.exe_exists")
|
|
||||||
@mock.patch("letsencrypt_apache.parser.subprocess.Popen")
|
|
||||||
def test_enable_site(self, mock_popen, mock_exe_exists, mock_run_script):
|
|
||||||
mock_popen().returncode = 0
|
|
||||||
mock_popen().communicate.return_value = ("Define: DUMP_RUN_CFG", "")
|
|
||||||
mock_exe_exists.return_value = True
|
|
||||||
|
|
||||||
# Default 443 vhost
|
# Default 443 vhost
|
||||||
self.assertFalse(self.vh_truth[1].enabled)
|
self.assertFalse(self.vh_truth[1].enabled)
|
||||||
self.config.enable_site(self.vh_truth[1])
|
self.config.enable_site(self.vh_truth[1])
|
||||||
self.assertTrue(self.vh_truth[1].enabled)
|
self.assertTrue(self.vh_truth[1].enabled)
|
||||||
# Mod enabled
|
|
||||||
self.assertTrue(mock_run_script.called)
|
|
||||||
|
|
||||||
# Go again to make sure nothing fails
|
# Go again to make sure nothing fails
|
||||||
self.config.enable_site(self.vh_truth[1])
|
self.config.enable_site(self.vh_truth[1])
|
||||||
@@ -316,9 +307,7 @@ class TwoVhost80Test(util.ApacheTest):
|
|||||||
self.config.prepare_server_https("443")
|
self.config.prepare_server_https("443")
|
||||||
self.assertEqual(mock_enable.call_args[1], {"temp": False})
|
self.assertEqual(mock_enable.call_args[1], {"temp": False})
|
||||||
|
|
||||||
# Modifying base func call... to auth
|
self.config.prepare_server_https("8080", temp=True)
|
||||||
self.config.config.func.__name__ = "auth"
|
|
||||||
self.config.prepare_server_https("8080")
|
|
||||||
# Enable mod is temporary
|
# Enable mod is temporary
|
||||||
self.assertEqual(mock_enable.call_args[1], {"temp": True})
|
self.assertEqual(mock_enable.call_args[1], {"temp": True})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user