diff --git a/letsencrypt-apache/letsencrypt_apache/configurator.py b/letsencrypt-apache/letsencrypt_apache/configurator.py index 87687e38d..01c9d4f30 100644 --- a/letsencrypt-apache/letsencrypt_apache/configurator.py +++ b/letsencrypt-apache/letsencrypt_apache/configurator.py @@ -482,7 +482,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): logger.debug(msg) self.save_notes += msg - def prepare_server_https(self, port): + def prepare_server_https(self, port, temp=False): """Prepare the server for HTTPS. 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: logger.info("Loading mod_ssl into Apache Server") - if self.config.func.__name__ == "auth": - self.enable_mod("ssl", temp=True) - else: - self.enable_mod("ssl", temp=False) + self.enable_mod("ssl", temp=temp) # Check for Listen # 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): """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:: Make sure link is not broken... @@ -968,12 +968,6 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): if self.is_site_enabled(vhost.filep): 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: enabled_path = ("%s/sites-enabled/%s" % (self.parser.root, os.path.basename(vhost.filep))) diff --git a/letsencrypt-apache/letsencrypt_apache/dvsni.py b/letsencrypt-apache/letsencrypt_apache/dvsni.py index b05156c5d..c6c41dc51 100644 --- a/letsencrypt-apache/letsencrypt_apache/dvsni.py +++ b/letsencrypt-apache/letsencrypt_apache/dvsni.py @@ -62,7 +62,7 @@ class ApacheDvsni(common.Dvsni): # Prepare the server for HTTPS self.configurator.prepare_server_https( - str(self.configurator.config.dvsni_port)) + str(self.configurator.config.dvsni_port), True) responses = [] diff --git a/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py b/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py index 4a5cd4500..71599bd1d 100644 --- a/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py +++ b/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py @@ -207,20 +207,11 @@ class TwoVhost80Test(util.ApacheTest): self.assertRaises( errors.MisconfigurationError, self.config.enable_mod, "ssl") - @mock.patch("letsencrypt.le_util.run_script") - @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 - + def test_enable_site(self): # Default 443 vhost self.assertFalse(self.vh_truth[1].enabled) self.config.enable_site(self.vh_truth[1]) self.assertTrue(self.vh_truth[1].enabled) - # Mod enabled - self.assertTrue(mock_run_script.called) # Go again to make sure nothing fails self.config.enable_site(self.vh_truth[1]) @@ -316,9 +307,7 @@ class TwoVhost80Test(util.ApacheTest): self.config.prepare_server_https("443") self.assertEqual(mock_enable.call_args[1], {"temp": False}) - # Modifying base func call... to auth - self.config.config.func.__name__ = "auth" - self.config.prepare_server_https("8080") + self.config.prepare_server_https("8080", temp=True) # Enable mod is temporary self.assertEqual(mock_enable.call_args[1], {"temp": True})