cisco_node_utils_mgx 2.1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +96 -0
- data/.travis.yml +17 -0
- data/CHANGELOG.md +676 -0
- data/CONTRIBUTING.md +43 -0
- data/Gemfile +10 -0
- data/LICENSE +201 -0
- data/README.md +246 -0
- data/Rakefile +44 -0
- data/SUPPORT.md +3 -0
- data/bin/.rubocop.yml +18 -0
- data/bin/check_metric_limits.rb +109 -0
- data/bin/git/hooks/commit-msg/enforce_style +89 -0
- data/bin/git/hooks/hook_lib +115 -0
- data/bin/git/hooks/hooks-wrapper +38 -0
- data/bin/git/hooks/post-flow-hotfix-start/update-version +24 -0
- data/bin/git/hooks/post-flow-release-finish/update-version +29 -0
- data/bin/git/hooks/post-flow-release-start/update-version +19 -0
- data/bin/git/hooks/post-merge/update-hooks +6 -0
- data/bin/git/hooks/post-rewrite/update-hooks +6 -0
- data/bin/git/hooks/pre-commit/check_unstaged_changes +18 -0
- data/bin/git/hooks/pre-commit/rubocop +25 -0
- data/bin/git/hooks/pre-commit/validate-diffs +45 -0
- data/bin/git/hooks/pre-commit/validate-yaml +18 -0
- data/bin/git/hooks/pre-push/check-changelog +24 -0
- data/bin/git/hooks/pre-push/rubocop +7 -0
- data/bin/git/update-hooks +123 -0
- data/bin/show_running_yang.rb +233 -0
- data/cisco_node_utils.gemspec +41 -0
- data/docs/README-develop-best-practices.md +521 -0
- data/docs/README-develop-node-utils-APIs.md +570 -0
- data/docs/README-maintainers.md +77 -0
- data/docs/README-test-execution.md +57 -0
- data/docs/README-utilities.md +14 -0
- data/docs/agent_files.png +0 -0
- data/docs/cisco_node_utils.yaml.example +36 -0
- data/docs/template-router.rb +123 -0
- data/docs/template-test_router.rb +104 -0
- data/ext/mkrf_conf.rb +63 -0
- data/lib/.rubocop.yml +18 -0
- data/lib/cisco_node_utils/aaa_authentication_login.rb +95 -0
- data/lib/cisco_node_utils/aaa_authentication_login_service.rb +138 -0
- data/lib/cisco_node_utils/aaa_authorization_service.rb +156 -0
- data/lib/cisco_node_utils/ace.rb +467 -0
- data/lib/cisco_node_utils/acl.rb +101 -0
- data/lib/cisco_node_utils/banner.rb +63 -0
- data/lib/cisco_node_utils/bfd_global.rb +305 -0
- data/lib/cisco_node_utils/bgp.rb +988 -0
- data/lib/cisco_node_utils/bgp_af.rb +545 -0
- data/lib/cisco_node_utils/bgp_af_aggr_addr.rb +207 -0
- data/lib/cisco_node_utils/bgp_neighbor.rb +527 -0
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +780 -0
- data/lib/cisco_node_utils/bridge_domain.rb +178 -0
- data/lib/cisco_node_utils/bridge_domain_vni.rb +206 -0
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +444 -0
- data/lib/cisco_node_utils/client/client.rb +238 -0
- data/lib/cisco_node_utils/client/grpc/client.rb +395 -0
- data/lib/cisco_node_utils/client/grpc/ems.proto +148 -0
- data/lib/cisco_node_utils/client/grpc/ems.rb +111 -0
- data/lib/cisco_node_utils/client/grpc/ems_services.rb +49 -0
- data/lib/cisco_node_utils/client/grpc.rb +33 -0
- data/lib/cisco_node_utils/client/nxapi/client.rb +368 -0
- data/lib/cisco_node_utils/client/nxapi.rb +31 -0
- data/lib/cisco_node_utils/client/utils.rb +180 -0
- data/lib/cisco_node_utils/client.rb +35 -0
- data/lib/cisco_node_utils/cmd_ref/README_YAML.md +590 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +40 -0
- data/lib/cisco_node_utils/cmd_ref/acl.yaml +48 -0
- data/lib/cisco_node_utils/cmd_ref/banner.yaml +11 -0
- data/lib/cisco_node_utils/cmd_ref/bfd_global.yaml +117 -0
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +383 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +223 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_af_aa.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +174 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +236 -0
- data/lib/cisco_node_utils/cmd_ref/bridge_domain.yaml +49 -0
- data/lib/cisco_node_utils/cmd_ref/bridge_domain_vni.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/dhcp_relay_global.yaml +128 -0
- data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +55 -0
- data/lib/cisco_node_utils/cmd_ref/encapsulation.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_multicast.yaml +12 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_multisite.yaml +18 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_stormcontrol.yaml +18 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +48 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +183 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +40 -0
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +126 -0
- data/lib/cisco_node_utils/cmd_ref/hostname.yaml +8 -0
- data/lib/cisco_node_utils/cmd_ref/hsrp_global.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/images.yaml +8 -0
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +781 -0
- data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/interface_evpn_multisite.yaml +17 -0
- data/lib/cisco_node_utils/cmd_ref/interface_hsrp_group.yaml +120 -0
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +112 -0
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +87 -0
- data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +42 -0
- data/lib/cisco_node_utils/cmd_ref/inventory.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/ip_multicast.yaml +22 -0
- data/lib/cisco_node_utils/cmd_ref/itd_device_group.yaml +83 -0
- data/lib/cisco_node_utils/cmd_ref/itd_service.yaml +119 -0
- data/lib/cisco_node_utils/cmd_ref/memory.yaml +24 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_auth_key.yaml +10 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +27 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +34 -0
- data/lib/cisco_node_utils/cmd_ref/object_group.yaml +32 -0
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +91 -0
- data/lib/cisco_node_utils/cmd_ref/ospf_area.yaml +91 -0
- data/lib/cisco_node_utils/cmd_ref/ospf_area_vlink.yaml +88 -0
- data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +37 -0
- data/lib/cisco_node_utils/cmd_ref/pim.yaml +43 -0
- data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +86 -0
- data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +37 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +100 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +19 -0
- data/lib/cisco_node_utils/cmd_ref/route_map.yaml +601 -0
- data/lib/cisco_node_utils/cmd_ref/show_system.yaml +9 -0
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +84 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +81 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +9 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +74 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +91 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +57 -0
- data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +23 -0
- data/lib/cisco_node_utils/cmd_ref/span_session.yaml +65 -0
- data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +235 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_facility.yaml +10 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +34 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/system.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_global.yaml +37 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +63 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +64 -0
- data/lib/cisco_node_utils/cmd_ref/upgrade.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +52 -0
- data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +8 -0
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +106 -0
- data/lib/cisco_node_utils/cmd_ref/vpc.yaml +233 -0
- data/lib/cisco_node_utils/cmd_ref/vrf.yaml +86 -0
- data/lib/cisco_node_utils/cmd_ref/vrf_af.yaml +139 -0
- data/lib/cisco_node_utils/cmd_ref/vtp.yaml +32 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +114 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +71 -0
- data/lib/cisco_node_utils/cmd_ref/yang.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +68 -0
- data/lib/cisco_node_utils/command_reference.rb +724 -0
- data/lib/cisco_node_utils/configparser_lib.rb +195 -0
- data/lib/cisco_node_utils/constants.rb +40 -0
- data/lib/cisco_node_utils/dhcp_relay_global.rb +302 -0
- data/lib/cisco_node_utils/dns_domain.rb +93 -0
- data/lib/cisco_node_utils/domain_name.rb +82 -0
- data/lib/cisco_node_utils/encapsulation.rb +112 -0
- data/lib/cisco_node_utils/environment.rb +110 -0
- data/lib/cisco_node_utils/evpn_multicast.rb +66 -0
- data/lib/cisco_node_utils/evpn_multisite.rb +96 -0
- data/lib/cisco_node_utils/evpn_stormcontrol.rb +84 -0
- data/lib/cisco_node_utils/evpn_vni.rb +159 -0
- data/lib/cisco_node_utils/exceptions.rb +140 -0
- data/lib/cisco_node_utils/fabricpath_global.rb +405 -0
- data/lib/cisco_node_utils/fabricpath_topology.rb +137 -0
- data/lib/cisco_node_utils/feature.rb +377 -0
- data/lib/cisco_node_utils/hostname.rb +62 -0
- data/lib/cisco_node_utils/hsrp_global.rb +97 -0
- data/lib/cisco_node_utils/interface.rb +2128 -0
- data/lib/cisco_node_utils/interface_channel_group.rb +142 -0
- data/lib/cisco_node_utils/interface_evpn_multisite.rb +72 -0
- data/lib/cisco_node_utils/interface_hsrp_group.rb +557 -0
- data/lib/cisco_node_utils/interface_ospf.rb +378 -0
- data/lib/cisco_node_utils/interface_portchannel.rb +180 -0
- data/lib/cisco_node_utils/interface_service_vni.rb +132 -0
- data/lib/cisco_node_utils/ip_multicast.rb +90 -0
- data/lib/cisco_node_utils/itd_device_group.rb +228 -0
- data/lib/cisco_node_utils/itd_device_group_node.rb +144 -0
- data/lib/cisco_node_utils/itd_service.rb +511 -0
- data/lib/cisco_node_utils/logger.rb +78 -0
- data/lib/cisco_node_utils/name_server.rb +64 -0
- data/lib/cisco_node_utils/node.rb +443 -0
- data/lib/cisco_node_utils/node_util.rb +111 -0
- data/lib/cisco_node_utils/ntp_auth_key.rb +67 -0
- data/lib/cisco_node_utils/ntp_config.rb +83 -0
- data/lib/cisco_node_utils/ntp_server.rb +86 -0
- data/lib/cisco_node_utils/object_group.rb +75 -0
- data/lib/cisco_node_utils/object_group_entry.rb +143 -0
- data/lib/cisco_node_utils/overlay_global.rb +142 -0
- data/lib/cisco_node_utils/pim.rb +131 -0
- data/lib/cisco_node_utils/pim_group_list.rb +109 -0
- data/lib/cisco_node_utils/pim_rp_address.rb +103 -0
- data/lib/cisco_node_utils/platform.rb +217 -0
- data/lib/cisco_node_utils/portchannel_global.rb +347 -0
- data/lib/cisco_node_utils/radius_global.rb +165 -0
- data/lib/cisco_node_utils/radius_server.rb +421 -0
- data/lib/cisco_node_utils/radius_server_group.rb +117 -0
- data/lib/cisco_node_utils/route_map.rb +2540 -0
- data/lib/cisco_node_utils/router_ospf.rb +77 -0
- data/lib/cisco_node_utils/router_ospf_area.rb +416 -0
- data/lib/cisco_node_utils/router_ospf_area_vlink.rb +313 -0
- data/lib/cisco_node_utils/router_ospf_vrf.rb +342 -0
- data/lib/cisco_node_utils/snmp_notification_receiver.rb +176 -0
- data/lib/cisco_node_utils/snmpcommunity.rb +109 -0
- data/lib/cisco_node_utils/snmpgroup.rb +54 -0
- data/lib/cisco_node_utils/snmpnotification.rb +57 -0
- data/lib/cisco_node_utils/snmpserver.rb +132 -0
- data/lib/cisco_node_utils/snmpuser.rb +403 -0
- data/lib/cisco_node_utils/span_session.rb +149 -0
- data/lib/cisco_node_utils/stp_global.rb +676 -0
- data/lib/cisco_node_utils/syslog_facility.rb +64 -0
- data/lib/cisco_node_utils/syslog_server.rb +146 -0
- data/lib/cisco_node_utils/syslog_settings.rb +174 -0
- data/lib/cisco_node_utils/tacacs_global.rb +137 -0
- data/lib/cisco_node_utils/tacacs_server.rb +173 -0
- data/lib/cisco_node_utils/tacacs_server_group.rb +149 -0
- data/lib/cisco_node_utils/tacacs_server_host.rb +216 -0
- data/lib/cisco_node_utils/upgrade.rb +122 -0
- data/lib/cisco_node_utils/vdc.rb +118 -0
- data/lib/cisco_node_utils/version.rb +21 -0
- data/lib/cisco_node_utils/vlan.rb +301 -0
- data/lib/cisco_node_utils/vpc.rb +466 -0
- data/lib/cisco_node_utils/vrf.rb +192 -0
- data/lib/cisco_node_utils/vrf_af.rb +327 -0
- data/lib/cisco_node_utils/vtp.rb +125 -0
- data/lib/cisco_node_utils/vxlan_vtep.rb +286 -0
- data/lib/cisco_node_utils/vxlan_vtep_vni.rb +331 -0
- data/lib/cisco_node_utils/yang.rb +160 -0
- data/lib/cisco_node_utils/yum.rb +213 -0
- data/lib/cisco_node_utils.rb +21 -0
- data/lib/minitest/environment_plugin.rb +31 -0
- data/lib/minitest/log_level_plugin.rb +41 -0
- data/spec/client_spec.rb +7 -0
- data/spec/environment_spec.rb +384 -0
- data/spec/grpc_client_spec.rb +23 -0
- data/spec/isolate/all_clients_spec.rb +9 -0
- data/spec/isolate/grpc_only_spec.rb +16 -0
- data/spec/isolate/no_clients_spec.rb +26 -0
- data/spec/isolate/nxapi_only_spec.rb +16 -0
- data/spec/nxapi_client_spec.rb +42 -0
- data/spec/schema.yaml +82 -0
- data/spec/shared_examples_for_clients.rb +14 -0
- data/spec/spec_helper.rb +91 -0
- data/spec/whitespace_spec.rb +10 -0
- data/spec/yaml_spec.rb +42 -0
- data/tests/.rubocop.yml +18 -0
- data/tests/CSCuxdublin-1.0.0-7.0.3.I3.1.lib32_n9000.rpm +0 -0
- data/tests/basetest.rb +243 -0
- data/tests/ciscotest.rb +577 -0
- data/tests/cmd_config.yaml +75 -0
- data/tests/cmd_config_invalid.yaml +16 -0
- data/tests/n9000_sample-1.0.0-7.0.3.x86_64.rpm +0 -0
- data/tests/noop.rb +7 -0
- data/tests/platform_info.rb +63 -0
- data/tests/tacacs_server.yaml.example +6 -0
- data/tests/test_aaa_authentication_login.rb +243 -0
- data/tests/test_aaa_authentication_login_service.rb +761 -0
- data/tests/test_aaa_authorization_service.rb +874 -0
- data/tests/test_ace.rb +304 -0
- data/tests/test_acl.rb +185 -0
- data/tests/test_banner.rb +85 -0
- data/tests/test_bfd_global.rb +272 -0
- data/tests/test_bgp_af.rb +875 -0
- data/tests/test_bgp_af_aa.rb +108 -0
- data/tests/test_bgp_neighbor.rb +596 -0
- data/tests/test_bgp_neighbor_af.rb +781 -0
- data/tests/test_bridge_domain.rb +198 -0
- data/tests/test_bridge_domain_vni.rb +109 -0
- data/tests/test_client_utils.rb +111 -0
- data/tests/test_cmn_utils.rb +76 -0
- data/tests/test_command_config.rb +206 -0
- data/tests/test_command_reference.rb +669 -0
- data/tests/test_dhcp_relay_global.rb +286 -0
- data/tests/test_dns_domain.rb +123 -0
- data/tests/test_domain_name.rb +96 -0
- data/tests/test_encapsulation.rb +75 -0
- data/tests/test_evpn_multicast.rb +65 -0
- data/tests/test_evpn_multisite.rb +70 -0
- data/tests/test_evpn_stormcontrol.rb +56 -0
- data/tests/test_evpn_vni.rb +131 -0
- data/tests/test_fabricpath_global.rb +246 -0
- data/tests/test_fabricpath_topology.rb +77 -0
- data/tests/test_feature.rb +272 -0
- data/tests/test_grpc.rb +166 -0
- data/tests/test_hostname.rb +64 -0
- data/tests/test_hsrp_global.rb +79 -0
- data/tests/test_interface.rb +1958 -0
- data/tests/test_interface_bdi.rb +80 -0
- data/tests/test_interface_channel_group.rb +131 -0
- data/tests/test_interface_evpn_multisite.rb +94 -0
- data/tests/test_interface_hsrp.rb +134 -0
- data/tests/test_interface_hsrp_group.rb +570 -0
- data/tests/test_interface_ospf.rb +820 -0
- data/tests/test_interface_portchannel.rb +135 -0
- data/tests/test_interface_private_vlan.rb +365 -0
- data/tests/test_interface_service_vni.rb +203 -0
- data/tests/test_interface_svi.rb +210 -0
- data/tests/test_interface_switchport.rb +468 -0
- data/tests/test_ip_multicast.rb +80 -0
- data/tests/test_itd_device_group.rb +145 -0
- data/tests/test_itd_device_group_node.rb +199 -0
- data/tests/test_itd_service.rb +314 -0
- data/tests/test_logger.rb +43 -0
- data/tests/test_name_server.rb +94 -0
- data/tests/test_node.rb +50 -0
- data/tests/test_node_ext.rb +406 -0
- data/tests/test_node_util.rb +119 -0
- data/tests/test_ntp_auth_key.rb +77 -0
- data/tests/test_ntp_config.rb +100 -0
- data/tests/test_ntp_server.rb +146 -0
- data/tests/test_nxapi.rb +236 -0
- data/tests/test_object_group.rb +122 -0
- data/tests/test_overlay_global.rb +108 -0
- data/tests/test_pim.rb +203 -0
- data/tests/test_pim_group_list.rb +147 -0
- data/tests/test_pim_rp_address.rb +155 -0
- data/tests/test_platform.rb +254 -0
- data/tests/test_portchannel_global.rb +322 -0
- data/tests/test_radius_global.rb +108 -0
- data/tests/test_radius_server.rb +377 -0
- data/tests/test_radius_server_group.rb +151 -0
- data/tests/test_route_map.rb +1479 -0
- data/tests/test_router_bgp.rb +1325 -0
- data/tests/test_router_ospf.rb +56 -0
- data/tests/test_router_ospf_area.rb +433 -0
- data/tests/test_router_ospf_area_vlink.rb +298 -0
- data/tests/test_router_ospf_vrf.rb +690 -0
- data/tests/test_snmp_notification_receiver.rb +169 -0
- data/tests/test_snmpcommunity.rb +422 -0
- data/tests/test_snmpgroup.rb +71 -0
- data/tests/test_snmpnotification.rb +91 -0
- data/tests/test_snmpserver.rb +251 -0
- data/tests/test_snmpuser.rb +666 -0
- data/tests/test_span_session.rb +155 -0
- data/tests/test_stp_global.rb +575 -0
- data/tests/test_syslog_facility.rb +80 -0
- data/tests/test_syslog_server.rb +119 -0
- data/tests/test_syslog_settings.rb +123 -0
- data/tests/test_tacacs_global.rb +109 -0
- data/tests/test_tacacs_server.rb +436 -0
- data/tests/test_tacacs_server_group.rb +434 -0
- data/tests/test_tacacs_server_host.rb +427 -0
- data/tests/test_upgrade.rb +105 -0
- data/tests/test_vdc.rb +64 -0
- data/tests/test_vlan.rb +386 -0
- data/tests/test_vlan_private.rb +656 -0
- data/tests/test_vpc.rb +548 -0
- data/tests/test_vrf.rb +248 -0
- data/tests/test_vrf_af.rb +288 -0
- data/tests/test_vtp.rb +278 -0
- data/tests/test_vxlan_vtep.rb +327 -0
- data/tests/test_vxlan_vtep_vni.rb +326 -0
- data/tests/test_yang.rb +369 -0
- data/tests/test_yum.rb +109 -0
- data/tests/upgrade_info.yaml.example +3 -0
- data/tests/yum_package.yaml +94 -0
- metadata +534 -0
|
@@ -0,0 +1,666 @@
|
|
|
1
|
+
# Copyright (c) 2013-2016 Cisco and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
require_relative 'ciscotest'
|
|
16
|
+
require_relative '../lib/cisco_node_utils/snmpuser'
|
|
17
|
+
|
|
18
|
+
DEFAULT_SNMP_USER_AUTH_PASSWORD = ''
|
|
19
|
+
DEFAULT_SNMP_USER_PRIV_PASSWORD = ''
|
|
20
|
+
DEFAULT_SNMP_USER_GROUP_NAME = 'network-operator'
|
|
21
|
+
|
|
22
|
+
# TestSnmpUser - Minitest for SnmpUser node utility class
|
|
23
|
+
class TestSnmpUser < CiscoTestCase
|
|
24
|
+
@skip_unless_supported = 'snmp_user'
|
|
25
|
+
|
|
26
|
+
@@current_users = nil # rubocop:disable Style/ClassVars
|
|
27
|
+
|
|
28
|
+
def setup
|
|
29
|
+
super
|
|
30
|
+
@test_users = []
|
|
31
|
+
# Get the list of users that exist on the node when we first begin
|
|
32
|
+
@@current_users = SnmpUser.users if @@current_users.nil? # rubocop:disable Style/ClassVars
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def create_user(name, opts='')
|
|
36
|
+
config("snmp-server user #{name} #{opts}")
|
|
37
|
+
@test_users.push(name)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def destroy_user(user)
|
|
41
|
+
@test_users.delete(user.name)
|
|
42
|
+
user.destroy
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def remove_test_users
|
|
46
|
+
SnmpUser.users.values.each do |obj|
|
|
47
|
+
begin
|
|
48
|
+
# Delete users that are in current but also added by these tests.
|
|
49
|
+
if @@current_users.keys.include?(obj.name) && @test_users.include?(obj.name)
|
|
50
|
+
obj.destroy
|
|
51
|
+
# Delete users that are part of test.
|
|
52
|
+
elsif @test_users.include? obj.name
|
|
53
|
+
obj.destroy
|
|
54
|
+
# Do not delete users in current but not in test.
|
|
55
|
+
elsif @@current_users.keys.include? obj.name
|
|
56
|
+
next
|
|
57
|
+
else
|
|
58
|
+
# Delete if not in current or test.
|
|
59
|
+
obj.destroy
|
|
60
|
+
end
|
|
61
|
+
rescue CliError => e
|
|
62
|
+
puts e.message
|
|
63
|
+
puts "retry deleting the user #{obj.name}"
|
|
64
|
+
config("snmp-server user #{obj.name}")
|
|
65
|
+
config("no snmp-server user #{obj.name}")
|
|
66
|
+
next
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def teardown
|
|
72
|
+
# This teardown tries to preserve any non-test snmp-server user entries
|
|
73
|
+
# and only teardown the entries added by this test.
|
|
74
|
+
remove_test_users
|
|
75
|
+
super
|
|
76
|
+
delta = SnmpUser.users.keys - @@current_users.keys
|
|
77
|
+
unless delta.empty?
|
|
78
|
+
# Some platforms are slow, wait for snmp-server user entries to be deleted
|
|
79
|
+
15.times do
|
|
80
|
+
sleep(1)
|
|
81
|
+
node.cache_flush
|
|
82
|
+
delta = SnmpUser.users.keys - @@current_users.keys
|
|
83
|
+
break if delta.empty?
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
assert_empty(delta, 'teardown method did not clean up all users')
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def user_pat(name, group='network-admin')
|
|
90
|
+
group ? /snmp-server user #{name} #{group}/ : /snmp-server user #{name}/
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
## test cases starts here
|
|
94
|
+
|
|
95
|
+
def test_collection_not_empty
|
|
96
|
+
create_user('tester')
|
|
97
|
+
refute_empty(SnmpUser.users,
|
|
98
|
+
'SnmpUser collection is empty')
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def test_create_invalid_args
|
|
102
|
+
args_list = [
|
|
103
|
+
['Empty name',
|
|
104
|
+
['', ['network-admin'],
|
|
105
|
+
:none, '', :none, '', false, ''],
|
|
106
|
+
],
|
|
107
|
+
['Auth password but no authproto',
|
|
108
|
+
['userv3testUnknownAuth', ['network-admin'],
|
|
109
|
+
:none, 'test12345', :none, '', false, ''],
|
|
110
|
+
],
|
|
111
|
+
['Priv password but no privproto',
|
|
112
|
+
['userv3testUnknownPriv', ['network-admin'],
|
|
113
|
+
:sha, 'test12345', :none, 'test12345', false, ''],
|
|
114
|
+
],
|
|
115
|
+
]
|
|
116
|
+
args_list.each do |msg, args|
|
|
117
|
+
assert_raises(ArgumentError, msg) { SnmpUser.new(*args) }
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def test_create_invalid_cli
|
|
122
|
+
args_list = [
|
|
123
|
+
['Cleartext password with localized key',
|
|
124
|
+
['userv3testauthsha1', ['network-admin'],
|
|
125
|
+
:sha, 'test123456', :none, '', true, # localized key
|
|
126
|
+
''],
|
|
127
|
+
],
|
|
128
|
+
['Invalid group name',
|
|
129
|
+
['userv3test', ['network-admin123'],
|
|
130
|
+
:none, '', :none, '', false, ''],
|
|
131
|
+
],
|
|
132
|
+
]
|
|
133
|
+
args_list.each do |msg, args|
|
|
134
|
+
assert_raises(CliError, msg) { SnmpUser.new(*args) }
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def test_engine_id_valid_and_none
|
|
139
|
+
create_user('tester', 'auth sha XXWWPass0wrf engineID 22:22:22:22:23:22')
|
|
140
|
+
create_user('tester2')
|
|
141
|
+
|
|
142
|
+
snmpusers = SnmpUser.users
|
|
143
|
+
|
|
144
|
+
found_tester = false
|
|
145
|
+
found_tester2 = false
|
|
146
|
+
snmpusers.each_value do |snmpuser|
|
|
147
|
+
if snmpuser.name == 'tester'
|
|
148
|
+
assert_equal('22:22:22:22:23:22', snmpuser.engine_id)
|
|
149
|
+
destroy_user(snmpuser)
|
|
150
|
+
found_tester = true
|
|
151
|
+
elsif snmpuser.name == 'tester2'
|
|
152
|
+
assert_equal('', snmpuser.engine_id)
|
|
153
|
+
destroy_user(snmpuser)
|
|
154
|
+
found_tester2 = true
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
assert(found_tester)
|
|
158
|
+
assert(found_tester2)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def test_noauth_nopriv
|
|
162
|
+
name = 'userv3test2'
|
|
163
|
+
groups = ['network-admin']
|
|
164
|
+
snmpuser = SnmpUser.new(name,
|
|
165
|
+
groups,
|
|
166
|
+
:none, '',
|
|
167
|
+
:none, '',
|
|
168
|
+
false,
|
|
169
|
+
'')
|
|
170
|
+
assert_show_match(pattern: user_pat(name),
|
|
171
|
+
command: 'show run snmp all | no-more')
|
|
172
|
+
snmpuser.destroy
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def test_noauth_nopriv_multi
|
|
176
|
+
name = 'userv3test3'
|
|
177
|
+
groups = ['network-admin', 'vdc-admin']
|
|
178
|
+
snmpuser = SnmpUser.new(name,
|
|
179
|
+
groups,
|
|
180
|
+
:none, '',
|
|
181
|
+
:none, '',
|
|
182
|
+
false,
|
|
183
|
+
'')
|
|
184
|
+
s = @device.cmd('show run snmp all | no-more')
|
|
185
|
+
groups.each do |group|
|
|
186
|
+
assert_match(user_pat(name, group), s)
|
|
187
|
+
end
|
|
188
|
+
snmpuser.destroy
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
def test_destroy
|
|
192
|
+
name = 'userv3testdestroy'
|
|
193
|
+
group = 'network-operator'
|
|
194
|
+
create_user(name, group)
|
|
195
|
+
|
|
196
|
+
# get user
|
|
197
|
+
snmpuser = SnmpUser.users[name]
|
|
198
|
+
assert_equal(snmpuser.name, name)
|
|
199
|
+
assert_empty(snmpuser.engine_id)
|
|
200
|
+
# destroy the user
|
|
201
|
+
destroy_user(snmpuser)
|
|
202
|
+
# check user got removed.
|
|
203
|
+
sleep(5)
|
|
204
|
+
node.cache_flush
|
|
205
|
+
refute_show_match(command: 'show run snmp all | no-more',
|
|
206
|
+
pattern: user_pat(name, group))
|
|
207
|
+
assert_nil(SnmpUser.users[name])
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def test_auth_pw_equal_invalid_param
|
|
211
|
+
name = 'testV3PwEqualInvalid2'
|
|
212
|
+
auth_pw = 'TeSt297534'
|
|
213
|
+
create_user(name, "network-admin auth md5 #{auth_pw}")
|
|
214
|
+
|
|
215
|
+
# get users
|
|
216
|
+
refute(SnmpUser.users[name].auth_password_equal?('', false))
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
def test_auth_priv_pw_equal_invalid_param
|
|
220
|
+
name = 'testV3PwEqualInvalid'
|
|
221
|
+
auth_pw = 'XXWWPass0wrf'
|
|
222
|
+
create_user(name, "network-admin auth md5 #{auth_pw} priv #{auth_pw}")
|
|
223
|
+
|
|
224
|
+
# get users
|
|
225
|
+
snmpuser = SnmpUser.users[name]
|
|
226
|
+
refute(snmpuser.auth_password_equal?('', false))
|
|
227
|
+
refute(snmpuser.priv_password_equal?('', false))
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def test_auth_pw_equal_priv_invalid_param
|
|
231
|
+
name = 'testV3PwEqualInvalid'
|
|
232
|
+
auth_pw = 'XXWWPass0wrf'
|
|
233
|
+
create_user(name, "network-operator auth md5 #{auth_pw} priv #{auth_pw}")
|
|
234
|
+
|
|
235
|
+
# get users
|
|
236
|
+
snmpuser = SnmpUser.users[name]
|
|
237
|
+
assert(snmpuser.auth_password_equal?(auth_pw, false))
|
|
238
|
+
refute(snmpuser.priv_password_equal?('', false))
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
def test_auth_pw_not_equal
|
|
242
|
+
name = 'testV3PwEqual'
|
|
243
|
+
auth_pw = 'xxwwpass0r!f'
|
|
244
|
+
create_user(name, "network-admin auth md5 #{auth_pw}")
|
|
245
|
+
|
|
246
|
+
# get users
|
|
247
|
+
snmpuser = SnmpUser.users[name]
|
|
248
|
+
refute(snmpuser.auth_password_equal?('xxwwpass0r!', false))
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
def test_auth_pw_equal
|
|
252
|
+
name = 'testV3PwEqual'
|
|
253
|
+
auth_pw = 'XXWWPass0wrf'
|
|
254
|
+
create_user(name, "network-admin auth md5 #{auth_pw}")
|
|
255
|
+
|
|
256
|
+
# get users
|
|
257
|
+
assert(SnmpUser.users[name].auth_password_equal?(auth_pw, false))
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
def test_auth_priv_pw_equal_empty
|
|
261
|
+
name = 'testV3PwEmpty'
|
|
262
|
+
create_user(name, 'network-admin')
|
|
263
|
+
# nil and "" are treated interchangeably
|
|
264
|
+
assert(SnmpUser.users[name].auth_password_equal?('', false))
|
|
265
|
+
assert(SnmpUser.users[name].priv_password_equal?('', false))
|
|
266
|
+
assert(SnmpUser.users[name].auth_password_equal?(nil, false))
|
|
267
|
+
assert(SnmpUser.users[name].priv_password_equal?(nil, false))
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def test_auth_pw_equal_localizedkey
|
|
271
|
+
name = 'testV3PwEqual'
|
|
272
|
+
auth_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
|
|
273
|
+
create_user(name, "network-admin auth md5 #{auth_pw} localizedkey")
|
|
274
|
+
|
|
275
|
+
# get users
|
|
276
|
+
snmpuser = SnmpUser.users[name]
|
|
277
|
+
assert(snmpuser.auth_password_equal?(auth_pw, true))
|
|
278
|
+
# verify that if we give a wrong password, the api will return false
|
|
279
|
+
refute(snmpuser.auth_password_equal?('0xFe6c', true))
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
def test_auth_priv_pw_equal_localizedkey
|
|
283
|
+
name = 'testV3PwEqual'
|
|
284
|
+
auth_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
|
|
285
|
+
priv_pw = '0x29916eac22d90362598abef1b9045018'
|
|
286
|
+
create_user(name, "network-admin auth md5 #{auth_pw} " \
|
|
287
|
+
"priv aes-128 #{priv_pw} localizedkey")
|
|
288
|
+
|
|
289
|
+
# get users
|
|
290
|
+
snmpuser = SnmpUser.users[name]
|
|
291
|
+
assert(snmpuser.auth_password_equal?(auth_pw, true))
|
|
292
|
+
assert(snmpuser.priv_password_equal?(priv_pw, true))
|
|
293
|
+
refute(snmpuser.priv_password_equal?('0x2291', true))
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def test_auth_priv_des_pw_equal
|
|
297
|
+
name = 'testV3PwEqual'
|
|
298
|
+
auth_pw = 'XXWWPass0wrf'
|
|
299
|
+
priv_pw = 'WWXXPaas0wrf'
|
|
300
|
+
create_user(name, "network-operator auth md5 #{auth_pw} priv #{priv_pw}")
|
|
301
|
+
|
|
302
|
+
# get users
|
|
303
|
+
snmpuser = SnmpUser.users[name]
|
|
304
|
+
assert(snmpuser.auth_password_equal?(auth_pw, false))
|
|
305
|
+
assert(snmpuser.priv_password_equal?(priv_pw, false))
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
def test_auth_md5_nopriv
|
|
309
|
+
name = 'userv3test5'
|
|
310
|
+
groups = ['network-admin']
|
|
311
|
+
auth_pw = 'XXWWPass0wrf'
|
|
312
|
+
snmpuser = SnmpUser.new(name,
|
|
313
|
+
groups,
|
|
314
|
+
:md5, auth_pw,
|
|
315
|
+
:none, '',
|
|
316
|
+
false, # clear text
|
|
317
|
+
'')
|
|
318
|
+
assert_show_match(
|
|
319
|
+
pattern: /#{user_pat(name)} auth md5 \S+ localizedkey/,
|
|
320
|
+
command: "show run snmp all | in #{name} | no-more")
|
|
321
|
+
snmpuser.destroy
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
def test_auth_md5_nopriv_pw_localized
|
|
325
|
+
name = 'userv3testauth'
|
|
326
|
+
groups = ['network-admin']
|
|
327
|
+
auth_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
|
|
328
|
+
snmpuser = SnmpUser.new(name,
|
|
329
|
+
groups,
|
|
330
|
+
:md5, auth_pw,
|
|
331
|
+
:none, '',
|
|
332
|
+
true, # localized
|
|
333
|
+
'')
|
|
334
|
+
assert_equal(snmpuser.name, name)
|
|
335
|
+
assert_empty(snmpuser.engine_id)
|
|
336
|
+
assert_show_match(
|
|
337
|
+
pattern: /#{user_pat(name)} auth md5 #{auth_pw} localizedkey/,
|
|
338
|
+
command: "show run snmp all | in #{name} | no-more")
|
|
339
|
+
snmpuser.destroy
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
def test_auth_sha_nopriv
|
|
343
|
+
name = 'userv3testsha'
|
|
344
|
+
groups = ['network-admin']
|
|
345
|
+
auth_pw = 'XXWWPass0wrf'
|
|
346
|
+
snmpuser = SnmpUser.new(name,
|
|
347
|
+
groups,
|
|
348
|
+
:sha, auth_pw,
|
|
349
|
+
:none, '',
|
|
350
|
+
false, # clear text
|
|
351
|
+
'')
|
|
352
|
+
assert_show_match(
|
|
353
|
+
pattern: /#{user_pat(name)} auth sha \S+ localizedkey/,
|
|
354
|
+
command: "show run snmp all | in #{name} | no-more")
|
|
355
|
+
snmpuser.destroy
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
# If the auth pw is in hex and localized key param in constructor is false,
|
|
359
|
+
# then the pw got localized by the device again.
|
|
360
|
+
def test_auth_sha_nopriv_pw_localized_false
|
|
361
|
+
name = 'userv3testauthsha3'
|
|
362
|
+
groups = ['network-admin']
|
|
363
|
+
auth_pw = '0xFe6cf9aea159c2c38e0a79ec23ed3cbb'
|
|
364
|
+
|
|
365
|
+
snmpuser = SnmpUser.new(name,
|
|
366
|
+
groups,
|
|
367
|
+
:sha, auth_pw,
|
|
368
|
+
:none, '',
|
|
369
|
+
false, # localized key
|
|
370
|
+
'')
|
|
371
|
+
assert_show_match(
|
|
372
|
+
pattern: /#{user_pat(name)} auth sha \S+ localizedkey/,
|
|
373
|
+
command: "show run snmp all | in #{name} | no-more")
|
|
374
|
+
snmpuser.destroy
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
def test_auth_sha_nopriv_pw_localized
|
|
378
|
+
name = 'userv3testauthsha4'
|
|
379
|
+
groups = ['network-admin']
|
|
380
|
+
auth_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
|
|
381
|
+
snmpuser = SnmpUser.new(name,
|
|
382
|
+
groups,
|
|
383
|
+
:sha, auth_pw,
|
|
384
|
+
:none, '',
|
|
385
|
+
true, # localized
|
|
386
|
+
'')
|
|
387
|
+
assert_show_match(
|
|
388
|
+
pattern: /#{user_pat(name)} auth sha #{auth_pw} localizedkey/,
|
|
389
|
+
command: "show run snmp all | in #{name} | no-more")
|
|
390
|
+
snmpuser.destroy
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
def test_auth_md5_priv_des
|
|
394
|
+
name = 'userv3test6'
|
|
395
|
+
groups = ['network-admin']
|
|
396
|
+
auth_pw = 'XXWWPass0wrf'
|
|
397
|
+
priv_pw = 'Priv973ApQsX'
|
|
398
|
+
snmpuser = SnmpUser.new(name,
|
|
399
|
+
groups,
|
|
400
|
+
:md5, auth_pw,
|
|
401
|
+
:des, priv_pw,
|
|
402
|
+
false, # clear text
|
|
403
|
+
'')
|
|
404
|
+
assert_show_match(
|
|
405
|
+
pattern: /#{user_pat(name)} auth md5 \S+ priv \S+ localizedkey/,
|
|
406
|
+
command: "show run snmp all | in #{name} | no-more")
|
|
407
|
+
snmpuser.destroy
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
def test_auth_md5_priv_des_pw_localized
|
|
411
|
+
name = 'userv3testauth'
|
|
412
|
+
groups = ['network-admin']
|
|
413
|
+
auth_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
|
|
414
|
+
priv_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
|
|
415
|
+
snmpuser = SnmpUser.new(name,
|
|
416
|
+
groups,
|
|
417
|
+
:md5, auth_pw,
|
|
418
|
+
:des, priv_pw,
|
|
419
|
+
true, # localized
|
|
420
|
+
'')
|
|
421
|
+
assert_show_match(
|
|
422
|
+
pattern: /#{user_pat(name)} auth md5 #{auth_pw} priv #{priv_pw} localizedkey/,
|
|
423
|
+
command: "show run snmp all | in #{name} | no-more")
|
|
424
|
+
snmpuser.destroy
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
def test_auth_md5_priv_aes128
|
|
428
|
+
name = 'userv3test7'
|
|
429
|
+
groups = ['network-admin']
|
|
430
|
+
auth_pw = 'XXWWPass0wrf'
|
|
431
|
+
priv_pw = 'Priv973ApQsX'
|
|
432
|
+
snmpuser = SnmpUser.new(name,
|
|
433
|
+
groups,
|
|
434
|
+
:md5, auth_pw,
|
|
435
|
+
:aes128, priv_pw,
|
|
436
|
+
false, # clear text
|
|
437
|
+
'')
|
|
438
|
+
assert_show_match(
|
|
439
|
+
pattern: /#{user_pat(name)} auth md5 \S+ priv aes-128 \S+ localizedkey/,
|
|
440
|
+
command: "show run snmp all | in #{name} | no-more")
|
|
441
|
+
snmpuser.destroy
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
def test_auth_md5_priv_aes128_pw_localized
|
|
445
|
+
name = 'userv3testauth'
|
|
446
|
+
groups = ['network-admin']
|
|
447
|
+
auth_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
|
|
448
|
+
priv_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
|
|
449
|
+
snmpuser = SnmpUser.new(name,
|
|
450
|
+
groups,
|
|
451
|
+
:md5, auth_pw,
|
|
452
|
+
:aes128, priv_pw,
|
|
453
|
+
true, # localized
|
|
454
|
+
'')
|
|
455
|
+
assert_show_match(
|
|
456
|
+
pattern: /#{user_pat(name)} auth md5 #{auth_pw} priv aes-128 #{priv_pw} localizedkey/,
|
|
457
|
+
command: "show run snmp all | in #{name} | no-more")
|
|
458
|
+
snmpuser.destroy
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
def test_auth_sha_priv_des
|
|
462
|
+
name = 'userv3test8'
|
|
463
|
+
groups = ['network-admin']
|
|
464
|
+
auth_pw = 'XXWWPass0wrf'
|
|
465
|
+
priv_pw = 'Priv973ApQsX'
|
|
466
|
+
snmpuser = SnmpUser.new(name,
|
|
467
|
+
groups,
|
|
468
|
+
:sha, auth_pw,
|
|
469
|
+
:des, priv_pw,
|
|
470
|
+
false, # clear text
|
|
471
|
+
'')
|
|
472
|
+
assert_show_match(
|
|
473
|
+
pattern: /#{user_pat(name)} auth sha \S+ priv \S+ localizedkey/,
|
|
474
|
+
command: "show run snmp all | in #{name} | no-more")
|
|
475
|
+
snmpuser.destroy
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
def test_auth_md5_priv_sha_pw_localized
|
|
479
|
+
name = 'userv3testauth'
|
|
480
|
+
groups = ['network-admin']
|
|
481
|
+
auth_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
|
|
482
|
+
priv_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
|
|
483
|
+
snmpuser = SnmpUser.new(name,
|
|
484
|
+
groups,
|
|
485
|
+
:sha, auth_pw,
|
|
486
|
+
:des, priv_pw,
|
|
487
|
+
true, # localized
|
|
488
|
+
'')
|
|
489
|
+
assert_show_match(
|
|
490
|
+
pattern: /#{user_pat(name)} auth sha #{auth_pw} priv #{priv_pw} localizedkey/,
|
|
491
|
+
command: "show run snmp all | in #{name} | no-more")
|
|
492
|
+
snmpuser.destroy
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
def test_auth_sha_priv_aes128
|
|
496
|
+
name = 'userv3test9'
|
|
497
|
+
groups = ['network-admin']
|
|
498
|
+
auth_pw = 'XXWWPass0wrf'
|
|
499
|
+
priv_pw = 'Priv973ApQsX'
|
|
500
|
+
snmpuser = SnmpUser.new(name,
|
|
501
|
+
groups,
|
|
502
|
+
:sha, auth_pw,
|
|
503
|
+
:aes128, priv_pw,
|
|
504
|
+
false, # clear text
|
|
505
|
+
'')
|
|
506
|
+
assert_show_match(
|
|
507
|
+
pattern: /#{user_pat(name)} auth sha \S+ priv aes-128 \S+ localizedkey/,
|
|
508
|
+
command: "show run snmp all | in #{name} | no-more")
|
|
509
|
+
snmpuser.destroy
|
|
510
|
+
end
|
|
511
|
+
|
|
512
|
+
def test_auth_sha_priv_aes128_pw_localized
|
|
513
|
+
name = 'userv3testauth'
|
|
514
|
+
groups = ['network-admin']
|
|
515
|
+
auth_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
|
|
516
|
+
priv_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
|
|
517
|
+
snmpuser = SnmpUser.new(name,
|
|
518
|
+
groups,
|
|
519
|
+
:sha, auth_pw,
|
|
520
|
+
:aes128, priv_pw,
|
|
521
|
+
true, # localized
|
|
522
|
+
'')
|
|
523
|
+
assert_show_match(
|
|
524
|
+
pattern: /#{user_pat(name)} auth sha #{auth_pw} priv aes-128 #{priv_pw} localizedkey/,
|
|
525
|
+
command: "show run snmp all | in #{name} | no-more")
|
|
526
|
+
snmpuser.destroy
|
|
527
|
+
end
|
|
528
|
+
|
|
529
|
+
def test_create_destroy_with_engine_id
|
|
530
|
+
name = 'test_with_engine_id'
|
|
531
|
+
auth_pw = 'XXWWPass0wrf'
|
|
532
|
+
priv_pw = 'XXWWPass0wrf'
|
|
533
|
+
engine_id = '128:12:12:12:12'
|
|
534
|
+
snmpuser = SnmpUser.new(name, [''], :md5, auth_pw, :des, priv_pw,
|
|
535
|
+
false, engine_id)
|
|
536
|
+
assert_show_match(
|
|
537
|
+
pattern: /snmp-server user #{name} auth \S+ \S+ priv .*\S+ localizedkey engineID #{engine_id}/,
|
|
538
|
+
command: "show run snmp all | in #{name} | no-more")
|
|
539
|
+
user = SnmpUser.users["#{name} #{engine_id}"]
|
|
540
|
+
refute_nil(user)
|
|
541
|
+
assert_equal(snmpuser.name, user.name)
|
|
542
|
+
assert_equal(snmpuser.name, name)
|
|
543
|
+
assert_equal(snmpuser.engine_id, engine_id)
|
|
544
|
+
assert_equal(snmpuser.engine_id, user.engine_id)
|
|
545
|
+
snmpuser.destroy
|
|
546
|
+
refute_show_match(
|
|
547
|
+
pattern: /snmp-server user #{name} auth \S+ \S+ priv .*\S+ localizedkey engineID #{engine_id}/,
|
|
548
|
+
command: "show run snmp all | in #{name} | no-more")
|
|
549
|
+
assert_nil(SnmpUser.users["#{name} #{engine_id}"])
|
|
550
|
+
end
|
|
551
|
+
|
|
552
|
+
def test_authpassword
|
|
553
|
+
name = 'test_authpassword'
|
|
554
|
+
auth_pw = '0x123456'
|
|
555
|
+
snmpuser = SnmpUser.new(name, [''], :md5, auth_pw, :none, '', true, '')
|
|
556
|
+
|
|
557
|
+
pw = snmpuser.auth_password
|
|
558
|
+
assert_equal(auth_pw, pw)
|
|
559
|
+
snmpuser.destroy
|
|
560
|
+
end
|
|
561
|
+
|
|
562
|
+
def test_authpassword_with_engineid
|
|
563
|
+
name = 'test_authpassword'
|
|
564
|
+
auth_pw = '0x123456'
|
|
565
|
+
engine_id = '128:12:12:12:12'
|
|
566
|
+
snmpuser = SnmpUser.new(name, [''], :md5, auth_pw,
|
|
567
|
+
:none, '', true, engine_id)
|
|
568
|
+
|
|
569
|
+
pw = snmpuser.auth_password
|
|
570
|
+
assert_equal(auth_pw, pw)
|
|
571
|
+
snmpuser.destroy
|
|
572
|
+
end
|
|
573
|
+
|
|
574
|
+
def test_privpassword
|
|
575
|
+
priv_password = '0x123456'
|
|
576
|
+
snmpuser = SnmpUser.new('test_pp1', [''], :md5, priv_password,
|
|
577
|
+
:des, priv_password, true, '')
|
|
578
|
+
|
|
579
|
+
pw = snmpuser.priv_password
|
|
580
|
+
assert_equal(priv_password, pw)
|
|
581
|
+
snmpuser.destroy
|
|
582
|
+
|
|
583
|
+
snmpuser = SnmpUser.new('test_pp2', [''], :md5, priv_password,
|
|
584
|
+
:aes128, priv_password, true, '')
|
|
585
|
+
pw = snmpuser.priv_password
|
|
586
|
+
assert_equal(priv_password, pw)
|
|
587
|
+
snmpuser.destroy
|
|
588
|
+
end
|
|
589
|
+
|
|
590
|
+
def test_privpassword_with_engineid
|
|
591
|
+
priv_password = '0x123456'
|
|
592
|
+
engine_id = '128:12:12:12:12'
|
|
593
|
+
snmpuser = SnmpUser.new('test_pp3', [''], :md5, priv_password,
|
|
594
|
+
:des, priv_password, true, engine_id)
|
|
595
|
+
pw = snmpuser.priv_password
|
|
596
|
+
assert_equal(priv_password, pw)
|
|
597
|
+
snmpuser.destroy
|
|
598
|
+
|
|
599
|
+
snmpuser = SnmpUser.new('test_pp4', [''], :md5, priv_password,
|
|
600
|
+
:aes128, priv_password, true, '')
|
|
601
|
+
pw = snmpuser.priv_password
|
|
602
|
+
assert_equal(priv_password, pw)
|
|
603
|
+
snmpuser.destroy
|
|
604
|
+
end
|
|
605
|
+
|
|
606
|
+
def test_auth_password_equal_with_engineid
|
|
607
|
+
name = 'test_authpass_equal'
|
|
608
|
+
auth_pass = 'XXWWPass0wrf'
|
|
609
|
+
engine_id = '128:12:12:12:12'
|
|
610
|
+
|
|
611
|
+
snmpuser = SnmpUser.new(name, [''], :md5, auth_pass, :none, '', false,
|
|
612
|
+
engine_id)
|
|
613
|
+
|
|
614
|
+
assert(snmpuser.auth_password_equal?(auth_pass, false))
|
|
615
|
+
# our api should be able to detect wrong password
|
|
616
|
+
refute(snmpuser.auth_password_equal?('WWXXPass0wrf', false))
|
|
617
|
+
snmpuser.destroy
|
|
618
|
+
end
|
|
619
|
+
|
|
620
|
+
def test_priv_password_equal_with_engineid
|
|
621
|
+
priv_pass = 'XXWWPass0wrf'
|
|
622
|
+
engine_id = '128:12:12:12:12'
|
|
623
|
+
|
|
624
|
+
snmpuser = SnmpUser.new('test_pp5', [''], :md5, priv_pass, :des, priv_pass, false,
|
|
625
|
+
engine_id)
|
|
626
|
+
assert(snmpuser.priv_password_equal?(priv_pass, false))
|
|
627
|
+
refute(snmpuser.priv_password_equal?('tWWXXpass0wrf', false))
|
|
628
|
+
snmpuser.destroy
|
|
629
|
+
|
|
630
|
+
snmpuser = SnmpUser.new('test_pp6', [''], :md5, priv_pass,
|
|
631
|
+
:aes128, priv_pass, false, engine_id)
|
|
632
|
+
assert(snmpuser.priv_password_equal?(priv_pass, false))
|
|
633
|
+
refute(snmpuser.priv_password_equal?('tWWXXpass0wrf', false))
|
|
634
|
+
snmpuser.destroy
|
|
635
|
+
end
|
|
636
|
+
|
|
637
|
+
def test_default_groups
|
|
638
|
+
groups = [DEFAULT_SNMP_USER_GROUP_NAME]
|
|
639
|
+
assert_equal(groups, SnmpUser.default_groups,
|
|
640
|
+
'Error: Wrong default groups')
|
|
641
|
+
end
|
|
642
|
+
|
|
643
|
+
def test_default_auth_protocol
|
|
644
|
+
assert_equal(:md5,
|
|
645
|
+
SnmpUser.default_auth_protocol,
|
|
646
|
+
'Error: Wrong default auth protocol')
|
|
647
|
+
end
|
|
648
|
+
|
|
649
|
+
def test_default_auth_password
|
|
650
|
+
assert_equal(DEFAULT_SNMP_USER_AUTH_PASSWORD,
|
|
651
|
+
SnmpUser.default_auth_password,
|
|
652
|
+
'Error: Wrong default auth password')
|
|
653
|
+
end
|
|
654
|
+
|
|
655
|
+
def test_default_priv_protocol
|
|
656
|
+
assert_equal(:des,
|
|
657
|
+
SnmpUser.default_priv_protocol,
|
|
658
|
+
'Error: Wrong default priv protocol')
|
|
659
|
+
end
|
|
660
|
+
|
|
661
|
+
def test_default_priv_password
|
|
662
|
+
assert_equal(DEFAULT_SNMP_USER_PRIV_PASSWORD,
|
|
663
|
+
SnmpUser.default_priv_password,
|
|
664
|
+
'Error: Wrong default priv password')
|
|
665
|
+
end
|
|
666
|
+
end
|