Ejemplo n.º 1
0
 def test_isc_logging_chan_method_option_series_failing(self):
     """ Clause logging; Series Method; failing mode """
     test_string = 'print-time 2; buffered -1; print-severity True;'
     expected_result = {'print_time': '1', 'buffered': '0', 'print_severity': 'True'}
     assertParserResultDictFalse(logging_chan_method_option_series,
                                 test_string,
                                 expected_result)
Ejemplo n.º 2
0
 def test_isc_logging_chan_print_severity_element_failing(self):
     """ Clause logging; Element Channel Print Severity; failing mode """
     test_string = 'print-severity severe;'
     expected_result = {'print_severity': 'severe'}
     assertParserResultDictFalse(logging_chan_print_severity_element,
                                 test_string,
                                 expected_result)
Ejemplo n.º 3
0
 def test_isc_logging_chan_file_method_failing(self):
     """ Clause logging; Element File Method; failing mode """
     test_string = 'stdin;'
     expected_result = {}
     assertParserResultDictFalse(logging_chan_file_method,
                                 test_string,
                                 expected_result, 'did not detect missing semicolon')
     test_string ='stdout;'
     expected_result = {}
     assertParserResultDictFalse(logging_chan_file_method,
                                 test_string,
                                 expected_result, 'did not detect missing semicolon')
     test_string ='zero;'
     expected_result = {}
     assertParserResultDictFalse(logging_chan_file_method,
                                 test_string,
                                 expected_result, 'did not detect missing semicolon')
     test_string ='file nutz;file-with-semicolon.type;'
     expected_result = {}
     assertParserResultDictFalse(logging_chan_file_method,
                                 test_string,
                                 expected_result, 'did not detect missing semicolon')
     test_string = 'syslog warning;'
     expected_result = {'io': 'null'}
     assertParserResultDictFalse(logging_chan_file_method,
                                 test_string,
                                 expected_result, 'did not detect missing semicolon')
Ejemplo n.º 4
0
 def test_isc_masters_element_series_failing(self):
     """Masters clause, Master Element series, purposely failing mode"""
     test_string = 'netspeed 150000000'
     expected_result = {
         'master_list': [
             {'addr': 'master_recon_border_gateway', 'key_id': '"My_Secret_Company_Key"'}
         ]
     }
     assertParserResultDictFalse(masters_element_series, test_string, expected_result)
Ejemplo n.º 5
0
    def test_isc_clause_options_version_passing(self):
        # assertParserResultDictTrue(options_stmt_version, 'version 1.0.15;', {'version_string': '1.0.15'})
        assertParserResultDictTrue(options_stmt_version, 'version "1.0.15";', {'version_string': '"1.0.15"'})
        assertParserResultDictTrue(options_stmt_version, "version '1.0.15';", {'version_string': '\'1.0.15\''})

        # Multiline test
        print("\nMulti-line tests:")

        assertParserResultDictFalse(options_stmt_version, "version = '1.0.15';", {})
Ejemplo n.º 6
0
 def test_isc_clause_logging_logging_stmt_category_failing(self):
     """ Clause logging; Statement Category; failing mode """
     test_string = 'category k l { b; c; d; };'
     expected_result = {
         'category_group': {
             'categories': ['b', 'c', 'd'],
             'category_group_name': 'k'}}
     assertParserResultDictFalse(logging_stmt_category_set,
                                 test_string,
                                 expected_result)
Ejemplo n.º 7
0
 def test_isc_logging_clause_stmt_failing(self):
     """ Clause logging; Statement Logging; failing mode """
     test_string = 'logging { channel cb { files "/tmp/x" size 30M; severity info; print-time yes;}; };'
     expected_result = {}
     assertParserResultDictFalse(clause_stmt_logging_standalone,
                                 test_string,
                                 expected_result)
     test_string = 'logging { channel trucker { file "/tmp/x" size 30M; print__ime yes; severity info;}; };'
     expected_result = {}
     assertParserResultDictFalse(clause_stmt_logging_standalone,
                                 test_string,
                                 expected_result)
Ejemplo n.º 8
0
 def test_isc_logging_stmt_channel_failing(self):
     """ Clause logging; Statement Channel; failing mode """
     test_string = 'channel bl eep { file "/tmp/x" size 38M; severity warning;};'
     expected_result = {
         'channel': {
             'channel_name': 'bl',
             'channel_name2': 'eep',
             'path_name': '"/tmp/x"',
             'severity': 'warning',
             'size_spec': [38, 'M']}}
     assertParserResultDictFalse(logging_stmt_channel_set,
                                 test_string,
                                 expected_result)
