Add a test using the returned ancestor paths

This commit is contained in:
Joona Hoikkala 2020-01-29 19:14:54 +02:00
parent e4524e6fec
commit 8b22ce9b8e
No known key found for this signature in database
GPG key ID: D5AA86BBF9B29A5C
3 changed files with 16 additions and 2 deletions

View file

@ -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()

View file

@ -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

View file

@ -205,7 +205,7 @@ IncludeOptional sites-enabled/*.conf
</VirtualHost>
# Custom re-include of a single file to test multiple ancestor searches
<IfModule mod_ssl.c>
<IfModule mod_somethingcustom.c>
IncludeOptional sites-enabled/default-ssl.conf
</IfModule>