diff --git a/certbot-apache/certbot_apache/_internal/parser.py b/certbot-apache/certbot_apache/_internal/parser.py index a021d3445..51d94c4f3 100644 --- a/certbot-apache/certbot_apache/_internal/parser.py +++ b/certbot-apache/certbot_apache/_internal/parser.py @@ -677,7 +677,6 @@ class ApacheParser(object): and their values. """ - includes = self.find_dir("Include", start="/files") includes += self.find_dir("IncludeOptional", start="/files") inc_dict = dict() diff --git a/certbot-apache/tests/parser_test.py b/certbot-apache/tests/parser_test.py index f7a6b8f9f..be408ea92 100644 --- a/certbot-apache/tests/parser_test.py +++ b/certbot-apache/tests/parser_test.py @@ -335,6 +335,7 @@ class BasicParserTest(util.ParserTest): assert default_ssl is not None # Need to add this manually as apache2ctl cannot be run for tests self.parser.modules.add("mod_ssl.c") + self.parser.modules.add("mod_somethingcustom.c") blocks = self.parser.find_blocks_from_include_tree("ifmodule", default_ssl.path) self.assertEqual(len(blocks), 2) @@ -349,6 +350,20 @@ class BasicParserTest(util.ParserTest): default_ssl.path) self.assertEqual(notfound, []) + def test_if_specific_ancestor_conditional(self): + default_ssl = None + for vh in self.config.vhosts: + if vh.path.endswith("default-ssl.conf/IfModule/VirtualHost"): + default_ssl = vh + break + assert default_ssl is not None + # Need to add this manually as apache2ctl cannot be run for tests + self.parser.modules.add("mod_ssl.c") + self.parser.modules.add("mod_somethingcustom.c") + blocks = self.parser.find_blocks_from_include_tree("ifmodule", + default_ssl.path) + self.assertEqual('mod_somethingcustom.c', self.parser.get_arg(blocks[1]+"/arg[1]")) + class ParserInitTest(util.ApacheTest): def setUp(self): # pylint: disable=arguments-differ diff --git a/certbot-apache/tests/testdata/debian_apache_2_4/multiple_vhosts/apache2/apache2.conf b/certbot-apache/tests/testdata/debian_apache_2_4/multiple_vhosts/apache2/apache2.conf index 598857ac8..963c3ade4 100644 --- a/certbot-apache/tests/testdata/debian_apache_2_4/multiple_vhosts/apache2/apache2.conf +++ b/certbot-apache/tests/testdata/debian_apache_2_4/multiple_vhosts/apache2/apache2.conf @@ -205,7 +205,7 @@ IncludeOptional sites-enabled/*.conf # Custom re-include of a single file to test multiple ancestor searches - + IncludeOptional sites-enabled/default-ssl.conf