Ejemplo n.º 9
0
 def test_isc_zone_statements_series_multiple_masters_passing(self):
     """ Clause zone; Statement, multiple masters; passing """
     # Only one masters statement is allowed in zone clause, so get the last one
     assertParserResultDictFalse(
         zone_statements_series,
         'masters dmz_masters port 7552 dscp 5 { yellow_masters key priv_dns_chan_key5; }; ' +
         'masters bastion_hosts port 1024 dscp 6 { fe08::1 port 77; };',
         {'masters': [{'dscp_port': 6,
                       'ip_port': 1025,
                       'master_id': 'bastion_hosts',
                       'master_list': [{'addr': 'fe08::1',
                                        'ip_port': 77}]}]}
     )
Ejemplo n.º 10
0
 def test_isc_masters_name_failing(self):
     """ Clause masters; Series Master Name; failing mode """
     test_data = [
         'route,net;',
         'bad host',
         'no such;',
     ]
     expected_result = {'master_id': '2.2.2.2'}
     assertParserResultDictFalse(master_id, 'route.net;', expected_result)
     assertParserResultDictFalse(master_id, 'bad host', expected_result)
     assertParserResultDictFalse(master_id, 'no such;', expected_result)
Ejemplo n.º 11
0
 def test_isc_logging_chan_print_time_element_failing(self):
     """ Clause logging; Element Channel Print Time; failing mode """
     test_string = 'print-time off;'
     expected_result = {'print_time': 'off'}
     assertParserResultDictFalse(logging_chan_print_time_element,
                                 test_string,
                                 expected_result)
     test_string = 'print-time zero;'
     expected_result = {'print_time': 'zero'}
     assertParserResultDictFalse(logging_chan_print_time_element,
                                 test_string,
                                 expected_result)
     test_string = 'print-time none;'
     expected_result = {'print_time': 'none'}
     assertParserResultDictFalse(logging_chan_print_time_element,
                                 test_string,
                                 expected_result)
     test_string = 'print-time iso8601-est;'
     expected_result = {'print_time': 'iso8601-est'}
     assertParserResultDictFalse(logging_chan_print_time_element,
                                 test_string,
                                 expected_result)
Ejemplo n.º 12
0
 def test_isc_logging_chan_file_path_size_element_failing(self):
     """ Clause logging; Element File path size; failing mode """
     test_string = 'size 15x'
     expected_result = {'size_spec': [15, 'x']}
     assertParserResultDictFalse(logging_chan_file_path_size_element,
                                 test_string,
                                 expected_result, '"x" is not a valid size legend')
     test_string = 'size 32kilo'
     expected_result = {'size_spec': [32, ' kilo']}
     assertParserResultDictFalse(logging_chan_file_path_size_element,
                                 test_string,
                                 expected_result, '"kilo" is not a valid size legend')
     test_string = 'size 65mega'
     expected_result = {'size_spec': [65, 'mega']}
     assertParserResultDictFalse(logging_chan_file_path_size_element,
                                 test_string,
                                 expected_result, '"mega" s not a valid size legend')
     test_string = 'size 128 mega'
     expected_result = {'size_spec': [128, 'mega']}
     assertParserResultDictFalse(logging_chan_file_path_size_element,
                                 test_string,
                                 expected_result, '"mega" is not a valid size legend')
Ejemplo n.º 13
0
 def test_isc_logging_chan_method_element_failing(self):
     """ Clause logging; Element Channel Method; failing mode """
     test_string = 'files /tmp/x size 30M; severity ludicrous; print-time yes;}; };'
     expected_result = {'files': 'local0'}
     assertParserResultDictFalse(logging_chan_method_element,
                                 test_string,
                                 expected_result)
     test_string = 'syslog hacked;'
     expected_result = {'facility': 'hacked'}
     assertParserResultDictFalse(logging_chan_method_element,
                                 test_string,
                                 expected_result)
     test_string = 'syslog warning;'
     expected_result = {'facility': 'warning'}
     assertParserResultDictFalse(logging_chan_method_element,
                                 test_string,
                                 expected_result)
Ejemplo n.º 14
0
 def test_isc_logging_chan_severity_element_failing(self):
     """ Clause logging; Element Channel Severity; failing mode """
     test_data = [
     ]
     test_string = 'severity warn;'
     expected_result = {'severity': ['warn']}
     assertParserResultDictFalse(logging_chan_syslog_severity_element,
                                 test_string,
                                 expected_result)
     test_string = 'severity debug high;'
     expected_result = {'severity': {'debug': ['high']}}
     assertParserResultDictFalse(logging_chan_syslog_severity_element,
                                 test_string,
                                 expected_result)
     test_string = 'severity dire_emergency;'
     expected_result = {'severity': ['dire_emergency']}
     assertParserResultDictFalse(logging_chan_syslog_severity_element,
                                 test_string,
                                 expected_result)
     test_string = 'severity debug on;'
     expected_result = {'severity': {'debug': ['on']}}
     assertParserResultDictFalse(logging_chan_syslog_severity_element,
                                 test_string,
                                 expected_result)
