Esempio n. 1
0
def test_splits():
    httpd1 = _HttpdConf(
        context_wrap(HTTPD_CONF_MAIN_1, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = _HttpdConf(
        context_wrap(HTTPD_CONF_FILE_1, path='/etc/httpd/conf.d/00-a.conf'))
    httpd3 = _HttpdConf(
        context_wrap(HTTPD_CONF_FILE_2, path='/etc/httpd/conf.d/01-b.conf'))
    result = HttpdConfTree([httpd1, httpd2, httpd3])

    server_root = result['ServerRoot'][last]
    assert server_root.value == '/home/skontar/www'
    assert server_root.line == 'ServerRoot "/home/skontar/www"'
    assert server_root.file_name == '01-b.conf'
    assert server_root.file_path == '/etc/httpd/conf.d/01-b.conf'

    listen = result["Listen"][last]
    assert listen.value == 8080
    assert listen.line == 'Listen 8080'
    assert listen.file_name == '00-a.conf'
    assert listen.file_path == '/etc/httpd/conf.d/00-a.conf'

    httpd1 = _HttpdConf(
        context_wrap(HTTPD_CONF_MAIN_2, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = _HttpdConf(
        context_wrap(HTTPD_CONF_FILE_1, path='/etc/httpd/conf.d/00-a.conf'))
    httpd3 = _HttpdConf(
        context_wrap(HTTPD_CONF_FILE_2, path='/etc/httpd/conf.d/01-b.conf'))
    result = HttpdConfTree([httpd1, httpd2, httpd3])

    server_root = result['ServerRoot'][last]
    assert server_root.value == '/etc/httpd'
    assert server_root.line == 'ServerRoot "/etc/httpd"'
    assert server_root.file_name == 'httpd.conf'
    assert server_root.file_path == '/etc/httpd/conf/httpd.conf'

    listen = result["Listen"][last]
    assert listen.value == 80
    assert listen.line == 'Listen 80'
    assert listen.file_name == 'httpd.conf'
    assert listen.file_path == '/etc/httpd/conf/httpd.conf'

    httpd1 = _HttpdConf(
        context_wrap(HTTPD_CONF_MAIN_3, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = _HttpdConf(
        context_wrap(HTTPD_CONF_FILE_1, path='/etc/httpd/conf.d/00-a.conf'))
    httpd3 = _HttpdConf(
        context_wrap(HTTPD_CONF_FILE_2, path='/etc/httpd/conf.d/01-b.conf'))
    result = HttpdConfTree([httpd1, httpd2, httpd3])

    server_root = result['ServerRoot'][last]
    assert server_root.value == '/home/skontar/www'
    assert server_root.line == 'ServerRoot "/home/skontar/www"'
    assert server_root.file_name == '01-b.conf'
    assert server_root.file_path == '/etc/httpd/conf.d/01-b.conf'
    assert listen.value == 80
    assert listen.line == 'Listen 80'
    assert listen.file_name == 'httpd.conf'
    assert listen.file_path == '/etc/httpd/conf/httpd.conf'
Esempio n. 2
0
def test_directives_and_sections():
    httpd1 = _HttpdConf(
        context_wrap(HTTPD_CONF_NEST_1, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = _HttpdConf(
        context_wrap(HTTPD_CONF_NEST_3, path='/etc/httpd/conf.d/00-a.conf'))
    httpd3 = _HttpdConf(
        context_wrap(HTTPD_CONF_NEST_4, path='/etc/httpd/conf.d/01-b.conf'))
    result = HttpdConfTree([httpd1, httpd2, httpd3])
    assert len(result.directives) == 3
    assert len(result.sections) == 7
    assert len(result.find_all(startswith("Dir")).directives) == 1
    assert len(result.find_all(startswith("Dir")).sections) == 1
def test_splits():
    httpd1 = _HttpdConf(context_wrap(HTTPD_CONF_MAIN_1, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = _HttpdConf(context_wrap(HTTPD_CONF_FILE_1, path='/etc/httpd/conf.d/00-a.conf'))
    httpd3 = _HttpdConf(context_wrap(HTTPD_CONF_FILE_2, path='/etc/httpd/conf.d/01-b.conf'))
    result = HttpdConfTree([httpd1, httpd2, httpd3])

    server_root = result['ServerRoot'][-1]
    assert server_root.value == '/home/skontar/www'
    assert server_root.line == 'ServerRoot "/home/skontar/www"'
    assert server_root.file_name == '01-b.conf'
    assert server_root.file_path == '/etc/httpd/conf.d/01-b.conf'

    listen = result["Listen"][-1]
    assert listen.value == 8080
    assert listen.line == 'Listen 8080'
    assert listen.file_name == '00-a.conf'
    assert listen.file_path == '/etc/httpd/conf.d/00-a.conf'

    ssl_proto = result['SSLProtocol'][-1]
    assert ssl_proto.attrs == ["-ALL", "+TLSv1.2", "#", "SSLv3"]

    httpd1 = _HttpdConf(context_wrap(HTTPD_CONF_MAIN_2, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = _HttpdConf(context_wrap(HTTPD_CONF_FILE_1, path='/etc/httpd/conf.d/00-a.conf'))
    httpd3 = _HttpdConf(context_wrap(HTTPD_CONF_FILE_2, path='/etc/httpd/conf.d/01-b.conf'))
    result = HttpdConfTree([httpd1, httpd2, httpd3])

    server_root = result['ServerRoot'][-1]
    assert server_root.value == '/etc/httpd'
    assert server_root.line == 'ServerRoot "/etc/httpd"'
    assert server_root.file_name == 'httpd.conf'
    assert server_root.file_path == '/etc/httpd/conf/httpd.conf'

    listen = result["Listen"][-1]
    assert listen.value == 80
    assert listen.line == 'Listen 80'
    assert listen.file_name == 'httpd.conf'
    assert listen.file_path == '/etc/httpd/conf/httpd.conf'

    httpd1 = _HttpdConf(context_wrap(HTTPD_CONF_MAIN_3, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = _HttpdConf(context_wrap(HTTPD_CONF_FILE_1, path='/etc/httpd/conf.d/00-a.conf'))
    httpd3 = _HttpdConf(context_wrap(HTTPD_CONF_FILE_2, path='/etc/httpd/conf.d/01-b.conf'))
    result = HttpdConfTree([httpd1, httpd2, httpd3])

    server_root = result['ServerRoot'][-1]
    assert server_root.value == '/home/skontar/www'
    assert server_root.line == 'ServerRoot "/home/skontar/www"'
    assert server_root.file_name == '01-b.conf'
    assert server_root.file_path == '/etc/httpd/conf.d/01-b.conf'
    assert listen.value == 80
    assert listen.line == 'Listen 80'
    assert listen.file_name == 'httpd.conf'
    assert listen.file_path == '/etc/httpd/conf/httpd.conf'
Esempio n. 4
0
def test_httpd_ssl_cert_exception():
    conf1 = _HttpdConf(context_wrap(HTTPD_CONF, path='/etc/httpd/conf/httpd.conf'))
    conf2 = _HttpdConf(context_wrap(HTTPD_CONF_WITHOUT_SSL, path='/etc/httpd/conf.d/no_ssl.conf'))
    conf_tree = HttpdConfTree([conf1, conf2])
    broker1 = {
        HttpdConfTree: conf_tree
    }
    conf1 = _HttpdConf(context_wrap(HTTPD_CONF, path='/etc/httpd/conf/httpd.conf'))
    conf2 = _HttpdConf(context_wrap(HTTPD_SSL_CONF_NO_VALUE, path='/etc/httpd/conf.d/no_ssl.conf'))
    conf_tree = HttpdConfTree([conf1, conf2])
    broker2 = {
        HttpdConfTree: conf_tree
    }
    with pytest.raises(SkipComponent):
        httpd_ssl_certificate_files(broker1)
        httpd_ssl_certificate_files(broker2)
def test_empty_last_line():
    httpd = _HttpdConf(
        context_wrap(HTTPD_EMPTY_LAST, path='/etc/httpd/conf/httpd.conf'))
    result = HttpdConfTree([httpd])

    index_options = result['IndexOptions'][-1]
    assert index_options.value == 'FancyIndexing HTMLTable VersionSort'
def test_indented_lines_and_comments():
    httpd = _HttpdConf(
        context_wrap(HTTPD_EMBEDDED_QUOTES, path='/etc/httpd/conf/httpd.conf'))
    result = HttpdConfTree([httpd])

    request_headers = result['RequestHeader']
    assert len(request_headers) == 2
def test_unicode_comments():
    httpd = _HttpdConf(
        context_wrap(UNICODE_COMMENTS, path='/etc/httpd/conf/httpd.conf'))
    result = HttpdConfTree([httpd])

    rewrite_cond = result["DNSSDEnable"]
    assert len(rewrite_cond) == 1
def test_multiple_includes():
    httpd1 = _HttpdConf(
        context_wrap(MULTIPLE_INCLUDES, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = _HttpdConf(
        context_wrap(UNICODE_COMMENTS,
                     path='/etc/httpd/conf.d/05-foreman.d/hello.conf'))
    result = HttpdConfTree([httpd1, httpd2])
    assert len(result["IfVersion"]["DNSSDEnable"]) == 2
def test_recursive_includes():
    with pytest.raises(Exception):
        httpd1 = _HttpdConf(
            context_wrap(MULTIPLE_INCLUDES, path='/etc/httpd/conf/httpd.conf'))
        httpd2 = _HttpdConf(
            context_wrap(MULTIPLE_INCLUDES,
                         path='/etc/httpd/conf.d/05-foreman.d/hello.conf'))
        HttpdConfTree([httpd1, httpd2])
def test_regex_and_op_attrs():
    httpd = _HttpdConf(context_wrap(HTTPD_REGEX_AND_OP_ATTRS, path='/etc/httpd/conf/httpd.conf'))
    result = HttpdConfTree([httpd])

    rewrite_cond = result["RewriteCond"]
    assert len(rewrite_cond) == 3

    if_version = result["IfVersion"]
    assert len(if_version) == 1
Esempio n. 11
0
def test_simple_queries():
    httpd1 = _HttpdConf(context_wrap(HTTPD_CONF_NEST_1, path='/etc/httpd/conf/httpd.conf'))
    result = HttpdConfTree([httpd1])
    assert result["EnableSendfile"][first].value
    assert len(result["VirtualHost"]) == 1
    assert len(result["VirtualHost"]["Directory"]) == 1
    assert len(result["VirtualHost"]["IfModule"]) == 4
    assert len(result["VirtualHost"]["IfModule"]["RewriteEngine"]) == 2
    assert len(result["VirtualHost"]["IfModule", "mod_rewrite.c"]) == 2
Esempio n. 12
0
def test_httpd_certificate_info_in_nss_exception():
    conf1 = _HttpdConf(
        context_wrap(HTTPD_CONF, path='/etc/httpd/conf/httpd.conf'))
    conf2 = _HttpdConf(
        context_wrap(HTTPD_WITH_NSS_OFF, path='/etc/httpd/conf.d/nss.conf'))
    conf_tree = HttpdConfTree([conf1, conf2])
    broker = {HttpdConfTree: conf_tree}
    with pytest.raises(SkipComponent):
        httpd_certificate_info_in_nss(broker)
Esempio n. 13
0
def test_httpd_certificate_info_in_nss():
    conf1 = _HttpdConf(
        context_wrap(HTTPD_CONF, path='/etc/httpd/conf/httpd.conf'))
    conf2 = _HttpdConf(
        context_wrap(HTTPD_WITH_NSS, path='/etc/httpd/conf.d/nss.conf'))
    conf_tree = HttpdConfTree([conf1, conf2])
    broker = {HttpdConfTree: conf_tree}
    result = httpd_certificate_info_in_nss(broker)
    assert result == [('/etc/httpd/aliasa', 'testcerta'),
                      ('/etc/httpd/aliasb', 'testcertb')]
def test_httpd_nested_conf_file():
    httpd1 = _HttpdConf(context_wrap(HTTPD_CONF_MAIN_3, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = _HttpdConf(context_wrap(HTTPD_CONF_FILE_1, path='/etc/httpd/conf.d/00-a.conf'))
    httpd3 = _HttpdConf(context_wrap(HTTPD_CONF_FILE_2, path='/etc/httpd/conf.d/d1/hello.conf'))
    result = HttpdConfTree([httpd1, httpd2, httpd3])

    server_root = result['ServerRoot'][-1]
    assert server_root.value == '/home/skontar/www'
    assert server_root.line == 'ServerRoot "/home/skontar/www"'
    assert server_root.file_name == 'hello.conf'
    assert server_root.file_path == '/etc/httpd/conf.d/d1/hello.conf'
Esempio n. 15
0
def test_httpd_certificate():
    conf1 = _HttpdConf(context_wrap(HTTPD_CONF, path='/etc/httpd/conf/httpd.conf'))
    conf2 = _HttpdConf(context_wrap(HTTPD_SSL_CONF, path='/etc/httpd/conf.d/ssl.conf'))
    conf_tree = HttpdConfTree([conf1, conf2])

    broker = {
        HttpdConfTree: conf_tree
    }
    result = httpd_ssl_certificate_files(broker)
    assert result == ['/etc/pki/katello/certs/katello-apache.crt']

    conf1 = _HttpdConf(context_wrap(HTTPD_CONF, path='/etc/httpd/conf/httpd.conf'))
    conf2 = _HttpdConf(context_wrap(HTTPD_SSL_CONF_2, path='/etc/httpd/conf.d/ssl.conf'))
    conf_tree = HttpdConfTree([conf1, conf2])

    broker = {
        HttpdConfTree: conf_tree
    }
    result = httpd_ssl_certificate_files(broker)
    assert result == ['/etc/pki/katello/certs/katello-apache.crt', '/etc/pki/katello/certs/katello-apache_d.crt']
def test_active_httpd():
    httpd1 = _HttpdConf(context_wrap(HTTPD_CONF_1, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = _HttpdConf(context_wrap(HTTPD_CONF_2, path='/etc/httpd/conf.d/00-z.conf'))
    httpd3 = _HttpdConf(context_wrap(HTTPD_CONF_3, path='/etc/httpd/conf.d/z-z.conf'))
    result = HttpdConfTree([httpd1, httpd2, httpd3])

    assert result['IfModule', 'prefork.c']['MaxClients'][-1].value == 512
    assert result['IfModule', 'prefork.c']['MaxClients'][-1].file_path == '/etc/httpd/conf.d/z-z.conf'
    assert result['IfModule', 'prefork.c']['ThreadsPerChild'][-1].value == 16
    assert result['IfModule', 'prefork.c']['ServerLimit'][-1].value == 256
    assert result['IfModule', 'prefork.c']['JustForTest'][-1].file_name == '00-z.conf'
    assert result['JustForTest_NoSec'][0].line == 'JustForTest_NoSec "/var/www/cgi"'
def test_httpd_conf_tree_with_load_modules():
    httpd1 = _HttpdConfSclHttpd24(context_wrap(HTTPD_CONF_MAIN_4, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = _HttpdConfSclHttpd24(context_wrap(HTTPD_CONF_MORE, path='/etc/httpd/conf.d/01-b.conf'))
    httpd3 = _HttpdConfSclHttpd24(context_wrap(HTTPD_CONF_FILE_3, path='/etc/httpd/conf.modules.d/02-c.conf'))
    result = HttpdConfTree([httpd1, httpd2, httpd3])
    userdirs = result['UserDir']
    assert len(userdirs) == 2
    assert userdirs[-1].value == 'enable bob'
    load_module_list = result['LoadModule']
    assert len(load_module_list) == 4
    assert result['LoadModule'][3].value == 'mpm_prefork_module modules/mod_mpm_prefork.so'
    assert result['LoadModule'][3].file_path == '/etc/httpd/conf.modules.d/02-c.conf'
def test_shadowing():
    httpd1 = _HttpdConf(context_wrap(HTTPD_CONF_SHADOWTEST_1, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = _HttpdConf(context_wrap(HTTPD_CONF_SHADOWTEST_2, path='/etc/httpd/conf.d/00-z.conf'))
    httpd3 = _HttpdConf(context_wrap(HTTPD_CONF_SHADOWTEST_3, path='/etc/httpd/conf.d/z-z.conf'))
    result = HttpdConfTree([httpd1, httpd2, httpd3])

    assert len(result["Foo"]) == 9
    assert len(result["IfModule"]) == 3
    assert len(result["IfModule"]["Foo"]) == 9
    assert len(result["IfModule"]["Bar"]) == 9
    assert len(result["IfModule", "prefork.c"]) == 2
    assert len(result["IfModule", "prefork.c"]["Foo"]) == 6
    assert len(result["IfModule", "prefork.c"]["Bar"]) == 6
    assert len(result["IfModule", "prefork.c"][0]["Foo"]) == 3
    assert len(result["IfModule", "prefork.c"][1]["Foo"]) == 3
    assert len(result["IfModule", "prefork.c"][0]["Bar"]) == 3
    assert len(result["IfModule", "prefork.c"][1]["Bar"]) == 3
def test_httpd_one_file_overwrites():
    httpd = _HttpdConf(context_wrap(HTTPD_CONF_MORE, path='/etc/httpd/conf/httpd.conf'))
    result = HttpdConfTree([httpd])

    active_setting = result['UserDir'][-1]
    assert active_setting.value == 'enable bob'
    assert active_setting.file_path == '/etc/httpd/conf/httpd.conf'
    assert active_setting.file_name == 'httpd.conf'
    assert active_setting.line == 'UserDir enable bob', active_setting.line

    setting_list = result['UserDir']
    assert len(setting_list) == 2
    assert setting_list[0].value == 'disable'
    assert setting_list[0].line == 'UserDir disable'
    assert setting_list[0].file_path == '/etc/httpd/conf/httpd.conf'
    assert setting_list[0].file_name == 'httpd.conf'
    assert setting_list[0].section is None
    assert setting_list[1].value == 'enable bob'
    assert setting_list[1].line == 'UserDir enable bob'
    assert setting_list[1].file_path == '/etc/httpd/conf/httpd.conf'
    assert setting_list[1].file_name == 'httpd.conf'
    assert setting_list[1].section_name is None
Esempio n. 20
0
def test_nopath():
    # no path
    httpd2 = _HttpdConf(context_wrap(HTTPD_CONF_2))
    try:
        result = HttpdConfTree([httpd2])
        # assert result['IfModule', 'prefork.c']['ServerLimit'][-1].value == 1024
        exception_happened = False
    except:
        exception_happened = True
    assert exception_happened

    # no httpd.conf
    httpd2 = _HttpdConf(
        context_wrap(HTTPD_CONF_2, path='/etc/httpd/conf.d/00-z.conf'))
    try:
        result = HttpdConfTree([httpd2])
        # assert result['IfModule', 'prefork.c']['ServerLimit'][-1].value == 1024
        exception_happened = False
    except:
        exception_happened = True
    assert exception_happened

    httpd2 = _HttpdConf(
        context_wrap(HTTPD_CONF_2, path='/etc/httpd/conf/httpd.conf'))
    result = HttpdConfTree([httpd2])
    assert result['IfModule', 'prefork.c']['ServerLimit'][-1].value == 1024

    httpd2 = _HttpdConf(
        context_wrap(HTTPD_CONF_2, path='/laaalalalala/blablabla/httpd.conf'))
    result = HttpdConfTree([httpd2])
    assert result['IfModule', 'prefork.c']['ServerLimit'][-1].value == 1024

    # no include in httpd.conf
    httpd2 = _HttpdConf(
        context_wrap(HTTPD_CONF_2, path='/etc/httpd/conf/httpd.conf'))
    httpd3 = _HttpdConf(
        context_wrap(HTTPD_CONF_3, path='/etc/httpd/conf.d/z-z.conf'))
    result = HttpdConfTree([httpd2, httpd3])
    assert result['IfModule', 'prefork.c']['ServerLimit'][-1].value == 1024

    # no include in httpd.conf
    httpd2 = _HttpdConf(
        context_wrap(HTTPD_CONF_2, path='/etc/httpd/conf/httpd.conf'))
    httpd3 = _HttpdConf(
        context_wrap(HTTPD_CONF_3, path='/etc/httpd/conf.d/aaa.conf'))
    result = HttpdConfTree([httpd3, httpd2])
    assert len(result['IfModule', 'prefork.c']['ServerLimit']) == 1
    assert result['IfModule', 'prefork.c']['ServerLimit'][0].value == 1024
    assert result['IfModule', 'prefork.c']['ServerLimit'][-1].value == 1024

    # with an include
    httpd1 = _HttpdConf(
        context_wrap(HTTPD_CONF_1, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = _HttpdConf(
        context_wrap(HTTPD_CONF_2, path='/etc/httpd/conf.d/00-z.conf'))
    result = HttpdConfTree([httpd1, httpd2])
    assert len(result['IfModule', 'prefork.c']['ServerLimit']) == 2
    assert result['IfModule', 'prefork.c']['ServerLimit'][0].value == 256
    assert result['IfModule', 'prefork.c']['ServerLimit'][-1].value == 1024

    # colliding filenames
    httpd1 = _HttpdConf(
        context_wrap(HTTPD_CONF_1, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = _HttpdConf(
        context_wrap(HTTPD_CONF_2, path='/etc/httpd/conf.d/00-z.conf'))
    httpd3 = _HttpdConf(
        context_wrap(HTTPD_CONF_3, path='/etc/httpd/conf.d/00-z.conf'))
    result = HttpdConfTree([httpd1, httpd2, httpd3])
    assert len(result['IfModule', 'prefork.c']['ServerLimit']) == 3
    assert result['IfModule',
                  'prefork.c']['ServerLimit'][0].value == 256  # httpd1
    assert result['IfModule',
                  'prefork.c']['ServerLimit'][1].value == 1024  # httpd2
    assert result['IfModule',
                  'prefork.c']['ServerLimit'][-1].value == 256  # httpd3
    assert len(result['IfModule', 'prefork.c']['MaxClients']) == 3
    assert result['IfModule',
                  'prefork.c']['MaxClients'][0].value == 256  # httpd1
    assert result['IfModule',
                  'prefork.c']['MaxClients'][1].value == 1024  # httpd2
    assert result['IfModule',
                  'prefork.c']['MaxClients'][-1].value == 512  # httpd3

    # testing other ways to access the same indices
    assert result['IfModule',
                  'prefork.c']['MaxClients'][0].value == 256  # httpd1
    assert result['IfModule',
                  'prefork.c']['MaxClients'][2].value == 512  # httpd3
    assert result['IfModule',
                  'prefork.c']['MaxClients'][-1].value == 512  # httpd3
Esempio n. 21
0
def test_complex_queries():
    httpd1 = _HttpdConf(
        context_wrap(HTTPD_CONF_NEST_1, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = _HttpdConf(
        context_wrap(HTTPD_CONF_NEST_3, path='/etc/httpd/conf.d/00-a.conf'))
    httpd3 = _HttpdConf(
        context_wrap(HTTPD_CONF_NEST_4, path='/etc/httpd/conf.d/01-b.conf'))
    result = HttpdConfTree([httpd1, httpd2, httpd3])
    assert len(result.select("VirtualHost")) == 3
    assert len(result.select(("VirtualHost", "128.39.140.28"))) == 2
    assert len(result.select(("VirtualHost", "128.39.140.30"))) == 1
    assert len(result.select(("VirtualHost", startswith("128.39.140")))) == 3
    assert len(result.select(("VirtualHost", ~startswith("128.39.140")))) == 0
    assert len(result.select(("VirtualHost", endswith("140.30")))) == 1
    assert len(result.select(("VirtualHost", ~endswith("140.30")))) == 2
    assert len(result.select(
        (startswith("Virtual"), ~endswith("140.30")))) == 2
    assert len(result.select("FilesMatch", deep=True, roots=False)) == 3

    # find all IfModule !php5_module stanzas regardless of location
    assert len(
        result.select(("IfModule", "!php5_module"), deep=True,
                      roots=False)) == 6

    # find all IfModule !php5_module stanzas immediately beneath a VirtualHost
    assert len(
        result.select("VirtualHost", ("IfModule", "!php5_module"),
                      roots=False)) == 3

    # find all IfModule !php4_module stanzas anywhere beneath a top level VirtualHost
    res = result.select("VirtualHost").select(("IfModule", "!php4_module"),
                                              deep=True,
                                              roots=False)
    assert len(res) == 3

    assert len(result.select(("VirtualHost", ~is_private))) == 3

    res = result.select(("VirtualHost", in_network("128.39.0.0/16")))
    assert len(res) == 3

    res = result.select(
        ("VirtualHost", ~is_private & in_network("128.39.0.0/16")))
    assert len(res) == 3
Esempio n. 22
0
def test_mixed_name():
    httpd1 = _HttpdConf(
        context_wrap(HTTPD_CONF_MIXED_NAME, path='/etc/httpd/conf/httpd.conf'))
    result = HttpdConfTree([httpd1])
    assert len(result.doc["H2Push"]) == 1