From 4c001ad46632eb98e184f3bf9e3b015e346cf2de Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Tue, 16 Jan 2018 20:39:17 -0800 Subject: [PATCH] check for Include in vhost --- .../certbot_apache/tests/http_01_test.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/certbot-apache/certbot_apache/tests/http_01_test.py b/certbot-apache/certbot_apache/tests/http_01_test.py index b0913b0a5..c68cfc728 100644 --- a/certbot-apache/certbot_apache/tests/http_01_test.py +++ b/certbot-apache/certbot_apache/tests/http_01_test.py @@ -22,8 +22,9 @@ class ApacheHttp01TestMeta(type): def _gen_test(num_achalls, minor_version): def _test(self): achalls = self.achalls[:num_achalls] + vhosts = self.vhosts[:num_achalls] self.config.version = (2, minor_version) - self.common_perform_test(achalls) + self.common_perform_test(achalls, vhosts) return _test for i in range(1, NUM_ACHALLS + 1): @@ -43,6 +44,7 @@ class ApacheHttp01Test(util.ApacheTest): self.account_key = self.rsa512jwk self.achalls = [] + self.vhosts = [] vhost_index = 0 for i in range(NUM_ACHALLS): domain = None @@ -54,6 +56,7 @@ class ApacheHttp01Test(util.ApacheTest): elif vhost.aliases: domain = next(iter(vhost.aliases)) if domain: + self.vhosts.append(vhost) vhost_index = j + 1 break else: # pragma: no cover @@ -113,7 +116,7 @@ class ApacheHttp01Test(util.ApacheTest): self.assertNotEqual(calls, other_calls) return other_calls - def common_perform_test(self, achalls): + def common_perform_test(self, achalls, vhosts): """Tests perform with the given achalls.""" challenge_dir = self.http.challenge_dir self.assertFalse(os.path.exists(challenge_dir)) @@ -131,13 +134,15 @@ class ApacheHttp01Test(util.ApacheTest): for achall in achalls: self._test_challenge_file(achall) + for vhost in vhosts): + matches = self.config.parser.find_dir("Include", + self.http.challenge_conf, + vhost.path) + self.assertEqual(len(matches), 1) + self.assertTrue(os.path.exists(challenge_dir)) def _test_challenge_conf(self): - self.assertEqual( - len(self.config.parser.find_dir( - "Include", self.http.challenge_conf)), 1) - with open(self.http.challenge_conf) as f: conf_contents = f.read()