Ejemplo n.º 15
0
 def test_isc_logging_chan_file_path_element_failing(self):
     """ Clause logging; Element File path; failing mode """
     test_string = 'file "/control_r\rsubdir/unquoted-key_id"'
     expected_result = {'path_name': '"/control_r\rsubdir/unquoted-key_id"'}
     assertParserResultDictFalse(logging_chan_file_path_element,
                                test_string,
                                expected_result, 'did not detect missing semicolon')
     test_string = 'file /control_b\bsubdir/unquoted-key_id'
     expected_result = {'path_name': '/control_b\bsubdir/unquoted-key_id'}
     assertParserResultDictFalse(logging_chan_file_path_element,
                                test_string,
                                expected_result, 'did not detect missing semicolon')
     test_string = 'file /gappy subdir/unquoted-key_id'
     expected_result = {'path_name': '/gappy subdir/unquoted-key_id'}
     assertParserResultDictFalse(logging_chan_file_path_element,
                                test_string,
                                expected_result, 'did not detect missing semicolon')
Ejemplo n.º 16
0
 def test_isc_logging_chan_file_path_version_element_failing(self):
     """ Clause logging; Element File path version; failing mode """
     test_string = 'version A;'
     expected_result = {}
     assertParserResultDictFalse(logging_chan_file_path_version_element,
                                 test_string,
                                 expected_result, 'Alpha characters are not valid file versions')
     test_string = 'version limited;'
     expected_result = {}
     assertParserResultDictFalse(logging_chan_file_path_version_element,
                                 test_string,
                                 expected_result, 'literal "limited" is not a valid value')
     test_string = 'version not-limited'
     expected_result = {}
     assertParserResultDictFalse(logging_chan_file_path_version_element,
                                 test_string,
                                 expected_result, 'did not detect missing semicolon')
Ejemplo n.º 17
0
 def test_isc_logging_chan_print_category_element_failing(self):
     """ Clause logging; Element Channel Print Category; failing mode """
     test_data = [
     ]
     test_string = 'print_category yes;'  # underscore used instead of an hyphen
     expected_result = {'print_category': 'False'}
     assertParserResultDictFalse(logging_chan_print_category_element,
                                 test_string,
                                 expected_result)
     test_string = 'print category yes;'  # missing hyphen
     expected_result = {'print_category': 'False'}
     assertParserResultDictFalse(logging_chan_print_category_element,
                                 test_string,
                                 expected_result)
     test_string = 'print-categories yes'  # plural form used instead of singular
     expected_result = {'print_category': 'False'}
     assertParserResultDictFalse(logging_chan_print_category_element,
                                 test_string,
                                 expected_result)
Ejemplo n.º 18
0
 def test_isc_master_name_failing(self):
     """Masters clause, Master Name type, purposely failing mode"""
     test_string = 'netspeed 150000000'
     expected_result = {'master_id': 'netspeed'}
     assertParserResultDictFalse(master_id, test_string, expected_result)
Ejemplo n.º 19
0
 def test_isc_optzone_stmt_statements_set_failing(self):
     assertParserResultDictFalse(optzone_statements_set,
                                 'notify-to-soa wrong;',
                                 {'notify_to_soa': 'wrong'})
 def test_isc_clause_stmt_managed_keys_failing(self):
     """ Clause managed-keys; purposely failing mode"""
     test_string = 'managed-keys { . initial-key 257 3 3 "AAAAAAAAA+BBBBBBBBBBBBB/CCXCCCCCCCCCCCCC";};'
     expected_result = {}
     assertParserResultDictFalse(clause_stmt_managed_keys_series,
                                 test_string, expected_result)
Ejemplo n.º 21
0
 def test_isc_inet_port_high_failing(self):
     """INET clause; ip_port element; highest value; failing mode"""
     assertParserResultDictFalse(ip_port, '65536', {'ip_port': '65536'})
Ejemplo n.º 22
0
 def test_isc_inet_port_low_failing(self):
     """INET clause; ip_port element; lowest value; failing mode"""
     assertParserResultDictFalse(ip_port, '0', {'ip_port': '0'})
Ejemplo n.º 23
0
 def test_isc_inet_port_element_wildcard_high_failing(self):
     """INET clause; port element; wildcard; failing"""
     assertParserResultDictFalse(inet_ip_port_keyword_and_wildcard_element,
                                 'port x', {'ip_port_w': '*'})
Ejemplo n.º 24
0
 def test_isc_inet_port_element_high_failing(self):
     """INET clause; port element; high failing"""
     assertParserResultDictFalse(inet_ip_port_keyword_and_number_element,
                                 'port 65536', {'ip_port': '65536'})
Ejemplo n.º 25
0
 def test_isc_inet_port_element_low_failing(self):
     """INET clause; port element; low; failing"""
     assertParserResultDictFalse(inet_ip_port_keyword_and_number_element,
                                 'port 0', {'ip_port': '0'})