Best Python code snippet using molecule_python
test_managed_keys.py
Source:test_managed_keys.py
1#!/usr/bin/env python32"""3File: test_managed_keys.py4Clause: view, managed-keys5Statement: managed-keys6Description: Performs unit test on the isc_managed_keys.py source file.7 The managed-keys statement used by either by:8 * 'view' clause as a statement or9 * top-level 'managed-keys' clause.10"""11import unittest12from bind9_parser.isc_utils import assert_parser_result_dict_true, assert_parser_result_dict_false13from bind9_parser.isc_managed_keys import managed_keyname_type,\14 managed_keyname_dquoted, managed_keyname_squoted,\15 managed_key_domain_name, managed_key_type,\16 managed_key_flags_type, managed_key_protocol_type,\17 managed_key_algorithm_name, managed_key_algorithm_type,\18 managed_key_secret_type, managed_keys_set,\19 managed_keys_series, managed_keys_statement_standalone,\20 quoted_managed_key_secret_type21class TestManagedKeys(unittest.TestCase):22 """ Statement managed-keys; used by view or managed-keys clause """23 def test_isc_managed_keys_domain_name_passing(self):24 """ Statement managed-keys; Type Domain Name; passing mode """25 test_data = [26 'key_name1',27 'unquoted-key_id2',28 "'squoted-key_id3'",29 '"dquoted-key_id4"',30 ]31 result = managed_key_domain_name.runTests(test_data, failureTests=False)32 self.assertTrue(result[0])33 def test_isc_managed_keys_domain_name_failing(self):34 """ Statement managed-keys; Type Domain Name; failing mode """35 test_data = [36 'country us',37 ]38 result = managed_key_domain_name.runTests(test_data, failureTests=True)39 self.assertTrue(result[0])40 def test_isc_managed_keys_algorithm_name_passing(self):41 """ Statement managed-keys; algorithm name; passing mode"""42 test_data = [43 'aABCDEFG',44 'hmac-md5',45 'hmac-sha512',46 'hmac-sha4096',47 ]48 result = managed_key_algorithm_name.runTests(49 test_data,50 failureTests=False51 )52 self.assertTrue(result[0])53 def test_isc_managed_keys_algorithm_name_failing(self):54 """ Statement managed-keys; algorithm name; failing mode"""55 test_data = [56 'aAB&DEFG',57 '\'aABDEFG',58 'aABDEFG\'',59 '"aABDEFG',60 'aABDEFG"',61 'bad*algorithm;',62 ]63 result = managed_key_algorithm_name.runTests(64 test_data,65 failureTests=True66 )67 self.assertTrue(result[0])68 # domain name, flags, protocol, algorithm, and the Base64 representation of the69 # key data.70 def test_isc_managed_keys_series_passing(self):71 """ Statement managed-keys; managed keys series; passing mode """72 test_data = [73 'abc initial-key 1 1 1 "ASBASDASD";',74 'abc initial-key 1 1 1 "ASBASDASD"; def initial-key 243 16 7 "LKJOULKJOIULKKJ+ASD";',75 ]76 result = managed_keys_series.runTests(77 test_data,78 failureTests=False79 )80 self.assertTrue(result[0])81 def test_isc_managed_keys_series_failing(self):82 """ Statement managed-keys; managed keys series, failing mode """83 test_data = [84 'abc initial-key X Y Z ASBASDASD;',85 ]86 result = managed_keys_series.runTests(87 test_data,88 failureTests=True89 )90 self.assertTrue(result[0])91 def test_isc_managed_keys_statement_set_passing(self):92 """ Statement managed-keys; passing mode """93 test_data = [94 'managed-keys { abc initial-key 1 1 1 "ASBASDASD";};',95 'managed-keys { example.com initial-key 1 1 1 "ASBASDASD";};',96 'managed-keys { www.example.com initial-key 1 1 1 "ASBASDASD";};',97 'managed-keys { www1.www.example.com initial-key 1 1 1 "ASBASDASD";};',98 'managed-keys { www1.www.example.com initial-key 1 1 1 "ASBASDASD";};',99 'managed-keys { "." initial-key 257 3 3 "AAAAAAAAA+BBBBBBBBBBBBB/CCXCCCCCCCCCCCCC";};',100 "managed-keys { \".\" initial-key 257 3 3 'AAAAAAAAA+BBBBBBBBBBBBB/CCXCCCCCCCCCCCCC';};",101 'managed-keys { "." initial-key 257 3 3 "AAAAAAAAA+BBBBBBBBBBBBB/CCXCCCCCCCCCCCCC";};',102 ]103 result = managed_keys_statement_standalone.runTests(104 test_data,105 failureTests=False106 )107 self.assertTrue(result[0])108 def test_isc_managed_keys_statement_set_failing(self):109 """ Statement managed-keys; failing mode """110 test_data = [111 'managed-keys { . initial_key 257 3 3 AAAAAAAAA+BBBBBBBBBBBBB/CCXCCCCCCCCCCCCC;};',112 ]113 result = managed_keys_statement_standalone.runTests(114 test_data,115 failureTests=True116 )117 self.assertTrue(result[0])118if __name__ == '__main__':...
isc_managed_keys.py
Source:isc_managed_keys.py
1#!/usr/bin/env python32"""3File: isc_managed_keys.py4Clause: managed-keys5Title: Clause statement for managed keys6Description: Provides managed-key-related grammar in7 PyParsing engine for ISC-configuration style8"""9from pyparsing import Word, alphanums, Group, Keyword, Literal, OneOrMore10from bind9_parser.isc_utils import semicolon, lbrack, rbrack, number_type,\11 squote, dquote, Combine12from bind9_parser.isc_rr import rr_domain_name_or_root13managed_keyname_type = rr_domain_name_or_root14managed_keyname_type.setName('keyname_base')15managed_keyname_dquoted = Combine(16 Literal('"')17 - managed_keyname_type18 + Literal('"')19)20# keyname_dquoted.setName('keyname_dquoted')21managed_keyname_squoted = Combine(22 Literal("'")23 - managed_keyname_type24 + Literal("'")25)('key_id')26# keyname_dquoted.setName('keyname_squoted')27managed_key_domain_name = (28 managed_keyname_dquoted29 | managed_keyname_squoted30 | managed_keyname_type31)('rr_domain')32managed_key_type = Keyword('initial-key') # Future will have multiple options33managed_key_flags_type = number_type('flags')34managed_key_flags_type.setName('<key-flags-id>')35managed_key_protocol_type = number_type('protocol_id')36managed_key_protocol_type.setName('<key-protocol-id>')37managed_key_algorithm_name = Word(alphanums + '-')('algorithm_type')38managed_key_algorithm_name.setName('<key-algorithm>')39managed_key_algorithm_type = number_type('algorithm_id')40managed_key_algorithm_type.setName('<key-algorithm-id>')41# Secret are in base64 encoding scheme with 2-char paddings (RFC 1421)42# Handles up to 16K encoding43charset_key_secret_base = ' \n\r\tABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='44charset_key_secret_base_squote_allowed = charset_key_secret_base + "'"45charset_key_secret_base_dquote_allowed = charset_key_secret_base + '"'46managed_key_secret_type = (47 Combine(squote + Word(charset_key_secret_base_dquote_allowed) + squote)48 | Combine(dquote + Word(charset_key_secret_base_squote_allowed) + dquote)49 | Word(charset_key_secret_base)50)('key_secret')51managed_key_secret_type.setName('<key-secret>')52quoted_managed_key_secret_type = (53 Combine(squote + Word(charset_key_secret_base_dquote_allowed) + squote)54 | Combine(dquote + Word(charset_key_secret_base_squote_allowed) + dquote)55)('quoted_key_secret')56# domain name, flags, protocol, algorithm, and the Base64 representation of the57# key data.58managed_keys_set = (59 managed_key_domain_name60 + Keyword('initial-key').suppress()61 - managed_key_flags_type62 - managed_key_protocol_type63 - managed_key_algorithm_type64 - quoted_managed_key_secret_type('key_secret')65 + semicolon66)67managed_keys_series = (68 OneOrMore(managed_keys_set)('')69)70# key <key-name> { algorithm <string>; secret <key-secret>; };71managed_keys_statement_standalone = (72 Keyword('managed-keys').suppress()73 - Group(74 lbrack75 + managed_keys_series76 + rbrack77 )78 + semicolon...
miscellaneous.py
Source:miscellaneous.py
1from django.db import models23#4#5#6class Miscellaneous(models.Model):78 #NOT_MANAGED: configuration_includes_quoted_values9 #NOT_MANAGED: memory_pools10 #NOT_MANAGED: memory_pools_limit11 #NOT_MANAGED: cachemgr_passwd12 #NOT_MANAGED: client_db13 #NOT_MANAGED: refresh_all_ims14 #NOT_MANAGED: reload_into_ims15 #NOT_MANAGED: connect_retries16 #NOT_MANAGED: retry_on_error17 #NOT_MANAGED: as_whois_server18 #NOT_MANAGED: offline_mode19 #NOT_MANAGED: uri_whitespace20 #NOT_MANAGED: chroot21 #NOT_MANAGED: balance_on_multiple_ip22 #NOT_MANAGED: pipeline_prefetch23 #NOT_MANAGED: high_response_time_warning24 #NOT_MANAGED: high_page_fault_warning25 #NOT_MANAGED: high_memory_warning26 #NOT_MANAGED: sleep_after_fork27 #NOT_MANAGED: windows_ipaddrchangemonitor28 #NOT_MANAGED: eui_lookup29 #NOT_MANAGED: max_filedescriptors3031 # forwarded_for configuration32 FORWARDED_FOR_OFF = 033 FORWARDED_FOR_ON = 134 FORWARDED_FOR_TRANSPARENT = 235 FORWARDED_FOR_TRUNCATE = 336 FORWARDED_FOR_DELETE = 437 FORWARDED_FOR_CHOICES = (38 (FORWARDED_FOR_OFF, "off"), 39 (FORWARDED_FOR_ON, "on (default)"), 40 (FORWARDED_FOR_TRANSPARENT, "transparent"),41 (FORWARDED_FOR_TRUNCATE, "truncate"),42 (FORWARDED_FOR_DELETE, "delete"),43 )44
...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!