Skip to content

Commit

Permalink
Merge db0749d into dc91357
Browse files Browse the repository at this point in the history
  • Loading branch information
joohoi committed Jul 30, 2018
2 parents dc91357 + db0749d commit 3a824de
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions certbot-apache/certbot_apache/http_01.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,10 @@ def _set_up_include_directives(self, vhost):
self.configurator.parser.add_dir(
vhost.path, "Include", self.challenge_conf_post)

if not vhost.enabled:
from certbot_apache.parser import get_aug_path
self.configurator.parser.add_dir(
get_aug_path(self.configurator.parser.loc["default"]),
"Include", vhost.filep)

self.moded_vhosts.add(vhost)
17 changes: 17 additions & 0 deletions certbot-apache/certbot_apache/tests/http_01_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from certbot import errors

from certbot.tests import acme_util
from certbot_apache.parser import get_aug_path
from certbot_apache.tests import util


Expand Down Expand Up @@ -134,6 +135,17 @@ def test_perform_3_achall_apache_2_2(self):
def test_perform_3_achall_apache_2_4(self):
self.combinations_perform_test(num_achalls=3, minor_version=4)

def test_activate_disabled_vhost(self):
vhosts = [v for v in self.config.vhosts if v.name == "certbot.demo"]
achalls = [
achallenges.KeyAuthorizationAnnotatedChallenge(
challb=acme_util.chall_to_challb(
challenges.HTTP01(token=((b'a' * 16))),
"pending"),
domain="certbot.demo", account_key=self.account_key)]
vhosts[0].enabled = False
self.common_perform_test(achalls, vhosts)

def combinations_perform_test(self, num_achalls, minor_version):
"""Test perform with the given achall count and Apache version."""
achalls = self.achalls[:num_achalls]
Expand Down Expand Up @@ -169,6 +181,11 @@ def common_perform_test(self, achalls, vhosts):
self.http.challenge_conf_post,
vhost.path)
self.assertEqual(len(matches), 1)
if not vhost.enabled:
matches = self.config.parser.find_dir(
"Include", vhost.filep,
get_aug_path(self.config.parser.loc["default"]))
self.assertEqual(len(matches), 1)

self.assertTrue(os.path.exists(challenge_dir))

Expand Down

0 comments on commit 3a824de

Please sign in to comment.