From 80ce6e29426d56f1ccbcd53ebd383a9b77614a7c Mon Sep 17 00:00:00 2001 From: Noah Swartz Date: Tue, 26 Jan 2016 13:42:56 -0800 Subject: [PATCH 01/13] initial servername write test --- .../letsencrypt_apache/configurator.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/letsencrypt-apache/letsencrypt_apache/configurator.py b/letsencrypt-apache/letsencrypt_apache/configurator.py index 8818923f4..9869c9029 100644 --- a/letsencrypt-apache/letsencrypt_apache/configurator.py +++ b/letsencrypt-apache/letsencrypt_apache/configurator.py @@ -298,12 +298,12 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): return self.assoc[target_name] # Try to find a reasonable vhost - vhost = self._find_best_vhost(target_name) + vhost, is_generic_host = self._find_best_vhost(target_name) if vhost is not None: if temp: return vhost if not vhost.ssl: - vhost = self.make_vhost_ssl(vhost) + vhost = self.make_vhost_ssl(vhost, is_generic_host, target_name) self.assoc[target_name] = vhost return vhost @@ -353,6 +353,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): # Points 1 - Address name with no SSL best_candidate = None best_points = 0 + is_generic_host = False for vhost in self.vhosts: if vhost.modmacro is True: @@ -364,6 +365,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): else: # No points given if names can't be found. # This gets hit but doesn't register + is_generic_host = True continue # pragma: no cover if vhost.ssl: @@ -383,7 +385,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): if len(reasonable_vhosts) == 1: best_candidate = reasonable_vhosts[0] - return best_candidate + return (best_candidate, is_generic_host) def _non_default_vhosts(self): """Return all non _default_ only vhosts.""" @@ -666,7 +668,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): "based virtual host", addr) self.add_name_vhost(addr) - def make_vhost_ssl(self, nonssl_vhost): # pylint: disable=too-many-locals + def make_vhost_ssl(self, nonssl_vhost, is_generic_host=False, target_name=None): # pylint: disable=too-many-locals """Makes an ssl_vhost version of a nonssl_vhost. Duplicates vhost and adds default ssl options @@ -692,7 +694,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): # Reload augeas to take into account the new vhost self.aug.load() - + #TODO: add line to write vhost name # Get Vhost augeas path for new vhost vh_p = self.aug.match("/files%s//* [label()=~regexp('%s')]" % (ssl_fp, parser.case_i("VirtualHost"))) @@ -709,6 +711,8 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): # Add directives self._add_dummy_ssl_directives(vh_p) + if is_generic_host: + self._add_servername(target_name, vh_p) # Log actions and create save notes logger.info("Created an SSL vhost at %s", ssl_fp) @@ -859,6 +863,10 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): "insert_key_file_path") self.parser.add_dir(vh_path, "Include", self.mod_ssl_conf) + def _add_servername(self, servername, vh_path): + self.parser.add_dir(vh_path, "ServerName", servername) + self.parser.add_dir(vh_path, "ServerAlias", servername) + def _add_name_vhost_if_necessary(self, vhost): """Add NameVirtualHost Directives if necessary for new vhost. From 4bae5b432ce82eb5f2859a0b04cb2e9a50f97fcd Mon Sep 17 00:00:00 2001 From: Noah Swartz Date: Tue, 26 Jan 2016 13:53:43 -0800 Subject: [PATCH 02/13] fix tests --- .../letsencrypt_apache/tests/configurator_test.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py b/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py index 00a98e33a..002520a05 100644 --- a/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py +++ b/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py @@ -188,12 +188,12 @@ class TwoVhost80Test(util.ApacheTest): def test_find_best_vhost(self): # pylint: disable=protected-access self.assertEqual( - self.vh_truth[3], self.config._find_best_vhost("letsencrypt.demo")) + (self.vh_truth[3], True), self.config._find_best_vhost("letsencrypt.demo")) self.assertEqual( - self.vh_truth[0], + (self.vh_truth[0], True), self.config._find_best_vhost("encryption-example.demo")) - self.assertTrue( - self.config._find_best_vhost("does-not-exist.com") is None) + self.assertEqual( + self.config._find_best_vhost("does-not-exist.com"), (None, True)) def test_find_best_vhost_variety(self): # pylint: disable=protected-access @@ -202,7 +202,7 @@ class TwoVhost80Test(util.ApacheTest): obj.Addr(("zombo.com",))]), True, False) self.config.vhosts.append(ssl_vh) - self.assertEqual(self.config._find_best_vhost("zombo.com"), ssl_vh) + self.assertEqual(self.config._find_best_vhost("zombo.com"), (ssl_vh, True)) def test_find_best_vhost_default(self): # pylint: disable=protected-access @@ -213,7 +213,7 @@ class TwoVhost80Test(util.ApacheTest): ] self.assertEqual( - self.config._find_best_vhost("example.demo"), self.vh_truth[2]) + self.config._find_best_vhost("example.demo"), (self.vh_truth[2], True)) def test_non_default_vhosts(self): # pylint: disable=protected-access From ff98ae3f2270dcca3426f6f14892ebad146f5c75 Mon Sep 17 00:00:00 2001 From: Noah Swartz Date: Thu, 28 Jan 2016 13:25:10 -0800 Subject: [PATCH 03/13] remove is_generic always write target_name --- .../letsencrypt_apache/configurator.py | 25 +++++++++---------- .../tests/configurator_test.py | 10 ++++---- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/letsencrypt-apache/letsencrypt_apache/configurator.py b/letsencrypt-apache/letsencrypt_apache/configurator.py index 9869c9029..7d603cfb5 100644 --- a/letsencrypt-apache/letsencrypt_apache/configurator.py +++ b/letsencrypt-apache/letsencrypt_apache/configurator.py @@ -298,12 +298,12 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): return self.assoc[target_name] # Try to find a reasonable vhost - vhost, is_generic_host = self._find_best_vhost(target_name) + vhost = self._find_best_vhost(target_name) if vhost is not None: if temp: return vhost if not vhost.ssl: - vhost = self.make_vhost_ssl(vhost, is_generic_host, target_name) + vhost = self.make_vhost_ssl(vhost, target_name) self.assoc[target_name] = vhost return vhost @@ -326,7 +326,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): # TODO: Conflicts is too conservative if not any(vhost.enabled and vhost.conflicts(addrs) for vhost in self.vhosts): - vhost = self.make_vhost_ssl(vhost) + vhost = self.make_vhost_ssl(vhost, target_name) else: logger.error( "The selected vhost would conflict with other HTTPS " @@ -353,8 +353,6 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): # Points 1 - Address name with no SSL best_candidate = None best_points = 0 - is_generic_host = False - for vhost in self.vhosts: if vhost.modmacro is True: continue @@ -365,7 +363,6 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): else: # No points given if names can't be found. # This gets hit but doesn't register - is_generic_host = True continue # pragma: no cover if vhost.ssl: @@ -385,7 +382,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): if len(reasonable_vhosts) == 1: best_candidate = reasonable_vhosts[0] - return (best_candidate, is_generic_host) + return (best_candidate) def _non_default_vhosts(self): """Return all non _default_ only vhosts.""" @@ -668,7 +665,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): "based virtual host", addr) self.add_name_vhost(addr) - def make_vhost_ssl(self, nonssl_vhost, is_generic_host=False, target_name=None): # pylint: disable=too-many-locals + def make_vhost_ssl(self, nonssl_vhost, target_name=None): # pylint: disable=too-many-locals """Makes an ssl_vhost version of a nonssl_vhost. Duplicates vhost and adds default ssl options @@ -711,8 +708,8 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): # Add directives self._add_dummy_ssl_directives(vh_p) - if is_generic_host: - self._add_servername(target_name, vh_p) + if target_name: + self._add_servername_alias(target_name, vh_p) # Log actions and create save notes logger.info("Created an SSL vhost at %s", ssl_fp) @@ -863,9 +860,11 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): "insert_key_file_path") self.parser.add_dir(vh_path, "Include", self.mod_ssl_conf) - def _add_servername(self, servername, vh_path): - self.parser.add_dir(vh_path, "ServerName", servername) - self.parser.add_dir(vh_path, "ServerAlias", servername) + def _add_servername_alias(self, target_name, vh_path): + if not self.parser.find_dir("ServerName", None, start=vh_path, exclude=False): + self.parser.add_dir(vh_path, "ServerName", target_name) + else: + self.parser.add_dir(vh_path, "ServerAlias", target_name) def _add_name_vhost_if_necessary(self, vhost): """Add NameVirtualHost Directives if necessary for new vhost. diff --git a/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py b/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py index 002520a05..887dcfe02 100644 --- a/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py +++ b/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py @@ -188,12 +188,12 @@ class TwoVhost80Test(util.ApacheTest): def test_find_best_vhost(self): # pylint: disable=protected-access self.assertEqual( - (self.vh_truth[3], True), self.config._find_best_vhost("letsencrypt.demo")) + self.vh_truth[3], self.config._find_best_vhost("letsencrypt.demo")) self.assertEqual( - (self.vh_truth[0], True), + self.vh_truth[0], self.config._find_best_vhost("encryption-example.demo")) self.assertEqual( - self.config._find_best_vhost("does-not-exist.com"), (None, True)) + self.config._find_best_vhost("does-not-exist.com"), None) def test_find_best_vhost_variety(self): # pylint: disable=protected-access @@ -202,7 +202,7 @@ class TwoVhost80Test(util.ApacheTest): obj.Addr(("zombo.com",))]), True, False) self.config.vhosts.append(ssl_vh) - self.assertEqual(self.config._find_best_vhost("zombo.com"), (ssl_vh, True)) + self.assertEqual(self.config._find_best_vhost("zombo.com"), ssl_vh) def test_find_best_vhost_default(self): # pylint: disable=protected-access @@ -213,7 +213,7 @@ class TwoVhost80Test(util.ApacheTest): ] self.assertEqual( - self.config._find_best_vhost("example.demo"), (self.vh_truth[2], True)) + self.config._find_best_vhost("example.demo"), self.vh_truth[2]) def test_non_default_vhosts(self): # pylint: disable=protected-access From e7507e535472021f38d76dd21f63048c8e8d1dd9 Mon Sep 17 00:00:00 2001 From: Noah Swartz Date: Thu, 28 Jan 2016 14:53:47 -0800 Subject: [PATCH 04/13] don't double write servers --- letsencrypt-apache/letsencrypt_apache/configurator.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/letsencrypt-apache/letsencrypt_apache/configurator.py b/letsencrypt-apache/letsencrypt_apache/configurator.py index 7d603cfb5..1abcf5b29 100644 --- a/letsencrypt-apache/letsencrypt_apache/configurator.py +++ b/letsencrypt-apache/letsencrypt_apache/configurator.py @@ -382,7 +382,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): if len(reasonable_vhosts) == 1: best_candidate = reasonable_vhosts[0] - return (best_candidate) + return best_candidate def _non_default_vhosts(self): """Return all non _default_ only vhosts.""" @@ -861,6 +861,9 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): self.parser.add_dir(vh_path, "Include", self.mod_ssl_conf) def _add_servername_alias(self, target_name, vh_path): + if (self.parser.find_dir("ServerName", target_name, start=vh_path, exclude=False) + or self.parser.find_dir("ServerAlias", target_name, start=vh_path, exclude=False)): + return if not self.parser.find_dir("ServerName", None, start=vh_path, exclude=False): self.parser.add_dir(vh_path, "ServerName", target_name) else: From 1417dc43cd8d39bb5773c123a27dfd42341946bd Mon Sep 17 00:00:00 2001 From: Noah Swartz Date: Thu, 28 Jan 2016 15:38:14 -0800 Subject: [PATCH 05/13] save ssl directives --- letsencrypt-apache/letsencrypt_apache/configurator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/letsencrypt-apache/letsencrypt_apache/configurator.py b/letsencrypt-apache/letsencrypt_apache/configurator.py index 1abcf5b29..cd41a02cf 100644 --- a/letsencrypt-apache/letsencrypt_apache/configurator.py +++ b/letsencrypt-apache/letsencrypt_apache/configurator.py @@ -708,6 +708,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): # Add directives self._add_dummy_ssl_directives(vh_p) + self.save("don't lose ssl directives", True) if target_name: self._add_servername_alias(target_name, vh_p) @@ -863,7 +864,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): def _add_servername_alias(self, target_name, vh_path): if (self.parser.find_dir("ServerName", target_name, start=vh_path, exclude=False) or self.parser.find_dir("ServerAlias", target_name, start=vh_path, exclude=False)): - return + return if not self.parser.find_dir("ServerName", None, start=vh_path, exclude=False): self.parser.add_dir(vh_path, "ServerName", target_name) else: From 3e5b89daa5a7cfe928eb48ce1a2d08030dab6ee7 Mon Sep 17 00:00:00 2001 From: Noah Swartz Date: Thu, 28 Jan 2016 15:54:02 -0800 Subject: [PATCH 06/13] remove save params --- letsencrypt-apache/letsencrypt_apache/configurator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/letsencrypt-apache/letsencrypt_apache/configurator.py b/letsencrypt-apache/letsencrypt_apache/configurator.py index cd41a02cf..31281681c 100644 --- a/letsencrypt-apache/letsencrypt_apache/configurator.py +++ b/letsencrypt-apache/letsencrypt_apache/configurator.py @@ -708,7 +708,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): # Add directives self._add_dummy_ssl_directives(vh_p) - self.save("don't lose ssl directives", True) + self.save() if target_name: self._add_servername_alias(target_name, vh_p) From 69ac8c6cfa84a68eece92c0da235f0f68253478b Mon Sep 17 00:00:00 2001 From: Noah Swartz Date: Thu, 28 Jan 2016 16:24:56 -0800 Subject: [PATCH 07/13] add servername/alias for all vhosts --- .../letsencrypt_apache/configurator.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/letsencrypt-apache/letsencrypt_apache/configurator.py b/letsencrypt-apache/letsencrypt_apache/configurator.py index 31281681c..67260a235 100644 --- a/letsencrypt-apache/letsencrypt_apache/configurator.py +++ b/letsencrypt-apache/letsencrypt_apache/configurator.py @@ -303,8 +303,9 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): if temp: return vhost if not vhost.ssl: - vhost = self.make_vhost_ssl(vhost, target_name) + vhost = self.make_vhost_ssl(vhost) + self._add_servername_alias(target_name, vhost) self.assoc[target_name] = vhost return vhost @@ -326,7 +327,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): # TODO: Conflicts is too conservative if not any(vhost.enabled and vhost.conflicts(addrs) for vhost in self.vhosts): - vhost = self.make_vhost_ssl(vhost, target_name) + vhost = self.make_vhost_ssl(vhost) else: logger.error( "The selected vhost would conflict with other HTTPS " @@ -335,6 +336,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): raise errors.PluginError( "VirtualHost not able to be selected.") + self._add_servername_alias(target_name, vhost) self.assoc[target_name] = vhost return vhost @@ -665,7 +667,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): "based virtual host", addr) self.add_name_vhost(addr) - def make_vhost_ssl(self, nonssl_vhost, target_name=None): # pylint: disable=too-many-locals + def make_vhost_ssl(self, nonssl_vhost): # pylint: disable=too-many-locals """Makes an ssl_vhost version of a nonssl_vhost. Duplicates vhost and adds default ssl options @@ -709,8 +711,6 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): # Add directives self._add_dummy_ssl_directives(vh_p) self.save() - if target_name: - self._add_servername_alias(target_name, vh_p) # Log actions and create save notes logger.info("Created an SSL vhost at %s", ssl_fp) @@ -861,7 +861,11 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): "insert_key_file_path") self.parser.add_dir(vh_path, "Include", self.mod_ssl_conf) - def _add_servername_alias(self, target_name, vh_path): + def _add_servername_alias(self, target_name, vhost): + fp = vhost.filep + vh_p = self.aug.match("/files%s//* [label()=~regexp('%s')]" % + (ssl_fp, parser.case_i("VirtualHost"))) + vh_path = vh_p[0] if (self.parser.find_dir("ServerName", target_name, start=vh_path, exclude=False) or self.parser.find_dir("ServerAlias", target_name, start=vh_path, exclude=False)): return From 5f50d698eee1a29142938a357683b19bc7f883b1 Mon Sep 17 00:00:00 2001 From: Noah Swartz Date: Thu, 28 Jan 2016 16:26:44 -0800 Subject: [PATCH 08/13] fix var name --- letsencrypt-apache/letsencrypt_apache/configurator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/letsencrypt-apache/letsencrypt_apache/configurator.py b/letsencrypt-apache/letsencrypt_apache/configurator.py index 67260a235..7575e0cbb 100644 --- a/letsencrypt-apache/letsencrypt_apache/configurator.py +++ b/letsencrypt-apache/letsencrypt_apache/configurator.py @@ -864,7 +864,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): def _add_servername_alias(self, target_name, vhost): fp = vhost.filep vh_p = self.aug.match("/files%s//* [label()=~regexp('%s')]" % - (ssl_fp, parser.case_i("VirtualHost"))) + (fp, parser.case_i("VirtualHost"))) vh_path = vh_p[0] if (self.parser.find_dir("ServerName", target_name, start=vh_path, exclude=False) or self.parser.find_dir("ServerAlias", target_name, start=vh_path, exclude=False)): From b7c94bb297dd47e11122fda94b75724bd3bd95ed Mon Sep 17 00:00:00 2001 From: Noah Swartz Date: Thu, 28 Jan 2016 16:48:12 -0800 Subject: [PATCH 09/13] don't continue if there's no vhost --- letsencrypt-apache/letsencrypt_apache/configurator.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/letsencrypt-apache/letsencrypt_apache/configurator.py b/letsencrypt-apache/letsencrypt_apache/configurator.py index 7575e0cbb..cf465e32f 100644 --- a/letsencrypt-apache/letsencrypt_apache/configurator.py +++ b/letsencrypt-apache/letsencrypt_apache/configurator.py @@ -865,6 +865,8 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): fp = vhost.filep vh_p = self.aug.match("/files%s//* [label()=~regexp('%s')]" % (fp, parser.case_i("VirtualHost"))) + if not vh_p: + return vh_path = vh_p[0] if (self.parser.find_dir("ServerName", target_name, start=vh_path, exclude=False) or self.parser.find_dir("ServerAlias", target_name, start=vh_path, exclude=False)): From a6d0410f4e0a7d689338ad4fcc23b77942400aef Mon Sep 17 00:00:00 2001 From: Noah Swartz Date: Fri, 29 Jan 2016 15:30:23 -0800 Subject: [PATCH 10/13] remove old TODO --- letsencrypt-apache/letsencrypt_apache/configurator.py | 1 - 1 file changed, 1 deletion(-) diff --git a/letsencrypt-apache/letsencrypt_apache/configurator.py b/letsencrypt-apache/letsencrypt_apache/configurator.py index cf465e32f..e3b8546a9 100644 --- a/letsencrypt-apache/letsencrypt_apache/configurator.py +++ b/letsencrypt-apache/letsencrypt_apache/configurator.py @@ -693,7 +693,6 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): # Reload augeas to take into account the new vhost self.aug.load() - #TODO: add line to write vhost name # Get Vhost augeas path for new vhost vh_p = self.aug.match("/files%s//* [label()=~regexp('%s')]" % (ssl_fp, parser.case_i("VirtualHost"))) From 7215376ff92907e6e879bd9d2f56070d93fa07b5 Mon Sep 17 00:00:00 2001 From: Noah Swartz Date: Fri, 29 Jan 2016 16:09:19 -0800 Subject: [PATCH 11/13] update server list with added names --- letsencrypt-apache/letsencrypt_apache/configurator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/letsencrypt-apache/letsencrypt_apache/configurator.py b/letsencrypt-apache/letsencrypt_apache/configurator.py index e3b8546a9..bae3da232 100644 --- a/letsencrypt-apache/letsencrypt_apache/configurator.py +++ b/letsencrypt-apache/letsencrypt_apache/configurator.py @@ -874,6 +874,7 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): self.parser.add_dir(vh_path, "ServerName", target_name) else: self.parser.add_dir(vh_path, "ServerAlias", target_name) + self._add_servernames(vhost) def _add_name_vhost_if_necessary(self, vhost): """Add NameVirtualHost Directives if necessary for new vhost. From 7d63a0c8df5b6ef43cf2d50402af4d9f98f4abfd Mon Sep 17 00:00:00 2001 From: Noah Swartz Date: Fri, 29 Jan 2016 16:44:22 -0800 Subject: [PATCH 12/13] fix stupid broken tests --- .../letsencrypt_apache/tests/configurator_test.py | 2 +- letsencrypt-apache/letsencrypt_apache/tests/util.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py b/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py index 887dcfe02..d4f770248 100644 --- a/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py +++ b/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py @@ -162,7 +162,7 @@ class TwoVhost80Test(util.ApacheTest): mock_select.return_value = self.vh_truth[0] chosen_vhost = self.config.choose_vhost("none.com") self.assertEqual( - self.vh_truth[0].get_names(), chosen_vhost.get_names()) + self.vh_truth[6].get_names(), chosen_vhost.get_names()) # Make sure we go from HTTP -> HTTPS self.assertFalse(self.vh_truth[0].ssl) diff --git a/letsencrypt-apache/letsencrypt_apache/tests/util.py b/letsencrypt-apache/letsencrypt_apache/tests/util.py index fb86d2320..169f1b379 100644 --- a/letsencrypt-apache/letsencrypt_apache/tests/util.py +++ b/letsencrypt-apache/letsencrypt_apache/tests/util.py @@ -151,7 +151,13 @@ def get_vh_truth(temp_dir, config_name): os.path.join(aug_pre, ("default-ssl-port-only.conf/" "IfModule/VirtualHost")), set([obj.Addr.fromstring("_default_:443")]), True, False), + obj.VirtualHost( + os.path.join(prefix, "encryption-example.conf"), + os.path.join(aug_pre, "encryption-example.conf/VirtualHost"), + set([obj.Addr.fromstring("*:80")]), + False, True, "encryption-example.demo") ] + vh_truth[6].aliases.add("none.com") return vh_truth return None # pragma: no cover From 36e2c9a9927c2047f7ce95115474433ca93ff3ca Mon Sep 17 00:00:00 2001 From: Noah Swartz Date: Fri, 29 Jan 2016 17:11:05 -0800 Subject: [PATCH 13/13] remove test hackery --- .../letsencrypt_apache/tests/configurator_test.py | 3 ++- letsencrypt-apache/letsencrypt_apache/tests/util.py | 8 +------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py b/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py index d4f770248..8aa933d6a 100644 --- a/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py +++ b/letsencrypt-apache/letsencrypt_apache/tests/configurator_test.py @@ -161,8 +161,9 @@ class TwoVhost80Test(util.ApacheTest): def test_choose_vhost_select_vhost_non_ssl(self, mock_select): mock_select.return_value = self.vh_truth[0] chosen_vhost = self.config.choose_vhost("none.com") + self.vh_truth[0].aliases.add("none.com") self.assertEqual( - self.vh_truth[6].get_names(), chosen_vhost.get_names()) + self.vh_truth[0].get_names(), chosen_vhost.get_names()) # Make sure we go from HTTP -> HTTPS self.assertFalse(self.vh_truth[0].ssl) diff --git a/letsencrypt-apache/letsencrypt_apache/tests/util.py b/letsencrypt-apache/letsencrypt_apache/tests/util.py index 169f1b379..47d4278f8 100644 --- a/letsencrypt-apache/letsencrypt_apache/tests/util.py +++ b/letsencrypt-apache/letsencrypt_apache/tests/util.py @@ -150,14 +150,8 @@ def get_vh_truth(temp_dir, config_name): os.path.join(prefix, "default-ssl-port-only.conf"), os.path.join(aug_pre, ("default-ssl-port-only.conf/" "IfModule/VirtualHost")), - set([obj.Addr.fromstring("_default_:443")]), True, False), - obj.VirtualHost( - os.path.join(prefix, "encryption-example.conf"), - os.path.join(aug_pre, "encryption-example.conf/VirtualHost"), - set([obj.Addr.fromstring("*:80")]), - False, True, "encryption-example.demo") + set([obj.Addr.fromstring("_default_:443")]), True, False) ] - vh_truth[6].aliases.add("none.com") return vh_truth return None # pragma: no cover