From de2580a23fa2d240153da0c55406c7be96f4d164 Mon Sep 17 00:00:00 2001 From: itdependsnetworks Date: Wed, 12 Oct 2022 22:48:59 -0400 Subject: [PATCH] Update testing mock strategy --- .../arista_eos/eos_full_received.py | 0 .../{ => base}/arista_eos/eos_full_sent.txt | 0 .../bigip_f5/bigip_full_received.py | 0 .../{ => base}/bigip_f5/bigip_full_sent.txt | 0 .../cisco_aireos/aireos_full_received.py | 0 .../cisco_aireos/aireos_full_sent.txt | 0 .../{ => base}/cisco_asa/asa_full_received.py | 0 .../{ => base}/cisco_asa/asa_full_sent.txt | 0 .../{ => base}/cisco_ios/ios_full_received.py | 0 .../{ => base}/cisco_ios/ios_full_sent.txt | 0 .../cisco_nxos/nxos_full_received.py | 0 .../{ => base}/cisco_nxos/nxos_full_sent.txt | 0 .../fortinet_fortios/fortios_full_received.py | 0 .../fortinet_fortios/fortios_full_sent.txt | 0 .../juniper_junos/junos_full_received.py | 0 .../juniper_junos/junos_full_sent.txt | 0 .../nokia_sros/sros_baseconfig_received.py | 0 .../nokia_sros/sros_baseconfig_sent.txt | 0 .../nokia_sros/sros_full_received.py | 0 .../{ => base}/nokia_sros/sros_full_sent.txt | 0 .../cisco_ios/ios_full_args.json | 4 + .../cisco_ios/ios_full_received.txt | 5 + .../cisco_ios/ios_full_sent.txt} | 52 +++ .../cisco_ios/ios_re_args.json | 4 + .../cisco_ios/ios_re_received.txt | 5 + .../cisco_ios/ios_re_sent.txt | 331 ++++++++++++++++++ .../cisco_ios/ios_starts_args.json | 4 + .../cisco_ios/ios_starts_received.txt | 5 + .../cisco_ios/ios_starts_sent.txt | 331 ++++++++++++++++++ .../find_children/cisco_ios/certificate.txt | 14 - .../find_children/cisco_ios/interface.txt | 24 -- .../cisco_ios/ios_full_args.json | 5 + .../cisco_ios/ios_full_received.txt | 4 + .../cisco_ios/ios_full_sent.txt | 331 ++++++++++++++++++ tests/unit/test_parser.py | 92 ++--- 35 files changed, 1116 insertions(+), 95 deletions(-) rename tests/unit/mock/config/parser/{ => base}/arista_eos/eos_full_received.py (100%) rename tests/unit/mock/config/parser/{ => base}/arista_eos/eos_full_sent.txt (100%) rename tests/unit/mock/config/parser/{ => base}/bigip_f5/bigip_full_received.py (100%) rename tests/unit/mock/config/parser/{ => base}/bigip_f5/bigip_full_sent.txt (100%) rename tests/unit/mock/config/parser/{ => base}/cisco_aireos/aireos_full_received.py (100%) rename tests/unit/mock/config/parser/{ => base}/cisco_aireos/aireos_full_sent.txt (100%) rename tests/unit/mock/config/parser/{ => base}/cisco_asa/asa_full_received.py (100%) rename tests/unit/mock/config/parser/{ => base}/cisco_asa/asa_full_sent.txt (100%) rename tests/unit/mock/config/parser/{ => base}/cisco_ios/ios_full_received.py (100%) rename tests/unit/mock/config/parser/{ => base}/cisco_ios/ios_full_sent.txt (100%) rename tests/unit/mock/config/parser/{ => base}/cisco_nxos/nxos_full_received.py (100%) rename tests/unit/mock/config/parser/{ => base}/cisco_nxos/nxos_full_sent.txt (100%) rename tests/unit/mock/config/parser/{ => base}/fortinet_fortios/fortios_full_received.py (100%) rename tests/unit/mock/config/parser/{ => base}/fortinet_fortios/fortios_full_sent.txt (100%) rename tests/unit/mock/config/parser/{ => base}/juniper_junos/junos_full_received.py (100%) rename tests/unit/mock/config/parser/{ => base}/juniper_junos/junos_full_sent.txt (100%) rename tests/unit/mock/config/parser/{ => base}/nokia_sros/sros_baseconfig_received.py (100%) rename tests/unit/mock/config/parser/{ => base}/nokia_sros/sros_baseconfig_sent.txt (100%) rename tests/unit/mock/config/parser/{ => base}/nokia_sros/sros_full_received.py (100%) rename tests/unit/mock/config/parser/{ => base}/nokia_sros/sros_full_sent.txt (100%) create mode 100644 tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_full_args.json create mode 100644 tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_full_received.txt rename tests/unit/mock/config/parser/{find_children/cisco_ios/full_config.txt => find_all_children/cisco_ios/ios_full_sent.txt} (58%) create mode 100644 tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_re_args.json create mode 100644 tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_re_received.txt create mode 100644 tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_re_sent.txt create mode 100644 tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_starts_args.json create mode 100644 tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_starts_received.txt create mode 100644 tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_starts_sent.txt delete mode 100644 tests/unit/mock/config/parser/find_children/cisco_ios/certificate.txt delete mode 100644 tests/unit/mock/config/parser/find_children/cisco_ios/interface.txt create mode 100644 tests/unit/mock/config/parser/find_children_w_parents/cisco_ios/ios_full_args.json create mode 100644 tests/unit/mock/config/parser/find_children_w_parents/cisco_ios/ios_full_received.txt create mode 100644 tests/unit/mock/config/parser/find_children_w_parents/cisco_ios/ios_full_sent.txt diff --git a/tests/unit/mock/config/parser/arista_eos/eos_full_received.py b/tests/unit/mock/config/parser/base/arista_eos/eos_full_received.py similarity index 100% rename from tests/unit/mock/config/parser/arista_eos/eos_full_received.py rename to tests/unit/mock/config/parser/base/arista_eos/eos_full_received.py diff --git a/tests/unit/mock/config/parser/arista_eos/eos_full_sent.txt b/tests/unit/mock/config/parser/base/arista_eos/eos_full_sent.txt similarity index 100% rename from tests/unit/mock/config/parser/arista_eos/eos_full_sent.txt rename to tests/unit/mock/config/parser/base/arista_eos/eos_full_sent.txt diff --git a/tests/unit/mock/config/parser/bigip_f5/bigip_full_received.py b/tests/unit/mock/config/parser/base/bigip_f5/bigip_full_received.py similarity index 100% rename from tests/unit/mock/config/parser/bigip_f5/bigip_full_received.py rename to tests/unit/mock/config/parser/base/bigip_f5/bigip_full_received.py diff --git a/tests/unit/mock/config/parser/bigip_f5/bigip_full_sent.txt b/tests/unit/mock/config/parser/base/bigip_f5/bigip_full_sent.txt similarity index 100% rename from tests/unit/mock/config/parser/bigip_f5/bigip_full_sent.txt rename to tests/unit/mock/config/parser/base/bigip_f5/bigip_full_sent.txt diff --git a/tests/unit/mock/config/parser/cisco_aireos/aireos_full_received.py b/tests/unit/mock/config/parser/base/cisco_aireos/aireos_full_received.py similarity index 100% rename from tests/unit/mock/config/parser/cisco_aireos/aireos_full_received.py rename to tests/unit/mock/config/parser/base/cisco_aireos/aireos_full_received.py diff --git a/tests/unit/mock/config/parser/cisco_aireos/aireos_full_sent.txt b/tests/unit/mock/config/parser/base/cisco_aireos/aireos_full_sent.txt similarity index 100% rename from tests/unit/mock/config/parser/cisco_aireos/aireos_full_sent.txt rename to tests/unit/mock/config/parser/base/cisco_aireos/aireos_full_sent.txt diff --git a/tests/unit/mock/config/parser/cisco_asa/asa_full_received.py b/tests/unit/mock/config/parser/base/cisco_asa/asa_full_received.py similarity index 100% rename from tests/unit/mock/config/parser/cisco_asa/asa_full_received.py rename to tests/unit/mock/config/parser/base/cisco_asa/asa_full_received.py diff --git a/tests/unit/mock/config/parser/cisco_asa/asa_full_sent.txt b/tests/unit/mock/config/parser/base/cisco_asa/asa_full_sent.txt similarity index 100% rename from tests/unit/mock/config/parser/cisco_asa/asa_full_sent.txt rename to tests/unit/mock/config/parser/base/cisco_asa/asa_full_sent.txt diff --git a/tests/unit/mock/config/parser/cisco_ios/ios_full_received.py b/tests/unit/mock/config/parser/base/cisco_ios/ios_full_received.py similarity index 100% rename from tests/unit/mock/config/parser/cisco_ios/ios_full_received.py rename to tests/unit/mock/config/parser/base/cisco_ios/ios_full_received.py diff --git a/tests/unit/mock/config/parser/cisco_ios/ios_full_sent.txt b/tests/unit/mock/config/parser/base/cisco_ios/ios_full_sent.txt similarity index 100% rename from tests/unit/mock/config/parser/cisco_ios/ios_full_sent.txt rename to tests/unit/mock/config/parser/base/cisco_ios/ios_full_sent.txt diff --git a/tests/unit/mock/config/parser/cisco_nxos/nxos_full_received.py b/tests/unit/mock/config/parser/base/cisco_nxos/nxos_full_received.py similarity index 100% rename from tests/unit/mock/config/parser/cisco_nxos/nxos_full_received.py rename to tests/unit/mock/config/parser/base/cisco_nxos/nxos_full_received.py diff --git a/tests/unit/mock/config/parser/cisco_nxos/nxos_full_sent.txt b/tests/unit/mock/config/parser/base/cisco_nxos/nxos_full_sent.txt similarity index 100% rename from tests/unit/mock/config/parser/cisco_nxos/nxos_full_sent.txt rename to tests/unit/mock/config/parser/base/cisco_nxos/nxos_full_sent.txt diff --git a/tests/unit/mock/config/parser/fortinet_fortios/fortios_full_received.py b/tests/unit/mock/config/parser/base/fortinet_fortios/fortios_full_received.py similarity index 100% rename from tests/unit/mock/config/parser/fortinet_fortios/fortios_full_received.py rename to tests/unit/mock/config/parser/base/fortinet_fortios/fortios_full_received.py diff --git a/tests/unit/mock/config/parser/fortinet_fortios/fortios_full_sent.txt b/tests/unit/mock/config/parser/base/fortinet_fortios/fortios_full_sent.txt similarity index 100% rename from tests/unit/mock/config/parser/fortinet_fortios/fortios_full_sent.txt rename to tests/unit/mock/config/parser/base/fortinet_fortios/fortios_full_sent.txt diff --git a/tests/unit/mock/config/parser/juniper_junos/junos_full_received.py b/tests/unit/mock/config/parser/base/juniper_junos/junos_full_received.py similarity index 100% rename from tests/unit/mock/config/parser/juniper_junos/junos_full_received.py rename to tests/unit/mock/config/parser/base/juniper_junos/junos_full_received.py diff --git a/tests/unit/mock/config/parser/juniper_junos/junos_full_sent.txt b/tests/unit/mock/config/parser/base/juniper_junos/junos_full_sent.txt similarity index 100% rename from tests/unit/mock/config/parser/juniper_junos/junos_full_sent.txt rename to tests/unit/mock/config/parser/base/juniper_junos/junos_full_sent.txt diff --git a/tests/unit/mock/config/parser/nokia_sros/sros_baseconfig_received.py b/tests/unit/mock/config/parser/base/nokia_sros/sros_baseconfig_received.py similarity index 100% rename from tests/unit/mock/config/parser/nokia_sros/sros_baseconfig_received.py rename to tests/unit/mock/config/parser/base/nokia_sros/sros_baseconfig_received.py diff --git a/tests/unit/mock/config/parser/nokia_sros/sros_baseconfig_sent.txt b/tests/unit/mock/config/parser/base/nokia_sros/sros_baseconfig_sent.txt similarity index 100% rename from tests/unit/mock/config/parser/nokia_sros/sros_baseconfig_sent.txt rename to tests/unit/mock/config/parser/base/nokia_sros/sros_baseconfig_sent.txt diff --git a/tests/unit/mock/config/parser/nokia_sros/sros_full_received.py b/tests/unit/mock/config/parser/base/nokia_sros/sros_full_received.py similarity index 100% rename from tests/unit/mock/config/parser/nokia_sros/sros_full_received.py rename to tests/unit/mock/config/parser/base/nokia_sros/sros_full_received.py diff --git a/tests/unit/mock/config/parser/nokia_sros/sros_full_sent.txt b/tests/unit/mock/config/parser/base/nokia_sros/sros_full_sent.txt similarity index 100% rename from tests/unit/mock/config/parser/nokia_sros/sros_full_sent.txt rename to tests/unit/mock/config/parser/base/nokia_sros/sros_full_sent.txt diff --git a/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_full_args.json b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_full_args.json new file mode 100644 index 00000000..cff02403 --- /dev/null +++ b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_full_args.json @@ -0,0 +1,4 @@ +{ + "pattern": "call-home", + "match_type": "exact" +} \ No newline at end of file diff --git a/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_full_received.txt b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_full_received.txt new file mode 100644 index 00000000..6535ea88 --- /dev/null +++ b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_full_received.txt @@ -0,0 +1,5 @@ +call-home + contact-email-addr sch-smart-licensing@cisco.com + profile "CiscoTAC-1" + active + destination transport-method http \ No newline at end of file diff --git a/tests/unit/mock/config/parser/find_children/cisco_ios/full_config.txt b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_full_sent.txt similarity index 58% rename from tests/unit/mock/config/parser/find_children/cisco_ios/full_config.txt rename to tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_full_sent.txt index c5776a40..d6932d4b 100644 --- a/tests/unit/mock/config/parser/find_children/cisco_ios/full_config.txt +++ b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_full_sent.txt @@ -88,9 +88,61 @@ crypto pki trustpoint SLA-TrustPoint ! crypto pki certificate chain TP-self-signed-1088426642 certificate self-signed 01 + 30820330 30820218 A0030201 02020101 300D0609 2A864886 F70D0101 05050030 + 31312F30 2D060355 04031326 494F532D 53656C66 2D536967 6E65642D 43657274 + 69666963 6174652D 31303838 34323636 3432301E 170D3231 30333039 30333233 + 30325A17 0D333030 31303130 30303030 305A3031 312F302D 06035504 03132649 + 4F532D53 656C662D 5369676E 65642D43 65727469 66696361 74652D31 30383834 + 32363634 32308201 22300D06 092A8648 86F70D01 01010500 0382010F 00308201 + 0A028201 0100E61B 372A60D2 0A1D58E3 0EC5CEBD 1EA5BF18 3F6BF297 2162DB79 + ECBF511A 8B14DF23 35EEF4A8 E219B625 E5ED6575 EAD5914A 905E07A2 C2298199 + D143673A 13C6212A 5A2C034F C250F52F F1187F51 0F003B7F 23642CAE 00A1413C + 270D4E53 55E7EDB4 1A7B69B6 4EB4B5E7 12ACA95C 07F22B02 80C65739 25C09B82 + 788C4DC2 9729D9DB F0471C13 E2082BDA 3C525850 56684AEF FCE2C18B 1A042FC1 + 20D1403B 837AA3EB D91F6055 0F5FFFE3 E7A9D3C8 09C454C0 CC2E793E B28B60CB + 3428B6FD 28280899 90E4D168 57AA9005 2FC602B9 D40BCD5E 6AD97F2D 986B1A90 + F76DE19B 870223D0 86093C37 62D81873 968EC939 53BA36D6 61650732 0124089F + 7B9445D8 8EF90203 010001A3 53305130 0F060355 1D130101 FF040530 030101FF + 301F0603 551D2304 18301680 1419973D 5607ACE0 D2127B39 A1F6AC00 2C7216A8 + F4301D06 03551D0E 04160414 19973D56 07ACE0D2 127B39A1 F6AC002C 7216A8F4 + 300D0609 2A864886 F70D0101 05050003 82010100 0D01C4E1 544034EE F516AB65 + 9DB7D85D EC3CC16F E1BCD286 3C7F351F D86F3B9B D17EC2BA 75B597E9 F2E3C0A7 + D4FFF39F F5152741 F0551772 135243FA 458E3F8B 77832597 1E18656E 3AA732BD + 40F899EA 16969EB1 15D8656E 12E57B7A BD7221E6 BAF7D210 2B2E601C 7D047BBA + B5F736A4 4969D25B 8C3B2D80 1DB93EC2 80C021E7 A8045D05 3D775D18 ECC4A82A + 158B85E7 89C03B6D 7D46BF23 0DC1684C 98F1E82D 898A56C6 A2442C46 15EC810B + 80148784 767C8EE1 5F37AA98 57306ABB 0FF717AB E42D2949 346D867D A619CAC1 + 24AD8BB1 7696E51B 2E1BA9E8 5883E396 FE8C8DB3 96636DF0 3E963FFC 749EF8D4 + 3C1D27CD 60B9C28E 5A32B0B7 76E74DB4 48D752EB quit crypto pki certificate chain SLA-TrustPoint certificate ca 01 + 30820321 30820209 A0030201 02020101 300D0609 2A864886 F70D0101 0B050030 + 32310E30 0C060355 040A1305 43697363 6F312030 1E060355 04031317 43697363 + 6F204C69 63656E73 696E6720 526F6F74 20434130 1E170D31 33303533 30313934 + 3834375A 170D3338 30353330 31393438 34375A30 32310E30 0C060355 040A1305 + 43697363 6F312030 1E060355 04031317 43697363 6F204C69 63656E73 696E6720 + 526F6F74 20434130 82012230 0D06092A 864886F7 0D010101 05000382 010F0030 + 82010A02 82010100 A6BCBD96 131E05F7 145EA72C 2CD686E6 17222EA1 F1EFF64D + CBB4C798 212AA147 C655D8D7 9471380D 8711441E 1AAF071A 9CAE6388 8A38E520 + 1C394D78 462EF239 C659F715 B98C0A59 5BBB5CBD 0CFEBEA3 700A8BF7 D8F256EE + 4AA4E80D DB6FD1C9 60B1FD18 FFC69C96 6FA68957 A2617DE7 104FDC5F EA2956AC + 7390A3EB 2B5436AD C847A2C5 DAB553EB 69A9A535 58E9F3E3 C0BD23CF 58BD7188 + 68E69491 20F320E7 948E71D7 AE3BCC84 F10684C7 4BC8E00F 539BA42B 42C68BB7 + C7479096 B4CB2D62 EA2F505D C7B062A4 6811D95B E8250FC4 5D5D5FB8 8F27D191 + C55F0D76 61F9A4CD 3D992327 A8BB03BD 4E6D7069 7CBADF8B DF5F4368 95135E44 + DFC7C6CF 04DD7FD1 02030100 01A34230 40300E06 03551D0F 0101FF04 04030201 + 06300F06 03551D13 0101FF04 05300301 01FF301D 0603551D 0E041604 1449DC85 + 4B3D31E5 1B3E6A17 606AF333 3D3B4C73 E8300D06 092A8648 86F70D01 010B0500 + 03820101 00507F24 D3932A66 86025D9F E838AE5C 6D4DF6B0 49631C78 240DA905 + 604EDCDE FF4FED2B 77FC460E CD636FDB DD44681E 3A5673AB 9093D3B1 6C9E3D8B + D98987BF E40CBD9E 1AECA0C2 2189BB5C 8FA85686 CD98B646 5575B146 8DFC66A8 + 467A3DF4 4D565700 6ADF0F0D CF835015 3C04FF7C 21E878AC 11BA9CD2 55A9232C + 7CA7B7E6 C1AF74F6 152E99B7 B1FCF9BB E973DE7F 5BDDEB86 C71E3B49 1765308B + 5FB0DA06 B92AFE7F 494E8A9E 07B85737 F3A58BE1 1A48A229 C37C1E69 39F08678 + 80DDCD16 D6BACECA EEBC7CF9 8428787B 35202CDC 60E4616A B623CDBD 230E3AFB + 418616A9 4093E049 4D10AB75 27E86F73 932E35B5 8862FDAE 0275156F 719BB2F0 + D697DF7F 28 quit ! license udi pid CSR1000V sn 9SAGBHTUEE9 diff --git a/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_re_args.json b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_re_args.json new file mode 100644 index 00000000..bc0a49b7 --- /dev/null +++ b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_re_args.json @@ -0,0 +1,4 @@ +{ + "pattern": "^call\\-*", + "match_type": "regex" +} \ No newline at end of file diff --git a/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_re_received.txt b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_re_received.txt new file mode 100644 index 00000000..6535ea88 --- /dev/null +++ b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_re_received.txt @@ -0,0 +1,5 @@ +call-home + contact-email-addr sch-smart-licensing@cisco.com + profile "CiscoTAC-1" + active + destination transport-method http \ No newline at end of file diff --git a/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_re_sent.txt b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_re_sent.txt new file mode 100644 index 00000000..d6932d4b --- /dev/null +++ b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_re_sent.txt @@ -0,0 +1,331 @@ +! +version 17.1 +service timestamps debug datetime msec +service timestamps log datetime msec +! Call-home is enabled by Smart-Licensing. +service call-home +platform qfp utilization monitor load 80 +platform punt-keepalive disable-kernel-core +platform console serial +! +hostname jcy-bb-01 +! +boot-start-marker +boot-end-marker +! +! +vrf definition MANAGEMENT + ! + address-family ipv4 + exit-address-family + ! + address-family ipv6 + exit-address-family +! +logging userinfo +! +no aaa new-model +call-home + ! If contact email address in call-home is configured as sch-smart-licensing@cisco.com + ! the email address configured in Cisco Smart License Portal will be used as contact email address to send SCH notifications. + contact-email-addr sch-smart-licensing@cisco.com + profile "CiscoTAC-1" + active + destination transport-method http +! +! +! +! +! +! +! +no ip domain lookup +ip domain name infra.ntc.com +! +! +! +login on-success log +! +! +! +! +! +! +! +subscriber templating +! +! +! +! +! +! +multilink bundle-name authenticated +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +crypto pki trustpoint TP-self-signed-1088426642 + enrollment selfsigned + subject-name cn=IOS-Self-Signed-Certificate-1088426642 + revocation-check none + rsakeypair TP-self-signed-1088426642 +! +crypto pki trustpoint SLA-TrustPoint + enrollment pkcs12 + revocation-check crl +! +! +crypto pki certificate chain TP-self-signed-1088426642 + certificate self-signed 01 + 30820330 30820218 A0030201 02020101 300D0609 2A864886 F70D0101 05050030 + 31312F30 2D060355 04031326 494F532D 53656C66 2D536967 6E65642D 43657274 + 69666963 6174652D 31303838 34323636 3432301E 170D3231 30333039 30333233 + 30325A17 0D333030 31303130 30303030 305A3031 312F302D 06035504 03132649 + 4F532D53 656C662D 5369676E 65642D43 65727469 66696361 74652D31 30383834 + 32363634 32308201 22300D06 092A8648 86F70D01 01010500 0382010F 00308201 + 0A028201 0100E61B 372A60D2 0A1D58E3 0EC5CEBD 1EA5BF18 3F6BF297 2162DB79 + ECBF511A 8B14DF23 35EEF4A8 E219B625 E5ED6575 EAD5914A 905E07A2 C2298199 + D143673A 13C6212A 5A2C034F C250F52F F1187F51 0F003B7F 23642CAE 00A1413C + 270D4E53 55E7EDB4 1A7B69B6 4EB4B5E7 12ACA95C 07F22B02 80C65739 25C09B82 + 788C4DC2 9729D9DB F0471C13 E2082BDA 3C525850 56684AEF FCE2C18B 1A042FC1 + 20D1403B 837AA3EB D91F6055 0F5FFFE3 E7A9D3C8 09C454C0 CC2E793E B28B60CB + 3428B6FD 28280899 90E4D168 57AA9005 2FC602B9 D40BCD5E 6AD97F2D 986B1A90 + F76DE19B 870223D0 86093C37 62D81873 968EC939 53BA36D6 61650732 0124089F + 7B9445D8 8EF90203 010001A3 53305130 0F060355 1D130101 FF040530 030101FF + 301F0603 551D2304 18301680 1419973D 5607ACE0 D2127B39 A1F6AC00 2C7216A8 + F4301D06 03551D0E 04160414 19973D56 07ACE0D2 127B39A1 F6AC002C 7216A8F4 + 300D0609 2A864886 F70D0101 05050003 82010100 0D01C4E1 544034EE F516AB65 + 9DB7D85D EC3CC16F E1BCD286 3C7F351F D86F3B9B D17EC2BA 75B597E9 F2E3C0A7 + D4FFF39F F5152741 F0551772 135243FA 458E3F8B 77832597 1E18656E 3AA732BD + 40F899EA 16969EB1 15D8656E 12E57B7A BD7221E6 BAF7D210 2B2E601C 7D047BBA + B5F736A4 4969D25B 8C3B2D80 1DB93EC2 80C021E7 A8045D05 3D775D18 ECC4A82A + 158B85E7 89C03B6D 7D46BF23 0DC1684C 98F1E82D 898A56C6 A2442C46 15EC810B + 80148784 767C8EE1 5F37AA98 57306ABB 0FF717AB E42D2949 346D867D A619CAC1 + 24AD8BB1 7696E51B 2E1BA9E8 5883E396 FE8C8DB3 96636DF0 3E963FFC 749EF8D4 + 3C1D27CD 60B9C28E 5A32B0B7 76E74DB4 48D752EB + quit +crypto pki certificate chain SLA-TrustPoint + certificate ca 01 + 30820321 30820209 A0030201 02020101 300D0609 2A864886 F70D0101 0B050030 + 32310E30 0C060355 040A1305 43697363 6F312030 1E060355 04031317 43697363 + 6F204C69 63656E73 696E6720 526F6F74 20434130 1E170D31 33303533 30313934 + 3834375A 170D3338 30353330 31393438 34375A30 32310E30 0C060355 040A1305 + 43697363 6F312030 1E060355 04031317 43697363 6F204C69 63656E73 696E6720 + 526F6F74 20434130 82012230 0D06092A 864886F7 0D010101 05000382 010F0030 + 82010A02 82010100 A6BCBD96 131E05F7 145EA72C 2CD686E6 17222EA1 F1EFF64D + CBB4C798 212AA147 C655D8D7 9471380D 8711441E 1AAF071A 9CAE6388 8A38E520 + 1C394D78 462EF239 C659F715 B98C0A59 5BBB5CBD 0CFEBEA3 700A8BF7 D8F256EE + 4AA4E80D DB6FD1C9 60B1FD18 FFC69C96 6FA68957 A2617DE7 104FDC5F EA2956AC + 7390A3EB 2B5436AD C847A2C5 DAB553EB 69A9A535 58E9F3E3 C0BD23CF 58BD7188 + 68E69491 20F320E7 948E71D7 AE3BCC84 F10684C7 4BC8E00F 539BA42B 42C68BB7 + C7479096 B4CB2D62 EA2F505D C7B062A4 6811D95B E8250FC4 5D5D5FB8 8F27D191 + C55F0D76 61F9A4CD 3D992327 A8BB03BD 4E6D7069 7CBADF8B DF5F4368 95135E44 + DFC7C6CF 04DD7FD1 02030100 01A34230 40300E06 03551D0F 0101FF04 04030201 + 06300F06 03551D13 0101FF04 05300301 01FF301D 0603551D 0E041604 1449DC85 + 4B3D31E5 1B3E6A17 606AF333 3D3B4C73 E8300D06 092A8648 86F70D01 010B0500 + 03820101 00507F24 D3932A66 86025D9F E838AE5C 6D4DF6B0 49631C78 240DA905 + 604EDCDE FF4FED2B 77FC460E CD636FDB DD44681E 3A5673AB 9093D3B1 6C9E3D8B + D98987BF E40CBD9E 1AECA0C2 2189BB5C 8FA85686 CD98B646 5575B146 8DFC66A8 + 467A3DF4 4D565700 6ADF0F0D CF835015 3C04FF7C 21E878AC 11BA9CD2 55A9232C + 7CA7B7E6 C1AF74F6 152E99B7 B1FCF9BB E973DE7F 5BDDEB86 C71E3B49 1765308B + 5FB0DA06 B92AFE7F 494E8A9E 07B85737 F3A58BE1 1A48A229 C37C1E69 39F08678 + 80DDCD16 D6BACECA EEBC7CF9 8428787B 35202CDC 60E4616A B623CDBD 230E3AFB + 418616A9 4093E049 4D10AB75 27E86F73 932E35B5 8862FDAE 0275156F 719BB2F0 + D697DF7F 28 + quit +! +license udi pid CSR1000V sn 9SAGBHTUEE9 +diagnostic bootup level minimal +archive + path bootflash:archive +memory free low-watermark processor 72107 +! +! +spanning-tree extend system-id +! +username ntc privilege 15 password 0 ntc123 +! +redundancy +! +! +! +! +! +lldp run +cdp run +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +interface Loopback0 + ip address 10.0.10.3 255.255.255.255 +! +interface GigabitEthernet1 + description MANAGEMENT_DO_NOT_CHANGE + ip address 10.0.0.15 255.255.255.0 + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet2 + ip address 10.10.0.6 255.255.255.252 + ip access-group BLOCK_TRANSIT_LINKS in + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet3 + ip address 10.10.0.14 255.255.255.252 + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet4 + description backbone-to-vmx3-ge0/0/3 + ip address 10.10.0.17 255.255.255.252 + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet5 + no ip address + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet6 + no ip address + shutdown + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet7 + no ip address + shutdown + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet8 + no ip address + shutdown + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet9 + no ip address + shutdown + negotiation auto + no mop enabled + no mop sysid +! +router bgp 65251 + bgp router-id 10.0.10.3 + bgp log-neighbor-changes + redistribute connected + neighbor 10.10.0.5 remote-as 65251 + neighbor 10.10.0.13 remote-as 65251 + neighbor 10.10.0.18 remote-as 65252 +! +! +virtual-service csr_mgmt +! +ip forward-protocol nd +ip http server +ip http authentication local +ip http secure-server +! +ip route 0.0.0.0 0.0.0.0 10.0.0.2 +ip scp server enable +! +! +logging origin-id hostname +logging host 10.125.1.171 transport udp port 7004 +! +! +snmp-server community ntc-public RO +snmp-server community ntc-private RW +snmp-server community networktocode RO +snmp-server community secure RW +snmp-server location Network to Code - NYC | NY +snmp-server contact John Smith +snmp-server host 10.1.1.1 version 2c networktocode +! +! +! +control-plane +! +! +! +! +banner exec ^C +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************^C +banner incoming ^C +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************^C +! +alias exec ntcclear clear platform software vnic-if nv +! +line con 0 + stopbits 1 +line vty 0 4 + privilege level 15 + login local + transport preferred ssh + transport input all +line vty 5 15 + privilege level 15 + login local + transport preferred ssh + transport input all +! +ntp server 10.1.1.1 +ntp server 10.2.2.2 prefer +! +! +! +! +! +netconf-yang +restconf +end \ No newline at end of file diff --git a/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_starts_args.json b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_starts_args.json new file mode 100644 index 00000000..68aaaf8c --- /dev/null +++ b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_starts_args.json @@ -0,0 +1,4 @@ +{ + "pattern": "call-", + "match_type": "startswith" +} \ No newline at end of file diff --git a/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_starts_received.txt b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_starts_received.txt new file mode 100644 index 00000000..6535ea88 --- /dev/null +++ b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_starts_received.txt @@ -0,0 +1,5 @@ +call-home + contact-email-addr sch-smart-licensing@cisco.com + profile "CiscoTAC-1" + active + destination transport-method http \ No newline at end of file diff --git a/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_starts_sent.txt b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_starts_sent.txt new file mode 100644 index 00000000..d6932d4b --- /dev/null +++ b/tests/unit/mock/config/parser/find_all_children/cisco_ios/ios_starts_sent.txt @@ -0,0 +1,331 @@ +! +version 17.1 +service timestamps debug datetime msec +service timestamps log datetime msec +! Call-home is enabled by Smart-Licensing. +service call-home +platform qfp utilization monitor load 80 +platform punt-keepalive disable-kernel-core +platform console serial +! +hostname jcy-bb-01 +! +boot-start-marker +boot-end-marker +! +! +vrf definition MANAGEMENT + ! + address-family ipv4 + exit-address-family + ! + address-family ipv6 + exit-address-family +! +logging userinfo +! +no aaa new-model +call-home + ! If contact email address in call-home is configured as sch-smart-licensing@cisco.com + ! the email address configured in Cisco Smart License Portal will be used as contact email address to send SCH notifications. + contact-email-addr sch-smart-licensing@cisco.com + profile "CiscoTAC-1" + active + destination transport-method http +! +! +! +! +! +! +! +no ip domain lookup +ip domain name infra.ntc.com +! +! +! +login on-success log +! +! +! +! +! +! +! +subscriber templating +! +! +! +! +! +! +multilink bundle-name authenticated +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +crypto pki trustpoint TP-self-signed-1088426642 + enrollment selfsigned + subject-name cn=IOS-Self-Signed-Certificate-1088426642 + revocation-check none + rsakeypair TP-self-signed-1088426642 +! +crypto pki trustpoint SLA-TrustPoint + enrollment pkcs12 + revocation-check crl +! +! +crypto pki certificate chain TP-self-signed-1088426642 + certificate self-signed 01 + 30820330 30820218 A0030201 02020101 300D0609 2A864886 F70D0101 05050030 + 31312F30 2D060355 04031326 494F532D 53656C66 2D536967 6E65642D 43657274 + 69666963 6174652D 31303838 34323636 3432301E 170D3231 30333039 30333233 + 30325A17 0D333030 31303130 30303030 305A3031 312F302D 06035504 03132649 + 4F532D53 656C662D 5369676E 65642D43 65727469 66696361 74652D31 30383834 + 32363634 32308201 22300D06 092A8648 86F70D01 01010500 0382010F 00308201 + 0A028201 0100E61B 372A60D2 0A1D58E3 0EC5CEBD 1EA5BF18 3F6BF297 2162DB79 + ECBF511A 8B14DF23 35EEF4A8 E219B625 E5ED6575 EAD5914A 905E07A2 C2298199 + D143673A 13C6212A 5A2C034F C250F52F F1187F51 0F003B7F 23642CAE 00A1413C + 270D4E53 55E7EDB4 1A7B69B6 4EB4B5E7 12ACA95C 07F22B02 80C65739 25C09B82 + 788C4DC2 9729D9DB F0471C13 E2082BDA 3C525850 56684AEF FCE2C18B 1A042FC1 + 20D1403B 837AA3EB D91F6055 0F5FFFE3 E7A9D3C8 09C454C0 CC2E793E B28B60CB + 3428B6FD 28280899 90E4D168 57AA9005 2FC602B9 D40BCD5E 6AD97F2D 986B1A90 + F76DE19B 870223D0 86093C37 62D81873 968EC939 53BA36D6 61650732 0124089F + 7B9445D8 8EF90203 010001A3 53305130 0F060355 1D130101 FF040530 030101FF + 301F0603 551D2304 18301680 1419973D 5607ACE0 D2127B39 A1F6AC00 2C7216A8 + F4301D06 03551D0E 04160414 19973D56 07ACE0D2 127B39A1 F6AC002C 7216A8F4 + 300D0609 2A864886 F70D0101 05050003 82010100 0D01C4E1 544034EE F516AB65 + 9DB7D85D EC3CC16F E1BCD286 3C7F351F D86F3B9B D17EC2BA 75B597E9 F2E3C0A7 + D4FFF39F F5152741 F0551772 135243FA 458E3F8B 77832597 1E18656E 3AA732BD + 40F899EA 16969EB1 15D8656E 12E57B7A BD7221E6 BAF7D210 2B2E601C 7D047BBA + B5F736A4 4969D25B 8C3B2D80 1DB93EC2 80C021E7 A8045D05 3D775D18 ECC4A82A + 158B85E7 89C03B6D 7D46BF23 0DC1684C 98F1E82D 898A56C6 A2442C46 15EC810B + 80148784 767C8EE1 5F37AA98 57306ABB 0FF717AB E42D2949 346D867D A619CAC1 + 24AD8BB1 7696E51B 2E1BA9E8 5883E396 FE8C8DB3 96636DF0 3E963FFC 749EF8D4 + 3C1D27CD 60B9C28E 5A32B0B7 76E74DB4 48D752EB + quit +crypto pki certificate chain SLA-TrustPoint + certificate ca 01 + 30820321 30820209 A0030201 02020101 300D0609 2A864886 F70D0101 0B050030 + 32310E30 0C060355 040A1305 43697363 6F312030 1E060355 04031317 43697363 + 6F204C69 63656E73 696E6720 526F6F74 20434130 1E170D31 33303533 30313934 + 3834375A 170D3338 30353330 31393438 34375A30 32310E30 0C060355 040A1305 + 43697363 6F312030 1E060355 04031317 43697363 6F204C69 63656E73 696E6720 + 526F6F74 20434130 82012230 0D06092A 864886F7 0D010101 05000382 010F0030 + 82010A02 82010100 A6BCBD96 131E05F7 145EA72C 2CD686E6 17222EA1 F1EFF64D + CBB4C798 212AA147 C655D8D7 9471380D 8711441E 1AAF071A 9CAE6388 8A38E520 + 1C394D78 462EF239 C659F715 B98C0A59 5BBB5CBD 0CFEBEA3 700A8BF7 D8F256EE + 4AA4E80D DB6FD1C9 60B1FD18 FFC69C96 6FA68957 A2617DE7 104FDC5F EA2956AC + 7390A3EB 2B5436AD C847A2C5 DAB553EB 69A9A535 58E9F3E3 C0BD23CF 58BD7188 + 68E69491 20F320E7 948E71D7 AE3BCC84 F10684C7 4BC8E00F 539BA42B 42C68BB7 + C7479096 B4CB2D62 EA2F505D C7B062A4 6811D95B E8250FC4 5D5D5FB8 8F27D191 + C55F0D76 61F9A4CD 3D992327 A8BB03BD 4E6D7069 7CBADF8B DF5F4368 95135E44 + DFC7C6CF 04DD7FD1 02030100 01A34230 40300E06 03551D0F 0101FF04 04030201 + 06300F06 03551D13 0101FF04 05300301 01FF301D 0603551D 0E041604 1449DC85 + 4B3D31E5 1B3E6A17 606AF333 3D3B4C73 E8300D06 092A8648 86F70D01 010B0500 + 03820101 00507F24 D3932A66 86025D9F E838AE5C 6D4DF6B0 49631C78 240DA905 + 604EDCDE FF4FED2B 77FC460E CD636FDB DD44681E 3A5673AB 9093D3B1 6C9E3D8B + D98987BF E40CBD9E 1AECA0C2 2189BB5C 8FA85686 CD98B646 5575B146 8DFC66A8 + 467A3DF4 4D565700 6ADF0F0D CF835015 3C04FF7C 21E878AC 11BA9CD2 55A9232C + 7CA7B7E6 C1AF74F6 152E99B7 B1FCF9BB E973DE7F 5BDDEB86 C71E3B49 1765308B + 5FB0DA06 B92AFE7F 494E8A9E 07B85737 F3A58BE1 1A48A229 C37C1E69 39F08678 + 80DDCD16 D6BACECA EEBC7CF9 8428787B 35202CDC 60E4616A B623CDBD 230E3AFB + 418616A9 4093E049 4D10AB75 27E86F73 932E35B5 8862FDAE 0275156F 719BB2F0 + D697DF7F 28 + quit +! +license udi pid CSR1000V sn 9SAGBHTUEE9 +diagnostic bootup level minimal +archive + path bootflash:archive +memory free low-watermark processor 72107 +! +! +spanning-tree extend system-id +! +username ntc privilege 15 password 0 ntc123 +! +redundancy +! +! +! +! +! +lldp run +cdp run +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +interface Loopback0 + ip address 10.0.10.3 255.255.255.255 +! +interface GigabitEthernet1 + description MANAGEMENT_DO_NOT_CHANGE + ip address 10.0.0.15 255.255.255.0 + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet2 + ip address 10.10.0.6 255.255.255.252 + ip access-group BLOCK_TRANSIT_LINKS in + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet3 + ip address 10.10.0.14 255.255.255.252 + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet4 + description backbone-to-vmx3-ge0/0/3 + ip address 10.10.0.17 255.255.255.252 + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet5 + no ip address + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet6 + no ip address + shutdown + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet7 + no ip address + shutdown + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet8 + no ip address + shutdown + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet9 + no ip address + shutdown + negotiation auto + no mop enabled + no mop sysid +! +router bgp 65251 + bgp router-id 10.0.10.3 + bgp log-neighbor-changes + redistribute connected + neighbor 10.10.0.5 remote-as 65251 + neighbor 10.10.0.13 remote-as 65251 + neighbor 10.10.0.18 remote-as 65252 +! +! +virtual-service csr_mgmt +! +ip forward-protocol nd +ip http server +ip http authentication local +ip http secure-server +! +ip route 0.0.0.0 0.0.0.0 10.0.0.2 +ip scp server enable +! +! +logging origin-id hostname +logging host 10.125.1.171 transport udp port 7004 +! +! +snmp-server community ntc-public RO +snmp-server community ntc-private RW +snmp-server community networktocode RO +snmp-server community secure RW +snmp-server location Network to Code - NYC | NY +snmp-server contact John Smith +snmp-server host 10.1.1.1 version 2c networktocode +! +! +! +control-plane +! +! +! +! +banner exec ^C +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************^C +banner incoming ^C +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************^C +! +alias exec ntcclear clear platform software vnic-if nv +! +line con 0 + stopbits 1 +line vty 0 4 + privilege level 15 + login local + transport preferred ssh + transport input all +line vty 5 15 + privilege level 15 + login local + transport preferred ssh + transport input all +! +ntp server 10.1.1.1 +ntp server 10.2.2.2 prefer +! +! +! +! +! +netconf-yang +restconf +end \ No newline at end of file diff --git a/tests/unit/mock/config/parser/find_children/cisco_ios/certificate.txt b/tests/unit/mock/config/parser/find_children/cisco_ios/certificate.txt deleted file mode 100644 index fc57c973..00000000 --- a/tests/unit/mock/config/parser/find_children/cisco_ios/certificate.txt +++ /dev/null @@ -1,14 +0,0 @@ -crypto pki trustpoint TP-self-signed-1088426642 - enrollment selfsigned - subject-name cn=IOS-Self-Signed-Certificate-1088426642 - revocation-check none - rsakeypair TP-self-signed-1088426642 -crypto pki trustpoint SLA-TrustPoint - enrollment pkcs12 - revocation-check crl -crypto pki certificate chain TP-self-signed-1088426642 - certificate self-signed 01 - quit -crypto pki certificate chain SLA-TrustPoint - certificate ca 01 - quit \ No newline at end of file diff --git a/tests/unit/mock/config/parser/find_children/cisco_ios/interface.txt b/tests/unit/mock/config/parser/find_children/cisco_ios/interface.txt deleted file mode 100644 index 232b74d2..00000000 --- a/tests/unit/mock/config/parser/find_children/cisco_ios/interface.txt +++ /dev/null @@ -1,24 +0,0 @@ - no ip address - negotiation auto - no mop enabled - no mop sysid - no ip address - shutdown - negotiation auto - no mop enabled - no mop sysid - no ip address - shutdown - negotiation auto - no mop enabled - no mop sysid - no ip address - shutdown - negotiation auto - no mop enabled - no mop sysid - no ip address - shutdown - negotiation auto - no mop enabled - no mop sysid \ No newline at end of file diff --git a/tests/unit/mock/config/parser/find_children_w_parents/cisco_ios/ios_full_args.json b/tests/unit/mock/config/parser/find_children_w_parents/cisco_ios/ios_full_args.json new file mode 100644 index 00000000..f5c1e792 --- /dev/null +++ b/tests/unit/mock/config/parser/find_children_w_parents/cisco_ios/ios_full_args.json @@ -0,0 +1,5 @@ +{ + "parent_pattern": "call-home", + "child_pattern": " profile \"CiscoTAC-1\"", + "match_type": "exact" +} \ No newline at end of file diff --git a/tests/unit/mock/config/parser/find_children_w_parents/cisco_ios/ios_full_received.txt b/tests/unit/mock/config/parser/find_children_w_parents/cisco_ios/ios_full_received.txt new file mode 100644 index 00000000..e7a4b1be --- /dev/null +++ b/tests/unit/mock/config/parser/find_children_w_parents/cisco_ios/ios_full_received.txt @@ -0,0 +1,4 @@ + contact-email-addr sch-smart-licensing@cisco.com + profile "CiscoTAC-1" + active + destination transport-method http \ No newline at end of file diff --git a/tests/unit/mock/config/parser/find_children_w_parents/cisco_ios/ios_full_sent.txt b/tests/unit/mock/config/parser/find_children_w_parents/cisco_ios/ios_full_sent.txt new file mode 100644 index 00000000..d6932d4b --- /dev/null +++ b/tests/unit/mock/config/parser/find_children_w_parents/cisco_ios/ios_full_sent.txt @@ -0,0 +1,331 @@ +! +version 17.1 +service timestamps debug datetime msec +service timestamps log datetime msec +! Call-home is enabled by Smart-Licensing. +service call-home +platform qfp utilization monitor load 80 +platform punt-keepalive disable-kernel-core +platform console serial +! +hostname jcy-bb-01 +! +boot-start-marker +boot-end-marker +! +! +vrf definition MANAGEMENT + ! + address-family ipv4 + exit-address-family + ! + address-family ipv6 + exit-address-family +! +logging userinfo +! +no aaa new-model +call-home + ! If contact email address in call-home is configured as sch-smart-licensing@cisco.com + ! the email address configured in Cisco Smart License Portal will be used as contact email address to send SCH notifications. + contact-email-addr sch-smart-licensing@cisco.com + profile "CiscoTAC-1" + active + destination transport-method http +! +! +! +! +! +! +! +no ip domain lookup +ip domain name infra.ntc.com +! +! +! +login on-success log +! +! +! +! +! +! +! +subscriber templating +! +! +! +! +! +! +multilink bundle-name authenticated +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +crypto pki trustpoint TP-self-signed-1088426642 + enrollment selfsigned + subject-name cn=IOS-Self-Signed-Certificate-1088426642 + revocation-check none + rsakeypair TP-self-signed-1088426642 +! +crypto pki trustpoint SLA-TrustPoint + enrollment pkcs12 + revocation-check crl +! +! +crypto pki certificate chain TP-self-signed-1088426642 + certificate self-signed 01 + 30820330 30820218 A0030201 02020101 300D0609 2A864886 F70D0101 05050030 + 31312F30 2D060355 04031326 494F532D 53656C66 2D536967 6E65642D 43657274 + 69666963 6174652D 31303838 34323636 3432301E 170D3231 30333039 30333233 + 30325A17 0D333030 31303130 30303030 305A3031 312F302D 06035504 03132649 + 4F532D53 656C662D 5369676E 65642D43 65727469 66696361 74652D31 30383834 + 32363634 32308201 22300D06 092A8648 86F70D01 01010500 0382010F 00308201 + 0A028201 0100E61B 372A60D2 0A1D58E3 0EC5CEBD 1EA5BF18 3F6BF297 2162DB79 + ECBF511A 8B14DF23 35EEF4A8 E219B625 E5ED6575 EAD5914A 905E07A2 C2298199 + D143673A 13C6212A 5A2C034F C250F52F F1187F51 0F003B7F 23642CAE 00A1413C + 270D4E53 55E7EDB4 1A7B69B6 4EB4B5E7 12ACA95C 07F22B02 80C65739 25C09B82 + 788C4DC2 9729D9DB F0471C13 E2082BDA 3C525850 56684AEF FCE2C18B 1A042FC1 + 20D1403B 837AA3EB D91F6055 0F5FFFE3 E7A9D3C8 09C454C0 CC2E793E B28B60CB + 3428B6FD 28280899 90E4D168 57AA9005 2FC602B9 D40BCD5E 6AD97F2D 986B1A90 + F76DE19B 870223D0 86093C37 62D81873 968EC939 53BA36D6 61650732 0124089F + 7B9445D8 8EF90203 010001A3 53305130 0F060355 1D130101 FF040530 030101FF + 301F0603 551D2304 18301680 1419973D 5607ACE0 D2127B39 A1F6AC00 2C7216A8 + F4301D06 03551D0E 04160414 19973D56 07ACE0D2 127B39A1 F6AC002C 7216A8F4 + 300D0609 2A864886 F70D0101 05050003 82010100 0D01C4E1 544034EE F516AB65 + 9DB7D85D EC3CC16F E1BCD286 3C7F351F D86F3B9B D17EC2BA 75B597E9 F2E3C0A7 + D4FFF39F F5152741 F0551772 135243FA 458E3F8B 77832597 1E18656E 3AA732BD + 40F899EA 16969EB1 15D8656E 12E57B7A BD7221E6 BAF7D210 2B2E601C 7D047BBA + B5F736A4 4969D25B 8C3B2D80 1DB93EC2 80C021E7 A8045D05 3D775D18 ECC4A82A + 158B85E7 89C03B6D 7D46BF23 0DC1684C 98F1E82D 898A56C6 A2442C46 15EC810B + 80148784 767C8EE1 5F37AA98 57306ABB 0FF717AB E42D2949 346D867D A619CAC1 + 24AD8BB1 7696E51B 2E1BA9E8 5883E396 FE8C8DB3 96636DF0 3E963FFC 749EF8D4 + 3C1D27CD 60B9C28E 5A32B0B7 76E74DB4 48D752EB + quit +crypto pki certificate chain SLA-TrustPoint + certificate ca 01 + 30820321 30820209 A0030201 02020101 300D0609 2A864886 F70D0101 0B050030 + 32310E30 0C060355 040A1305 43697363 6F312030 1E060355 04031317 43697363 + 6F204C69 63656E73 696E6720 526F6F74 20434130 1E170D31 33303533 30313934 + 3834375A 170D3338 30353330 31393438 34375A30 32310E30 0C060355 040A1305 + 43697363 6F312030 1E060355 04031317 43697363 6F204C69 63656E73 696E6720 + 526F6F74 20434130 82012230 0D06092A 864886F7 0D010101 05000382 010F0030 + 82010A02 82010100 A6BCBD96 131E05F7 145EA72C 2CD686E6 17222EA1 F1EFF64D + CBB4C798 212AA147 C655D8D7 9471380D 8711441E 1AAF071A 9CAE6388 8A38E520 + 1C394D78 462EF239 C659F715 B98C0A59 5BBB5CBD 0CFEBEA3 700A8BF7 D8F256EE + 4AA4E80D DB6FD1C9 60B1FD18 FFC69C96 6FA68957 A2617DE7 104FDC5F EA2956AC + 7390A3EB 2B5436AD C847A2C5 DAB553EB 69A9A535 58E9F3E3 C0BD23CF 58BD7188 + 68E69491 20F320E7 948E71D7 AE3BCC84 F10684C7 4BC8E00F 539BA42B 42C68BB7 + C7479096 B4CB2D62 EA2F505D C7B062A4 6811D95B E8250FC4 5D5D5FB8 8F27D191 + C55F0D76 61F9A4CD 3D992327 A8BB03BD 4E6D7069 7CBADF8B DF5F4368 95135E44 + DFC7C6CF 04DD7FD1 02030100 01A34230 40300E06 03551D0F 0101FF04 04030201 + 06300F06 03551D13 0101FF04 05300301 01FF301D 0603551D 0E041604 1449DC85 + 4B3D31E5 1B3E6A17 606AF333 3D3B4C73 E8300D06 092A8648 86F70D01 010B0500 + 03820101 00507F24 D3932A66 86025D9F E838AE5C 6D4DF6B0 49631C78 240DA905 + 604EDCDE FF4FED2B 77FC460E CD636FDB DD44681E 3A5673AB 9093D3B1 6C9E3D8B + D98987BF E40CBD9E 1AECA0C2 2189BB5C 8FA85686 CD98B646 5575B146 8DFC66A8 + 467A3DF4 4D565700 6ADF0F0D CF835015 3C04FF7C 21E878AC 11BA9CD2 55A9232C + 7CA7B7E6 C1AF74F6 152E99B7 B1FCF9BB E973DE7F 5BDDEB86 C71E3B49 1765308B + 5FB0DA06 B92AFE7F 494E8A9E 07B85737 F3A58BE1 1A48A229 C37C1E69 39F08678 + 80DDCD16 D6BACECA EEBC7CF9 8428787B 35202CDC 60E4616A B623CDBD 230E3AFB + 418616A9 4093E049 4D10AB75 27E86F73 932E35B5 8862FDAE 0275156F 719BB2F0 + D697DF7F 28 + quit +! +license udi pid CSR1000V sn 9SAGBHTUEE9 +diagnostic bootup level minimal +archive + path bootflash:archive +memory free low-watermark processor 72107 +! +! +spanning-tree extend system-id +! +username ntc privilege 15 password 0 ntc123 +! +redundancy +! +! +! +! +! +lldp run +cdp run +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +! +interface Loopback0 + ip address 10.0.10.3 255.255.255.255 +! +interface GigabitEthernet1 + description MANAGEMENT_DO_NOT_CHANGE + ip address 10.0.0.15 255.255.255.0 + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet2 + ip address 10.10.0.6 255.255.255.252 + ip access-group BLOCK_TRANSIT_LINKS in + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet3 + ip address 10.10.0.14 255.255.255.252 + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet4 + description backbone-to-vmx3-ge0/0/3 + ip address 10.10.0.17 255.255.255.252 + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet5 + no ip address + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet6 + no ip address + shutdown + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet7 + no ip address + shutdown + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet8 + no ip address + shutdown + negotiation auto + no mop enabled + no mop sysid +! +interface GigabitEthernet9 + no ip address + shutdown + negotiation auto + no mop enabled + no mop sysid +! +router bgp 65251 + bgp router-id 10.0.10.3 + bgp log-neighbor-changes + redistribute connected + neighbor 10.10.0.5 remote-as 65251 + neighbor 10.10.0.13 remote-as 65251 + neighbor 10.10.0.18 remote-as 65252 +! +! +virtual-service csr_mgmt +! +ip forward-protocol nd +ip http server +ip http authentication local +ip http secure-server +! +ip route 0.0.0.0 0.0.0.0 10.0.0.2 +ip scp server enable +! +! +logging origin-id hostname +logging host 10.125.1.171 transport udp port 7004 +! +! +snmp-server community ntc-public RO +snmp-server community ntc-private RW +snmp-server community networktocode RO +snmp-server community secure RW +snmp-server location Network to Code - NYC | NY +snmp-server contact John Smith +snmp-server host 10.1.1.1 version 2c networktocode +! +! +! +control-plane +! +! +! +! +banner exec ^C +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************^C +banner incoming ^C +************************************************************************** +* IOSv is strictly limited to use for evaluation, demonstration and IOS * +* education. IOSv is provided as-is and is not supported by Cisco's * +* Technical Advisory Center. Any use or disclosure, in whole or in part, * +* of the IOSv Software or Documentation to any third party for any * +* purposes is expressly prohibited except as otherwise authorized by * +* Cisco in writing. * +**************************************************************************^C +! +alias exec ntcclear clear platform software vnic-if nv +! +line con 0 + stopbits 1 +line vty 0 4 + privilege level 15 + login local + transport preferred ssh + transport input all +line vty 5 15 + privilege level 15 + login local + transport preferred ssh + transport input all +! +ntp server 10.1.1.1 +ntp server 10.2.2.2 prefer +! +! +! +! +! +netconf-yang +restconf +end \ No newline at end of file diff --git a/tests/unit/test_parser.py b/tests/unit/test_parser.py index 16e702f1..8186e631 100644 --- a/tests/unit/test_parser.py +++ b/tests/unit/test_parser.py @@ -4,54 +4,56 @@ import pytest from netutils.config import compliance -from netutils.config.parser import IOSConfigParser MOCK_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "mock", "config", "parser") -MOCK_GETPATH_DIR = os.path.join( - os.path.dirname(os.path.realpath(__file__)), "mock", "config", "parser", "find_children" -) TXT_FILE = "_sent.txt" -CONFIG_FILE = "full_config.txt" - -parameters = [] -for network_os in list(compliance.parser_map.keys()): - for _file in glob.glob(f"{MOCK_DIR}/{network_os}/*{TXT_FILE}"): - parameters.append([_file, network_os]) - +base_parameters = [] find_all_children_parameters = [] -find_all_children_test_cases = [ - ("crypto pki", "certificate.txt"), -] -for network_os in list(compliance.parser_map.keys()): - for _file in glob.glob(f"{MOCK_GETPATH_DIR}/{network_os}/{CONFIG_FILE}"): - for test_case in find_all_children_test_cases: - find_all_children_parameters.append( - (_file, test_case[0], f"{MOCK_GETPATH_DIR}/{network_os}/{test_case[1]}") - ) - -find_children_parents_parameters = [] -find_children_parents_test_cases = [ - ("interface", " no ip", "interface.txt"), -] +find_children_w_parents_parameters = [] for network_os in list(compliance.parser_map.keys()): - for _file in glob.glob(f"{MOCK_GETPATH_DIR}/{network_os}/{CONFIG_FILE}"): - for test_case in find_children_parents_test_cases: - find_children_parents_parameters.append( - (_file, test_case[0], test_case[1], f"{MOCK_GETPATH_DIR}/{network_os}/{test_case[2]}") - ) + for _file in glob.glob(f"{MOCK_DIR}/base/{network_os}/*{TXT_FILE}"): + base_parameters.append([_file, network_os]) + for _file in glob.glob(f"{MOCK_DIR}/find_all_children/{network_os}/*{TXT_FILE}"): + find_all_children_parameters.append([_file, network_os]) + for _file in glob.glob(f"{MOCK_DIR}/find_children_w_parents/{network_os}/*{TXT_FILE}"): + find_children_w_parents_parameters.append([_file, network_os]) -@pytest.mark.parametrize("_file, network_os", parameters) +@pytest.mark.parametrize("_file, network_os", base_parameters) def test_parser(_file, network_os, get_text_data, get_python_data): # pylint: disable=redefined-outer-name - truncate_file = os.path.join(MOCK_DIR, _file[: -len(TXT_FILE)]) + truncate_file = os.path.join(MOCK_DIR, "base", _file[: -len(TXT_FILE)]) - device_cfg = get_text_data(os.path.join(MOCK_DIR, _file)) + device_cfg = get_text_data(os.path.join(MOCK_DIR, "base", _file)) received_data = get_python_data(truncate_file + "_received.py", "data") os_parser = compliance.parser_map[network_os] assert os_parser(device_cfg).config_lines == received_data +@pytest.mark.parametrize("_file, network_os", find_all_children_parameters) +def test_find_all_children(_file, network_os, get_text_data, get_json_data): # pylint: disable=redefined-outer-name + truncate_file = os.path.join(MOCK_DIR, "find_all_children", _file[: -len(TXT_FILE)]) + + device_cfg = get_text_data(os.path.join(MOCK_DIR, "find_all_children", _file)) + received_data = get_text_data(os.path.join(MOCK_DIR, "find_all_children", truncate_file + "_received.txt")) + kwargs = get_json_data(truncate_file + "_args.json") + os_parser = compliance.parser_map[network_os] + assert "\n".join(os_parser(device_cfg).find_all_children(**kwargs)) == received_data + + +@pytest.mark.parametrize("_file, network_os", find_children_w_parents_parameters) +def test_find_children_w_parents( + _file, network_os, get_text_data, get_json_data +): # pylint: disable=redefined-outer-name + truncate_file = os.path.join(MOCK_DIR, "find_children_w_parents", _file[: -len(TXT_FILE)]) + + device_cfg = get_text_data(os.path.join(MOCK_DIR, "find_children_w_parents", _file)) + received_data = get_text_data(os.path.join(MOCK_DIR, "find_children_w_parents", truncate_file + "_received.txt")) + kwargs = get_json_data(truncate_file + "_args.json") + os_parser = compliance.parser_map[network_os] + assert "\n".join(os_parser(device_cfg).find_children_w_parents(**kwargs)) == received_data + + def test_incorrect_banner_ios(): banner_cfg = ( "aaa new-model\n" @@ -65,27 +67,3 @@ def test_incorrect_banner_ios(): ) with pytest.raises(ValueError): compliance.parser_map["cisco_ios"](banner_cfg).config_lines # pylint: disable=expression-not-assigned - - -@pytest.mark.parametrize("_file, pattern, expected", find_all_children_parameters) -def test_find_all_children(_file, pattern, expected, get_text_data): - """Tests get_path method.""" - device_cfg = get_text_data(os.path.join(MOCK_DIR, _file)) - config_tree = IOSConfigParser(str(device_cfg)) - returned_path = config_tree.find_all_children(pattern=pattern, match_type="regex") - expected_path = get_text_data(os.path.join(MOCK_DIR, expected)) - - assert returned_path == expected_path.split("\n") - - -@pytest.mark.parametrize("_file, parent_pattern, child_pattern, expected", find_children_parents_parameters) -def test_find_children_w_parents(_file, parent_pattern, child_pattern, expected, get_text_data): - """Tests get_path_with_children method.""" - device_cfg = get_text_data(os.path.join(MOCK_DIR, _file)) - config_tree = IOSConfigParser(str(device_cfg)) - returned_path = config_tree.find_children_w_parents( - parent_pattern=parent_pattern, child_pattern=child_pattern, match_type="regex" - ) - expected_path = get_text_data(os.path.join(MOCK_DIR, expected)) - - assert returned_path == expected_path.split("\n")