コード例 #1
0
def test_httpd_no_main_config():
    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 = HttpdConfAll([httpd2, httpd3])
    assert [a.file_name
            for a in result.config_data] == ['00-a.conf', '01-b.conf']
コード例 #2
0
def test_active_httpd_directory():
    httpd1 = HttpdConf(
        context_wrap(HTTPD_CONF_NEST_1, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = HttpdConf(
        context_wrap(HTTPD_CONF_NEST_2, path='/etc/httpd/conf.d/00-z.conf'))
    result = HttpdConfAll([httpd1, httpd2])
    assert result.get_section_list("Directory") == [
        (('Directory', '/var/www/example'), 'httpd.conf',
         '/etc/httpd/conf/httpd.conf')
    ]
    assert result.get_section_list("asdf") == []
    assert result.get_section_list(123456) == []
コード例 #3
0
def test_get_httpd_conf_nest_2():
    context = context_wrap(HTTPD_CONF_NEST_2, path=HTTPD_CONF_PATH)
    result = HttpdConf(context)

    assert result[("IfModule", "!php5_module")] == {
        'Testphp': [('php5_1', 'Testphp php5_1', 'IfModule', '!php5_module',
                     'httpd.conf', '/etc/httpd/conf/httpd.conf'),
                    ('php5_2', 'Testphp php5_2', 'IfModule', '!php5_module',
                     'httpd.conf', '/etc/httpd/conf/httpd.conf'),
                    ('php5_3', 'Testphp php5_3', 'IfModule', '!php5_module',
                     'httpd.conf', '/etc/httpd/conf/httpd.conf')],
        'JustATest': [('on', 'JustATest on', 'IfModule', '!php5_module',
                       'httpd.conf', '/etc/httpd/conf/httpd.conf')],
        ('IfModule', '!php4_module'): {
            ('Location', '/'): {
                ('FilesMatch', '".php[45]?$"'): {
                    'Deny': [('from all', 'Deny from all', 'FilesMatch',
                              '".php[45]?$"', 'httpd.conf',
                              '/etc/httpd/conf/httpd.conf')],
                    'Order': [('allow,deny', 'Order allow,deny', 'FilesMatch',
                               '".php[45]?$"', 'httpd.conf',
                               '/etc/httpd/conf/httpd.conf'),
                              ('deny,allow', 'Order deny,allow', 'FilesMatch',
                               '".php[45]?$"', 'httpd.conf',
                               '/etc/httpd/conf/httpd.conf')]
                }
            },
            'Testphp':
            [('php4_1', 'Testphp php4_1', 'IfModule', '!php4_module',
              'httpd.conf', '/etc/httpd/conf/httpd.conf'),
             ('php4_2', 'Testphp php4_2', 'IfModule', '!php4_module',
              'httpd.conf', '/etc/httpd/conf/httpd.conf')]
        }
    }
コード例 #4
0
def test_doc():
    env = {
        'HttpdConf': HttpdConf,
        'httpd_conf': HttpdConf(context_wrap(HTTPD_CONF_DOC, path='/path')),
    }
    failed, total = doctest.testmod(httpd_conf, globs=env)
    assert failed == 0
コード例 #5
0
def test_main_config_no_splitting():
    context = context_wrap(HTTPD_CONF_1, path=HTTPD_CONF_PATH)
    result = HttpdConf(context)

    assert result.file_path == HTTPD_CONF_PATH
    assert result.file_name == "httpd.conf"
    assert result.data == result.first_half
    assert result.second_half == {}
コード例 #6
0
def test_active_httpd_nest_2():
    httpd1 = HttpdConf(
        context_wrap(HTTPD_CONF_NEST_3, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = HttpdConf(
        context_wrap(HTTPD_CONF_NEST_4, path='/etc/httpd/conf.d/00-z.conf'))
    result = HttpdConfAll([httpd1, httpd2])
    testphp_im = result.get_setting_list('Testphp', 'IfModule')
    assert {
        ('IfModule', '!php5_module'):
        [('php5_v3_1', 'Testphp php5_v3_1', 'IfModule', '!php5_module',
          'httpd.conf', '/etc/httpd/conf/httpd.conf'),
         ('php5_v3_2', 'Testphp php5_v3_2', 'IfModule', '!php5_module',
          'httpd.conf', '/etc/httpd/conf/httpd.conf')]
    } in testphp_im
    assert {
        ('IfModule', '!php4_module'):
        [('php4_v3_1', 'Testphp php4_v3_1', 'IfModule', '!php4_module',
          'httpd.conf', '/etc/httpd/conf/httpd.conf')]
    } in testphp_im
    assert {
        ('IfModule', '!php5_module'):
        [('php5_v4_1', 'Testphp php5_v4_1', 'IfModule', '!php5_module',
          '00-z.conf', '/etc/httpd/conf.d/00-z.conf'),
         ('php5_v4_2', 'Testphp php5_v4_2', 'IfModule', '!php5_module',
          '00-z.conf', '/etc/httpd/conf.d/00-z.conf')]
    } in testphp_im
    assert {
        ('IfModule', '!php4_module'):
        [('php4_v4_1', 'Testphp php4_v4_1', 'IfModule', '!php4_module',
          '00-z.conf', '/etc/httpd/conf.d/00-z.conf')]
    } in testphp_im
    assert {
        ('IfModule', '!php5_module'):
        [('php5_3_a', 'Testphp php5_3_a', 'IfModule', '!php5_module',
          'httpd.conf', '/etc/httpd/conf/httpd.conf'),
         ('php5_4_b', 'Testphp php5_4_b', 'IfModule', '!php5_module',
          '00-z.conf', '/etc/httpd/conf.d/00-z.conf')]
    } in testphp_im
    assert {
        ('IfModule', '!php4_module'):
        [('php4_3_a', 'Testphp php4_3_a', 'IfModule', '!php4_module',
          'httpd.conf', '/etc/httpd/conf/httpd.conf'),
         ('php4_4_b', 'Testphp php4_4_b', 'IfModule', '!php4_module',
          '00-z.conf', '/etc/httpd/conf.d/00-z.conf')]
    } in testphp_im
コード例 #7
0
def test_multiple_values_for_directive():
    context = context_wrap(HTTPD_CONF_MORE, path=HTTPD_CONF_PATH)
    result = HttpdConf(context)

    assert result.file_path == HTTPD_CONF_PATH
    assert result.file_name == "httpd.conf"
    assert result['UserDir'] == [('disable', 'UserDir disable', None, None,
                                  result.file_name, result.file_path),
                                 ('enable bob', 'UserDir enable bob', None,
                                  None, result.file_name, result.file_path)]
    assert len(result['UserDir']) == 2
    assert result['UserDir'][0].value == 'disable'
    assert result['UserDir'][1].value == 'enable bob'
コード例 #8
0
def test_main_config_splitting():
    context = context_wrap(HTTPD_CONF_SPLIT, path=HTTPD_CONF_PATH)
    result = HttpdConf(context)

    assert result.file_path == HTTPD_CONF_PATH
    assert result.file_name == "httpd.conf"
    assert result['LogLevel'] == [('warn', 'LogLevel warn', None, None,
                                   result.file_name, result.file_path)]
    assert result['EnableSendfile'] == [('on', 'EnableSendfile on', None, None,
                                         result.file_name, result.file_path)]
    assert result.first_half['LogLevel'][-1].value == 'warn'
    assert result.first_half['LogLevel'][-1].line == 'LogLevel warn'
    assert result.second_half['EnableSendfile'][-1].value == 'on'
コード例 #9
0
def test_get_httpd_conf_nest_1():
    context = context_wrap(HTTPD_CONF_NEST_1, path=HTTPD_CONF_PATH)
    result = HttpdConf(context)

    assert result[("VirtualHost", "192.0.2.1")][(
        "IfModule",
        "mod_php4.c")]['php_admin_flag'][-1].value == "safe_mode Off"
    assert result[("VirtualHost", "192.0.2.1")][(
        "IfModule", "mod_rewrite.c")]['RewriteEngine'][-1].value == "Off"
    assert result[("VirtualHost", "192.0.2.1")][(
        "IfModule",
        "mod_rewrite.c")]['RewriteRule'][-1].value == ".* /index.php"
    assert result[("VirtualHost",
                   "192.0.2.1")]['ServerName'][-1].value == "www.example.com"
コード例 #10
0
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 = HttpdConfAll([httpd1, httpd2, httpd3])
    assert result.get_active_setting('MaxClients',
                                     section=('IfModule',
                                              'prefork.c'))[0].value == '512'
    assert result.get_active_setting(
        'MaxClients',
        section=('IfModule',
                 'prefork.c'))[0].file_path == '/etc/httpd/conf.d/z-z.conf'
    assert result.get_active_setting('ThreadsPerChild',
                                     section=('IfModule',
                                              'prefork.c'))[0].value == '16'
    assert result.get_active_setting(
        "MaxClients", ("IfModule", "prefork")) == [
            ParsedData(value='512',
                       line='MaxClients       512',
                       section='IfModule',
                       section_name='prefork.c',
                       file_name='z-z.conf',
                       file_path='/etc/httpd/conf.d/z-z.conf')
        ]
    assert result.get_active_setting('ServerLimit',
                                     section=('IfModule',
                                              'prefork.c'))[0].value == '256'
    assert result.get_active_setting(
        'JustForTest',
        section=('IfModule', 'prefork.c'))[-1].file_name == '00-z.conf'
    assert result.get_active_setting(
        'JustForTest_NoSec').line == 'JustForTest_NoSec "/var/www/cgi"'
コード例 #11
0
def test_get_httpd_conf_2():
    context = context_wrap(HTTPD_CONF_D_1, path=HTTPD_CONF_D_PATH)
    result = HttpdConf(context)

    except_SSLC = 'ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW'
    assert result["SSLProtocol"] == [
        ('-ALL +SSLv3', 'SSLProtocol -ALL +SSLv3', None, None,
         result.file_name, result.file_path)
    ]
    assert result["SSLCipherSuite"][-1].value == except_SSLC
    assert "NSSProtocol" not in result
    assert "MaxClients" not in result
    assert result.file_path == HTTPD_CONF_D_PATH
    assert result.file_name == "default.conf"
    assert result["SSLProtocol"][-1].value == '-ALL +SSLv3'
    assert result["SSLProtocol"][-1].line == 'SSLProtocol -ALL +SSLv3'
コード例 #12
0
def test_get_httpd_conf_1():
    context = context_wrap(HTTPD_CONF_1, path=HTTPD_CONF_PATH)
    result = HttpdConf(context)

    assert "SSLCipherSuite" not in result
    assert "SSLV3 TLSV1.0" in result["NSSProtocol"][-1]
    assert result[("IfModule", "prefork.c")]["MaxClients"][-1].value == "256"
    assert result[("IfModule", "worker.c")]["MaxClients"][-1].value == "300"
    assert type(result[("IfModule", "worker.c")]) is dict
    assert result.file_path == HTTPD_CONF_PATH
    assert 'ThreadsPerChild' not in result[('IfModule', 'prefork.c')]
    assert result[('IfModule',
                   'prefork.c')]['MaxRequestsPerChild'][-1].value == '200'
    assert result.file_name == "httpd.conf"
    assert result['LoadModule'][
        0].value == 'auth_basic_module modules/mod_auth_basic.so'
    assert result['LoadModule'][
        -1].value == 'auth_digest_module modules/mod_auth_digest.so'
    assert result['Directory', '/']['Options'][-1].value == 'FollowSymLinks'
コード例 #13
0
def test_httpd_one_file_overwrites():
    httpd = HttpdConf(
        context_wrap(HTTPD_CONF_MORE, path='/etc/httpd/conf/httpd.conf'))
    result = HttpdConfAll([httpd])

    active_setting = result.get_active_setting('UserDir')
    assert active_setting.value == 'enable bob'
    assert active_setting.line == 'UserDir enable bob'
    assert active_setting.file_path == '/etc/httpd/conf/httpd.conf'
    assert active_setting.file_name == 'httpd.conf'

    setting_list = result.get_setting_list('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
コード例 #14
0
def test_main_config_no_main_config():
    context = context_wrap(HTTPD_CONF_D_1, path=HTTPD_CONF_D_PATH)
    result = HttpdConf(context)

    assert result.first_half == {}
    assert result.second_half == {}
コード例 #15
0
def test_httpd_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 = HttpdConfAll([httpd1, httpd2, httpd3])
    assert result.get_active_setting('ServerRoot').value == '/home/skontar/www'
    assert result.get_active_setting(
        'ServerRoot').line == 'ServerRoot "/home/skontar/www"'
    assert result.get_active_setting('ServerRoot').file_name == '01-b.conf'
    assert result.get_active_setting(
        'ServerRoot').file_path == '/etc/httpd/conf.d/01-b.conf'
    assert result.get_active_setting('Listen').value == '8080'
    assert result.get_active_setting('Listen').line == 'Listen 8080'
    assert result.get_active_setting('Listen').file_name == '00-a.conf'
    assert result.get_active_setting(
        '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 = HttpdConfAll([httpd1, httpd2, httpd3])
    assert result.get_active_setting('ServerRoot').value == '/etc/httpd'
    assert result.get_active_setting(
        'ServerRoot').line == 'ServerRoot "/etc/httpd"'
    assert result.get_active_setting('ServerRoot').file_name == 'httpd.conf'
    assert result.get_active_setting(
        'ServerRoot').file_path == '/etc/httpd/conf/httpd.conf'
    assert result.get_active_setting('Listen').value == '80'
    assert result.get_active_setting('Listen').line == 'Listen 80'
    assert result.get_active_setting('Listen').file_name == 'httpd.conf'
    assert result.get_active_setting(
        '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 = HttpdConfAll([httpd1, httpd2, httpd3])
    assert result.get_active_setting('ServerRoot').value == '/home/skontar/www'
    assert result.get_active_setting(
        'ServerRoot').line == 'ServerRoot "/home/skontar/www"'
    assert result.get_active_setting('ServerRoot').file_name == '01-b.conf'
    assert result.get_active_setting(
        'ServerRoot').file_path == '/etc/httpd/conf.d/01-b.conf'
    assert result.get_active_setting('Listen').value == '80'
    assert result.get_active_setting('Listen').line == 'Listen 80'
    assert result.get_active_setting('Listen').file_name == 'httpd.conf'
    assert result.get_active_setting(
        'Listen').file_path == '/etc/httpd/conf/httpd.conf'

    # Test is data from inactive configs are also stored
    assert [a.file_name for a in result.config_data
            ] == ['httpd.conf', '00-a.conf', '01-b.conf', 'httpd.conf']
    assert result.config_data[1].file_name == '00-a.conf'
    assert result.config_data[1].file_path == '/etc/httpd/conf.d/00-a.conf'
    assert result.config_data[1].full_data_dict['Listen'][0].value == '8080'
    assert result.config_data[1].full_data_dict['Listen'][
        0].line == 'Listen 8080'
コード例 #16
0
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 = HttpdConfAll([httpd1, httpd2, httpd3])

    # get_setting_list returns ALL matching data

    assert result.get_setting_list('Foo') == [
        ParsedData('1A', 'Foo 1A', None, None, 'httpd.conf',
                   '/etc/httpd/conf/httpd.conf'),
        ParsedData('1B', 'Foo 1B', None, None, 'httpd.conf',
                   '/etc/httpd/conf/httpd.conf'),
        ParsedData('1C', 'Foo 1C', None, None, 'httpd.conf',
                   '/etc/httpd/conf/httpd.conf'),
        ParsedData('2A', 'Foo 2A', None, None, '00-z.conf',
                   '/etc/httpd/conf.d/00-z.conf'),
        ParsedData('2B', 'Foo 2B', None, None, '00-z.conf',
                   '/etc/httpd/conf.d/00-z.conf'),
        ParsedData('2C', 'Foo 2C', None, None, '00-z.conf',
                   '/etc/httpd/conf.d/00-z.conf'),
        ParsedData('3A', 'Foo 3A', None, None, 'z-z.conf',
                   '/etc/httpd/conf.d/z-z.conf'),
        ParsedData('3B', 'Foo 3B', None, None, 'z-z.conf',
                   '/etc/httpd/conf.d/z-z.conf'),
        ParsedData('3C', 'Foo 3C', None, None, 'z-z.conf',
                   '/etc/httpd/conf.d/z-z.conf'),
    ]
    assert result.get_setting_list(
        'Bar', section=('IfModule', 'prefork.c')) == [
            {
                ('IfModule', 'prefork.c'): [
                    ParsedData('1A', 'Bar 1A', 'IfModule', 'prefork.c',
                               'httpd.conf', '/etc/httpd/conf/httpd.conf'),
                    ParsedData('1B', 'Bar 1B', 'IfModule', 'prefork.c',
                               'httpd.conf', '/etc/httpd/conf/httpd.conf'),
                    ParsedData('1C', 'Bar 1C', 'IfModule', 'prefork.c',
                               'httpd.conf', '/etc/httpd/conf/httpd.conf'),
                    ParsedData('3A', 'Bar 3A', 'IfModule', 'prefork.c',
                               'z-z.conf', '/etc/httpd/conf.d/z-z.conf'),
                    ParsedData('3B', 'Bar 3B', 'IfModule', 'prefork.c',
                               'z-z.conf', '/etc/httpd/conf.d/z-z.conf'),
                    ParsedData('3C', 'Bar 3C', 'IfModule', 'prefork.c',
                               'z-z.conf', '/etc/httpd/conf.d/z-z.conf'),
                ],
            },
            {
                ('IfModule', 'ASDF.prefork.c.ASDF'): [
                    ParsedData('2A', 'Bar 2A', 'IfModule',
                               'ASDF.prefork.c.ASDF', '00-z.conf',
                               '/etc/httpd/conf.d/00-z.conf'),
                    ParsedData('2B', 'Bar 2B', 'IfModule',
                               'ASDF.prefork.c.ASDF', '00-z.conf',
                               '/etc/httpd/conf.d/00-z.conf'),
                    ParsedData('2C', 'Bar 2C', 'IfModule',
                               'ASDF.prefork.c.ASDF', '00-z.conf',
                               '/etc/httpd/conf.d/00-z.conf'),
                ],
            },
        ]
    assert result.get_setting_list('Bar') == []

    # get_active_setting returns the last value

    assert result.get_active_setting('Foo') == ('3C', 'Foo 3C', None, None,
                                                'z-z.conf',
                                                '/etc/httpd/conf.d/z-z.conf')
    assert result.get_active_setting(
        'Bar', section=('IfModule', 'prefork.c')) == [
            ('3C', 'Bar 3C', 'IfModule', 'prefork.c', 'z-z.conf',
             '/etc/httpd/conf.d/z-z.conf'),
            ('2C', 'Bar 2C', 'IfModule', 'ASDF.prefork.c.ASDF', '00-z.conf',
             '/etc/httpd/conf.d/00-z.conf'),
        ]
    assert result.get_active_setting('Bar') is None
コード例 #17
0
def test_no_name_section():
    context = context_wrap(HTTPD_CONF_NO_NAME_SEC, path=HTTPD_CONF_PATH)
    result = HttpdConf(context)

    assert result[("RequireAll", "")]["AuthName"][-1].value == "NAME Access"
    assert result[("RequireAll", "")]["Require"][-1].value == "valid-user"
コード例 #18
0
def test_active_httpd_nest_1():
    httpd1 = HttpdConf(
        context_wrap(HTTPD_CONF_NEST_1, path='/etc/httpd/conf/httpd.conf'))
    httpd2 = HttpdConf(
        context_wrap(HTTPD_CONF_NEST_2, path='/etc/httpd/conf.d/00-z.conf'))
    result = HttpdConfAll([httpd1, httpd2])
    assert result.get_setting_list('Order1', ('FilesMatch', 'php')) == []
    assert result.get_setting_list('Order', ('FilesMatch', 'pdf')) == []
    php_fm_order = result.get_setting_list('Order',
                                           section=('FilesMatch', 'php'))
    assert {
        ('FilesMatch', '".php[45]?$"'):
        [('allow,deny', 'Order allow,deny', 'FilesMatch', '".php[45]?$"',
          '00-z.conf', '/etc/httpd/conf.d/00-z.conf'),
         ('deny,allow', 'Order deny,allow', 'FilesMatch', '".php[45]?$"',
          '00-z.conf', '/etc/httpd/conf.d/00-z.conf')]
    } in php_fm_order
    assert {
        ('FilesMatch', '".php[45]"'):
        [('allow,deny', 'Order allow,deny', 'FilesMatch', '".php[45]"',
          'httpd.conf', '/etc/httpd/conf/httpd.conf'),
         ('deny,allow', 'Order deny,allow', 'FilesMatch', '".php[45]"',
          '00-z.conf', '/etc/httpd/conf.d/00-z.conf')],
    } in php_fm_order
    assert {
        ('FilesMatch', '".php[45]?$"'):
        [('allow,deny', 'Order allow,deny', 'FilesMatch', '".php[45]?$"',
          'httpd.conf', '/etc/httpd/conf/httpd.conf'),
         ('deny,allow', 'Order deny,allow', 'FilesMatch', '".php[45]?$"',
          'httpd.conf', '/etc/httpd/conf/httpd.conf')]
    } in php_fm_order
    re_im = result.get_setting_list('RewriteEngine', 'IfModule')
    assert {
        ('IfModule', 'mod_rewrite.c'):
        [('On', 'RewriteEngine On', 'IfModule', 'mod_rewrite.c', 'httpd.conf',
          '/etc/httpd/conf/httpd.conf'),
         ('Off', 'RewriteEngine Off', 'IfModule', 'mod_rewrite.c',
          'httpd.conf', '/etc/httpd/conf/httpd.conf')]
    } in re_im
    assert {
        ('IfModule', 'mod_rewrite.c'):
        [('Off', 'RewriteEngine Off', 'IfModule', 'mod_rewrite.c',
          'httpd.conf', '/etc/httpd/conf/httpd.conf'),
         ('On', 'RewriteEngine On', 'IfModule', 'mod_rewrite.c', '00-z.conf',
          '/etc/httpd/conf.d/00-z.conf')]
    } in re_im
    assert sorted(result.get_setting_list('EnableSendfile')) == sorted([
        ('off', 'EnableSendfile off', None, None, '00-z.conf',
         '/etc/httpd/conf.d/00-z.conf'),
        ('on', 'EnableSendfile on', None, None, 'httpd.conf',
         '/etc/httpd/conf/httpd.conf')
    ])
    assert result.get_setting_list('LogLevel') == [
        ('warn', 'LogLevel warn', None, None, 'httpd.conf',
         '/etc/httpd/conf/httpd.conf')
    ]
    assert result.get_setting_list('LogLevel1') == []

    assert result.get_active_setting('Order1', ('FilesMatch', 'php')) == []
    assert result.get_active_setting('Order', ('FilesMatch', 'pdf')) == []
    assert len(result.get_active_setting('Order',
                                         ('FilesMatch', '.php[45]?$'))) == 2
    assert len(result.get_active_setting('Order', ('FilesMatch', ))) == 4
    assert len(result.get_active_setting('Order',
                                         ('FilesMatch', '.php[45]'))) == 3
    assert sorted(
        result.get_active_setting(
            'Order', section=('FilesMatch', 'php'))) == sorted([
                ('deny,allow', 'Order deny,allow', 'FilesMatch',
                 '".php[45]?$"', '00-z.conf', '/etc/httpd/conf.d/00-z.conf'),
                ('deny,allow', 'Order deny,allow', 'FilesMatch', '".php[45]"',
                 '00-z.conf', '/etc/httpd/conf.d/00-z.conf'),
                ('deny,allow', 'Order deny,allow', 'FilesMatch',
                 '".php[45]?$"', 'httpd.conf', '/etc/httpd/conf/httpd.conf')
            ])
    assert sorted(
        result.get_active_setting(
            'RewriteEngine', section='IfModule')) == sorted([
                ('Off', 'RewriteEngine Off', 'IfModule', 'mod_rewrite.c',
                 'httpd.conf', '/etc/httpd/conf/httpd.conf'),
                ('On', 'RewriteEngine On', 'IfModule', 'mod_rewrite.c',
                 '00-z.conf', '/etc/httpd/conf.d/00-z.conf')
            ])
    assert result.get_active_setting(
        'EnableSendfile').line == 'EnableSendfile on'
    assert result.get_active_setting('Deny', ('FilesMatch', 'test')) == []
    assert result.get_active_setting(
        'Allow', ('FilesMatch', 'test'))[0].value == 'from all'
    assert result.get_active_setting('Deny', section=('IfModule', )) == []
    assert result.get_active_setting('MaxClients',
                                     section=('IfModule', 'prefork')) == []
    assert result.get_active_setting(
        'RewriteRule',
        section=('IfModule',
                 'mod_rewrite.c'))[0].line == "RewriteRule .* /index.php"
    assert result.get_active_setting("DocumentRoot").value == '/var/www/html'
    assert result.get_active_setting('RewriteRule',
                                     section=('IfModule', 'mod_rewrite.c',
                                              'invalid_test')) == []
    assert result.get_active_setting('LogLevel') == (
        'warn', 'LogLevel warn', None, None, 'httpd.conf',
        '/etc/httpd/conf/httpd.conf')
    assert result.get_active_setting('LogLevel1') is None