cisco_node_utils_mgx 2.1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,874 @@
|
|
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 'yaml'
|
16
|
+
require_relative 'ciscotest'
|
17
|
+
require_relative '../lib/cisco_node_utils/aaa_authorization_service'
|
18
|
+
|
19
|
+
# TestAaaAuthorizationService - Minitest for AaaAuthorizationService util
|
20
|
+
class TestAaaAuthorSvc < CiscoTestCase
|
21
|
+
@skip_unless_supported = 'aaa_authorization_service'
|
22
|
+
@@pre_clean_needed = true # rubocop:disable Style/ClassVars
|
23
|
+
|
24
|
+
def setup
|
25
|
+
super
|
26
|
+
|
27
|
+
skip_legacy_defect?('7.0.3.I3.1',
|
28
|
+
'CSCuz44696: Cannot configure aaa group server tacacs')
|
29
|
+
cleanup_aaa if @@pre_clean_needed
|
30
|
+
@@pre_clean_needed = false # rubocop:disable Style/ClassVars
|
31
|
+
feature_tacacs
|
32
|
+
preconfig_tacacs_server_access(tacacs_groups[0])
|
33
|
+
config_tacacs_servers(tacacs_groups[1..3])
|
34
|
+
end
|
35
|
+
|
36
|
+
def teardown
|
37
|
+
cleanup_aaa
|
38
|
+
feature_tacacs(false)
|
39
|
+
super
|
40
|
+
end
|
41
|
+
|
42
|
+
def cleanup_aaa
|
43
|
+
cmds = config('show run aaa').scan(/^aaa auth.*/)
|
44
|
+
cmds.each do |cmd|
|
45
|
+
cmd = strip_local(cmd) unless AaaAuthorizationService.remove_local_auth
|
46
|
+
config("no #{cmd}")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def config_tacacs_servers(servers)
|
51
|
+
servers.each do |server|
|
52
|
+
config("aaa group server tacacs+ #{server}")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def feature_tacacs(feature=true)
|
57
|
+
state = feature ? '' : 'no'
|
58
|
+
config("#{state} feature tacacs+")
|
59
|
+
end
|
60
|
+
|
61
|
+
def strip_local(config_string)
|
62
|
+
# AAA authorization method 'local' is a prerequisite for several tests in
|
63
|
+
# this suite but once configured by design is not allowed to be removed on
|
64
|
+
# certain nxos platforms.
|
65
|
+
config_string.gsub('local', '')
|
66
|
+
end
|
67
|
+
|
68
|
+
# Helper method to get regexp for aaa authorization commands
|
69
|
+
def get_pattern(cmd_type, service, groups, method=:unselected)
|
70
|
+
cmd_type = cmd_type == :config_commands ? 'config-commands' : cmd_type.to_s
|
71
|
+
groups = groups.join(' ') if groups.is_a? Array
|
72
|
+
method = method == :unselected ? '' : method.to_s
|
73
|
+
p = prefix
|
74
|
+
p << ' ' + cmd_type
|
75
|
+
p << ' ' + service
|
76
|
+
p << ' group ' + groups unless groups.empty?
|
77
|
+
p << ' ' + method unless method.empty?
|
78
|
+
Regexp.new(p)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Pre-configure the user-defined tacacs server in tests/tacacs_server.yaml
|
82
|
+
def preconfig_tacacs_server_access(group_name)
|
83
|
+
path = File.expand_path('../tacacs_server.yaml', __FILE__)
|
84
|
+
skip('Cannot find tests/tacacs_server.yaml') unless File.file?(path)
|
85
|
+
cfg = YAML.load(File.read(path))
|
86
|
+
valid_cfg?(cfg)
|
87
|
+
config("tacacs-server host #{cfg['host']} key #{cfg['key']}",
|
88
|
+
"aaa group server tacacs+ #{group_name}",
|
89
|
+
"server #{cfg['host']}",
|
90
|
+
"use-vrf #{cfg['vrf']}",
|
91
|
+
"source-interface #{cfg['intf']}",
|
92
|
+
'aaa authentication login ascii-authentication')
|
93
|
+
valid_server?(cfg['host'])
|
94
|
+
end
|
95
|
+
|
96
|
+
def prefix
|
97
|
+
'aaa authorization'
|
98
|
+
end
|
99
|
+
|
100
|
+
def show_cmd
|
101
|
+
'show run aaa all | no-more'
|
102
|
+
end
|
103
|
+
|
104
|
+
def tacacs_groups
|
105
|
+
%w(tac_group bxb100 sjc200 rtp10)
|
106
|
+
end
|
107
|
+
|
108
|
+
def valid_cfg?(cfg)
|
109
|
+
skip('tests/tacacs_server.yaml file is empty') unless cfg
|
110
|
+
msg = 'Missing key in tests/tacacs_server.yaml'
|
111
|
+
%w(host key vrf intf).each do |key|
|
112
|
+
skip("#{msg}: #{key}") if cfg[key].nil?
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def valid_server?(host)
|
117
|
+
test_aaa = config("test aaa server tacacs+ #{host} test test")
|
118
|
+
# Valid tacacs server will return message regarding user authentication
|
119
|
+
valid = test_aaa[/^user has \S+ authenticat(ed|ion)/]
|
120
|
+
fail "Host '#{host}' is either not a valid tacacs server " \
|
121
|
+
'or not reachable' unless valid
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_create_unsupported_type
|
125
|
+
assert_raises(ArgumentError) do
|
126
|
+
AaaAuthorizationService.new(:none, 'default')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_nil_type
|
131
|
+
assert_raises(TypeError) do
|
132
|
+
AaaAuthorizationService.new(nil, 'default')
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_type_inv
|
137
|
+
assert_raises(TypeError) do
|
138
|
+
AaaAuthorizationService.new('test', 'default')
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_range_type_inv
|
143
|
+
assert_raises(TypeError) do
|
144
|
+
AaaAuthorizationService.new(34, 'default')
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_svc_inv
|
149
|
+
assert_raises(ArgumentError) do
|
150
|
+
AaaAuthorizationService.new(:commands, 'test')
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_empty_svc
|
155
|
+
assert_raises(ArgumentError) do
|
156
|
+
AaaAuthorizationService.new(:commands, '')
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_cmds_def
|
161
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'default')
|
162
|
+
refute_nil(aaa_a_service,
|
163
|
+
'Error: AaaAuthorizationService creating commands default')
|
164
|
+
aaa_a_service.destroy unless aaa_a_service.nil?
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_cmds_con
|
168
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'console')
|
169
|
+
refute_nil(aaa_a_service,
|
170
|
+
'Error: AaaAuthorizationService creating commands default')
|
171
|
+
aaa_a_service.destroy unless aaa_a_service.nil?
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_cfg_cmds_def
|
175
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'default')
|
176
|
+
refute_nil(aaa_a_service,
|
177
|
+
'Error: AaaAuthorizationService creating ' \
|
178
|
+
'config-commands default')
|
179
|
+
aaa_a_service.destroy unless aaa_a_service.nil?
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_cfg_cmds_con
|
183
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'console')
|
184
|
+
refute_nil(aaa_a_service,
|
185
|
+
'Error: AaaAuthorizationService creating commands default')
|
186
|
+
aaa_a_service.destroy unless aaa_a_service.nil?
|
187
|
+
end
|
188
|
+
|
189
|
+
def test_get_type
|
190
|
+
type = :config_commands
|
191
|
+
aaa_a_service = AaaAuthorizationService.new(type, 'default')
|
192
|
+
assert_equal(type, aaa_a_service.type, 'Error : Invalid type')
|
193
|
+
aaa_a_service.destroy
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_get_name
|
197
|
+
service = 'default'
|
198
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, service)
|
199
|
+
assert_equal(service, aaa_a_service.name, 'Error : Invalid service name')
|
200
|
+
aaa_a_service.destroy
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_collect_inv
|
204
|
+
assert_nil(AaaAuthorizationService.services['TEST'])
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_collect_svc_cmds
|
208
|
+
type = :commands
|
209
|
+
collection = AaaAuthorizationService.services[type]
|
210
|
+
|
211
|
+
# Collection will not be empty since tacacs feature is enabled.
|
212
|
+
refute_empty(collection,
|
213
|
+
'Error: AaaAuthorizationService collection is not filled')
|
214
|
+
assert_equal(2, collection.size,
|
215
|
+
'Error: AaaAuthorizationService collection not correct size')
|
216
|
+
assert(collection.key?('default'),
|
217
|
+
'Error: AaaAuthorizationService collection does contain default')
|
218
|
+
assert(collection.key?('console'),
|
219
|
+
'Error: AaaAuthorizationService collection does contain console')
|
220
|
+
|
221
|
+
collection.each do |service, aaa_a_service|
|
222
|
+
assert_equal(service, aaa_a_service.name,
|
223
|
+
'Error: Invalid AaaAuthorizationService ' \
|
224
|
+
"#{service} in collection")
|
225
|
+
|
226
|
+
method = :local
|
227
|
+
assert_equal(method, aaa_a_service.method,
|
228
|
+
'Error: Invalid AaaAuthorizationService method for ' \
|
229
|
+
"#{service} in collection")
|
230
|
+
|
231
|
+
groups = []
|
232
|
+
assert_equal(groups, aaa_a_service.groups,
|
233
|
+
'Error: Invalid AaaAuthorizationService groups for ' \
|
234
|
+
"#{service} in collection")
|
235
|
+
aaa_a_service.destroy
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
def test_collect_svc_cfg_cmds
|
240
|
+
type = :config_commands
|
241
|
+
collection = AaaAuthorizationService.services[type]
|
242
|
+
|
243
|
+
# Collection will not be empty since tacacs feature is enabled.
|
244
|
+
refute_empty(collection,
|
245
|
+
'Error: AaaAuthorizationService collection is not filled')
|
246
|
+
assert_equal(2, collection.size,
|
247
|
+
'Error: AaaAuthorizationService collection not correct size')
|
248
|
+
assert(collection.key?('default'),
|
249
|
+
'Error: AaaAuthorizationService collection does contain default')
|
250
|
+
assert(collection.key?('console'),
|
251
|
+
'Error: AaaAuthorizationService collection does contain console')
|
252
|
+
|
253
|
+
collection.each do |service, aaa_a_service|
|
254
|
+
assert_equal(service, aaa_a_service.name,
|
255
|
+
"Error: Invalid AaaAuthorizationService #{service} " \
|
256
|
+
'in collection')
|
257
|
+
assert_equal(:local, aaa_a_service.method,
|
258
|
+
'Error: Invalid AaaAuthorizationService method for ' \
|
259
|
+
"#{service} in collection")
|
260
|
+
|
261
|
+
# Due to preconfig groups will indeed be populated
|
262
|
+
groups = []
|
263
|
+
assert_equal(groups, aaa_a_service.groups,
|
264
|
+
'Error: Invalid AaaAuthorizationService groups for ' \
|
265
|
+
"#{service} in collection")
|
266
|
+
aaa_a_service.destroy
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_type_cmds_def_con_grp
|
271
|
+
# Preconfig AAA Authorization
|
272
|
+
cmd1 = 'aaa authorization commands default group group2 group1 local'
|
273
|
+
cmd2 = 'aaa authorization commands console group group1 local'
|
274
|
+
config('aaa group server tacacs+ group1',
|
275
|
+
'aaa group server tacacs+ group2',
|
276
|
+
cmd1)
|
277
|
+
|
278
|
+
type = :commands
|
279
|
+
collection = AaaAuthorizationService.services[type]
|
280
|
+
refute_empty(collection,
|
281
|
+
'Error: AaaAuthorizationService collection is not filled')
|
282
|
+
assert_equal(2, collection.size,
|
283
|
+
'Error: AaaAuthorizationService collection not ' \
|
284
|
+
'reporting correct size')
|
285
|
+
assert(collection.key?('default'),
|
286
|
+
'Error: AaaAuthorizationService collection does contain default')
|
287
|
+
assert(collection.key?('console'),
|
288
|
+
'Error: AaaAuthorizationService collection does contain console')
|
289
|
+
|
290
|
+
service = 'default'
|
291
|
+
aaa_a_service = collection[service]
|
292
|
+
|
293
|
+
assert_equal(service, aaa_a_service.name,
|
294
|
+
"Error: Invalid AaaAuthorizationService #{service} " \
|
295
|
+
'in collection')
|
296
|
+
|
297
|
+
assert_equal(:local, aaa_a_service.method,
|
298
|
+
'Error: Invalid AaaAuthorizationService method for ' \
|
299
|
+
'default in collection')
|
300
|
+
groups = %w(group2 group1)
|
301
|
+
assert_equal(groups, aaa_a_service.groups,
|
302
|
+
'Error: Invalid AaaAuthorizationService groups for ' \
|
303
|
+
'default in collection')
|
304
|
+
|
305
|
+
# only one of default or console can be configured at a time without
|
306
|
+
# locking the CLI
|
307
|
+
config("no #{strip_local(cmd1)}", cmd2)
|
308
|
+
|
309
|
+
service = 'console'
|
310
|
+
aaa_a_service = collection[service]
|
311
|
+
|
312
|
+
assert_equal(:local, aaa_a_service.method,
|
313
|
+
'Error: Invalid AaaAuthorizationService method for ' \
|
314
|
+
'console in collection')
|
315
|
+
groups = ['group1']
|
316
|
+
assert_equal(groups, aaa_a_service.groups,
|
317
|
+
'Error: Invalid AaaAuthorizationService groups for ' \
|
318
|
+
'console in collection')
|
319
|
+
end
|
320
|
+
|
321
|
+
def test_type_cfg_cmds_def_con_grp
|
322
|
+
# Preconfig AAA Authorization
|
323
|
+
cmd1 = 'aaa authorization config-commands default group group2 group1 local'
|
324
|
+
cmd2 = 'aaa authorization config-commands console group group1 local'
|
325
|
+
config('aaa group server tacacs+ group1',
|
326
|
+
'aaa group server tacacs+ group2',
|
327
|
+
cmd1)
|
328
|
+
|
329
|
+
type = :config_commands
|
330
|
+
collection = AaaAuthorizationService.services[type]
|
331
|
+
refute_empty(collection,
|
332
|
+
'Error: AaaAuthorizationService collection is not filled')
|
333
|
+
assert_equal(2, collection.size,
|
334
|
+
'Error: AaaAuthorizationService collection not ' \
|
335
|
+
'reporting correct size')
|
336
|
+
assert(collection.key?('default'),
|
337
|
+
'Error: AaaAuthorizationService collection does contain default')
|
338
|
+
assert(collection.key?('console'),
|
339
|
+
'Error: AaaAuthorizationService collection does contain console')
|
340
|
+
|
341
|
+
service = 'default'
|
342
|
+
aaa_a_service = collection[service]
|
343
|
+
|
344
|
+
assert_equal(service, aaa_a_service.name,
|
345
|
+
"Error: Invalid AaaAuthorizationService #{service} " \
|
346
|
+
'in collection')
|
347
|
+
|
348
|
+
assert_equal(:local, aaa_a_service.method,
|
349
|
+
'Error: Invalid AaaAuthorizationService method ' \
|
350
|
+
'for default in collection')
|
351
|
+
groups = %w(group2 group1)
|
352
|
+
assert_equal(groups, aaa_a_service.groups,
|
353
|
+
'Error: Invalid AaaAuthorizationService groups ' \
|
354
|
+
'for default in collection')
|
355
|
+
|
356
|
+
config("no #{strip_local(cmd1)}", cmd2)
|
357
|
+
|
358
|
+
service = 'console'
|
359
|
+
aaa_a_service = collection[service]
|
360
|
+
|
361
|
+
assert_equal(:local, aaa_a_service.method,
|
362
|
+
'Error: Invalid AaaAuthorizationService method ' \
|
363
|
+
'for console in collection')
|
364
|
+
groups = ['group1']
|
365
|
+
assert_equal(groups, aaa_a_service.groups,
|
366
|
+
'Error: Invalid AaaAuthorizationService groups ' \
|
367
|
+
'for console in collection')
|
368
|
+
end
|
369
|
+
|
370
|
+
def test_get_def_method
|
371
|
+
type = :commands
|
372
|
+
aaa_a_service = AaaAuthorizationService.new(type, 'default')
|
373
|
+
assert_equal(:local, aaa_a_service.default_method,
|
374
|
+
'Error: AaaAuthorizationService command default, ' \
|
375
|
+
'default method')
|
376
|
+
aaa_a_service.destroy
|
377
|
+
|
378
|
+
aaa_a_service = AaaAuthorizationService.new(type, 'console')
|
379
|
+
assert_equal(:local, aaa_a_service.default_method,
|
380
|
+
'Error: AaaAuthorizationService command console, ' \
|
381
|
+
'default method')
|
382
|
+
aaa_a_service.destroy
|
383
|
+
|
384
|
+
type = :config_commands
|
385
|
+
aaa_a_service = AaaAuthorizationService.new(type, 'default')
|
386
|
+
assert_equal(:local, aaa_a_service.default_method,
|
387
|
+
'Error: AaaAuthorizationService config-command ' \
|
388
|
+
'default, default method')
|
389
|
+
aaa_a_service.destroy
|
390
|
+
|
391
|
+
aaa_a_service = AaaAuthorizationService.new(type, 'console')
|
392
|
+
assert_equal(:local, aaa_a_service.default_method,
|
393
|
+
'Error: AaaAuthorizationService config-command ' \
|
394
|
+
'console, default method')
|
395
|
+
aaa_a_service.destroy
|
396
|
+
end
|
397
|
+
|
398
|
+
def test_collect_grps_cmds_def
|
399
|
+
type = :commands
|
400
|
+
aaa_a_service = AaaAuthorizationService.new(type, 'default')
|
401
|
+
|
402
|
+
# Default case
|
403
|
+
assert_equal(aaa_a_service.default_groups, aaa_a_service.groups,
|
404
|
+
'Error: AaaAuthorizationService commands, ' \
|
405
|
+
'get groups for default')
|
406
|
+
|
407
|
+
config('aaa authorization commands default group ' \
|
408
|
+
"#{tacacs_groups[0..2].join(' ')}")
|
409
|
+
|
410
|
+
assert_equal(tacacs_groups[0..2], aaa_a_service.groups)
|
411
|
+
assert_equal(:unselected, aaa_a_service.method)
|
412
|
+
|
413
|
+
# Change the config to have different groups and method
|
414
|
+
cmd0 = 'aaa authorization commands default group ' \
|
415
|
+
"#{tacacs_groups[0]} #{tacacs_groups[3]} #{tacacs_groups[1]} local"
|
416
|
+
config(cmd0)
|
417
|
+
|
418
|
+
conf_groups = [tacacs_groups[0], tacacs_groups[3], tacacs_groups[1]]
|
419
|
+
assert_equal(conf_groups, aaa_a_service.groups)
|
420
|
+
assert_equal(:local, aaa_a_service.method)
|
421
|
+
|
422
|
+
# Mix default and console, but since our instance is for 'default'
|
423
|
+
# service we should only get 'default' groups and not 'console'
|
424
|
+
# groups.
|
425
|
+
cmd1 = 'aaa authorization commands default group ' \
|
426
|
+
"#{tacacs_groups.join(' ')} local"
|
427
|
+
cmd2 = 'aaa authorization commands console group ' \
|
428
|
+
"#{tacacs_groups[1..3].join(' ')} local"
|
429
|
+
|
430
|
+
config(cmd1, cmd2)
|
431
|
+
|
432
|
+
assert_equal(tacacs_groups, aaa_a_service.groups)
|
433
|
+
assert_equal(:local, aaa_a_service.method)
|
434
|
+
end
|
435
|
+
|
436
|
+
def test_collect_grps_cmds_con
|
437
|
+
type = :commands
|
438
|
+
aaa_a_service = AaaAuthorizationService.new(type, 'console')
|
439
|
+
|
440
|
+
# Default case
|
441
|
+
assert_equal(aaa_a_service.default_groups, aaa_a_service.groups)
|
442
|
+
|
443
|
+
config('aaa authorization commands console group ' \
|
444
|
+
"#{tacacs_groups[0..2].join(' ')}")
|
445
|
+
|
446
|
+
assert_equal(tacacs_groups[0..2], aaa_a_service.groups)
|
447
|
+
assert_equal(:unselected, aaa_a_service.method)
|
448
|
+
|
449
|
+
# Change the config to have different groups and method
|
450
|
+
cmd0 = 'aaa authorization commands console group ' \
|
451
|
+
"#{tacacs_groups[0]} #{tacacs_groups[3]} #{tacacs_groups[1]} local"
|
452
|
+
config(cmd0)
|
453
|
+
|
454
|
+
conf_groups = [tacacs_groups[0], tacacs_groups[3], tacacs_groups[1]]
|
455
|
+
assert_equal(conf_groups, aaa_a_service.groups)
|
456
|
+
assert_equal(:local, aaa_a_service.method)
|
457
|
+
|
458
|
+
# Mix default and console, but since our instance is for 'console'
|
459
|
+
# service we should only get 'console' groups and not 'default'
|
460
|
+
# groups.
|
461
|
+
cmd1 = 'aaa authorization commands console group ' \
|
462
|
+
"#{tacacs_groups.join(' ')} local"
|
463
|
+
cmd2 = 'aaa authorization commands default group ' \
|
464
|
+
"#{tacacs_groups[1..3].join(' ')} local"
|
465
|
+
config(cmd1, cmd2)
|
466
|
+
|
467
|
+
assert_equal(tacacs_groups, aaa_a_service.groups)
|
468
|
+
assert_equal(:local, aaa_a_service.method)
|
469
|
+
end
|
470
|
+
|
471
|
+
def test_collect_grps_cfg_cmds_def
|
472
|
+
type = :config_commands
|
473
|
+
aaa_a_service = AaaAuthorizationService.new(type, 'default')
|
474
|
+
|
475
|
+
# Default case
|
476
|
+
assert_equal(aaa_a_service.default_groups, aaa_a_service.groups)
|
477
|
+
|
478
|
+
config('aaa authorization config-commands default group ' \
|
479
|
+
"#{tacacs_groups[0]} #{tacacs_groups[1]} #{tacacs_groups[2]}")
|
480
|
+
|
481
|
+
assert_equal(tacacs_groups[0..2], aaa_a_service.groups)
|
482
|
+
assert_equal(:unselected, aaa_a_service.method)
|
483
|
+
|
484
|
+
# Change the config to have different groups and method
|
485
|
+
cmd0 = 'aaa authorization config-commands default group ' \
|
486
|
+
"#{tacacs_groups[0]} #{tacacs_groups[3]} #{tacacs_groups[1]} local"
|
487
|
+
config(cmd0)
|
488
|
+
|
489
|
+
conf_groups = [tacacs_groups[0], tacacs_groups[3], tacacs_groups[1]]
|
490
|
+
assert_equal(conf_groups, aaa_a_service.groups)
|
491
|
+
assert_equal(:local, aaa_a_service.method)
|
492
|
+
|
493
|
+
# Mix default and console, but since our instance is for 'default'
|
494
|
+
# service we should only get 'default' groups and not 'console'
|
495
|
+
# groups.
|
496
|
+
cmd1 = 'aaa authorization config-commands default group ' \
|
497
|
+
"#{tacacs_groups.join(' ')} local"
|
498
|
+
cmd2 = 'aaa authorization config-commands console group ' \
|
499
|
+
"#{tacacs_groups[1..3].join(' ')} local"
|
500
|
+
config(cmd1, cmd2)
|
501
|
+
|
502
|
+
assert_equal(tacacs_groups, aaa_a_service.groups)
|
503
|
+
assert_equal(:local, aaa_a_service.method)
|
504
|
+
end
|
505
|
+
|
506
|
+
def test_collect_grps_cfg_cmds_con
|
507
|
+
type = :config_commands
|
508
|
+
aaa_a_service = AaaAuthorizationService.new(type, 'console')
|
509
|
+
|
510
|
+
# Default case
|
511
|
+
assert_equal(aaa_a_service.default_groups, aaa_a_service.groups)
|
512
|
+
|
513
|
+
config('aaa authorization config-commands console group ' \
|
514
|
+
"#{tacacs_groups[0..2].join(' ')}")
|
515
|
+
|
516
|
+
assert_equal(tacacs_groups[0..2], aaa_a_service.groups)
|
517
|
+
assert_equal(:unselected, aaa_a_service.method)
|
518
|
+
|
519
|
+
# Change the config to have different groups and method
|
520
|
+
cmd0 = 'aaa authorization config-commands console group ' \
|
521
|
+
"#{tacacs_groups[0]} #{tacacs_groups[3]} #{tacacs_groups[1]} local"
|
522
|
+
config(cmd0)
|
523
|
+
|
524
|
+
conf_groups = [tacacs_groups[0], tacacs_groups[3], tacacs_groups[1]]
|
525
|
+
assert_equal(conf_groups, aaa_a_service.groups)
|
526
|
+
assert_equal(:local, aaa_a_service.method)
|
527
|
+
|
528
|
+
# Mix default and console, but since our instance is for 'console'
|
529
|
+
# service we should only get 'console' groups and not 'default'
|
530
|
+
# groups.
|
531
|
+
cmd1 = 'aaa authorization config-commands console group ' \
|
532
|
+
"#{tacacs_groups.join(' ')} local"
|
533
|
+
cmd2 = 'aaa authorization config-commands default group ' \
|
534
|
+
"#{tacacs_groups[1..3].join(' ')} local"
|
535
|
+
config(cmd1, cmd2)
|
536
|
+
|
537
|
+
assert_equal(tacacs_groups, aaa_a_service.groups)
|
538
|
+
assert_equal(:local, aaa_a_service.method)
|
539
|
+
end
|
540
|
+
|
541
|
+
def test_get_def_grps
|
542
|
+
groups = []
|
543
|
+
type = :commands
|
544
|
+
aaa_a_service = AaaAuthorizationService.new(type, 'default')
|
545
|
+
|
546
|
+
assert_equal(groups, aaa_a_service.default_groups,
|
547
|
+
'Error: AaaAuthorizationService commands default, ' \
|
548
|
+
'default groups')
|
549
|
+
aaa_a_service.destroy
|
550
|
+
|
551
|
+
aaa_a_service = AaaAuthorizationService.new(type, 'console')
|
552
|
+
|
553
|
+
assert_equal(groups, aaa_a_service.default_groups,
|
554
|
+
'Error: AaaAuthorizationService commands console, ' \
|
555
|
+
'default groups')
|
556
|
+
aaa_a_service.destroy
|
557
|
+
|
558
|
+
type = :config_commands
|
559
|
+
aaa_a_service = AaaAuthorizationService.new(type, 'default')
|
560
|
+
|
561
|
+
assert_equal(groups, aaa_a_service.default_groups,
|
562
|
+
'Error: AaaAuthorizationService config-commands ' \
|
563
|
+
'default, default groups')
|
564
|
+
aaa_a_service.destroy
|
565
|
+
|
566
|
+
aaa_a_service = AaaAuthorizationService.new(type, 'console')
|
567
|
+
|
568
|
+
assert_equal(groups, aaa_a_service.default_groups,
|
569
|
+
'Error: AaaAuthorizationService config-commands ' \
|
570
|
+
'console, default groups')
|
571
|
+
aaa_a_service.destroy
|
572
|
+
end
|
573
|
+
|
574
|
+
def test_cmds_def_unselected_single
|
575
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'default')
|
576
|
+
aaa_a_service.groups_method_set(tacacs_groups[0], :unselected)
|
577
|
+
|
578
|
+
p = get_pattern(:commands, 'default', tacacs_groups[0])
|
579
|
+
assert_show_match(command: show_cmd, pattern: p)
|
580
|
+
end
|
581
|
+
|
582
|
+
def test_cmds_def_unselected_multi
|
583
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'default')
|
584
|
+
aaa_a_service.groups_method_set(tacacs_groups[0..2], :unselected)
|
585
|
+
|
586
|
+
p = get_pattern(:commands, 'default', tacacs_groups[0..2])
|
587
|
+
assert_show_match(command: show_cmd, pattern: p)
|
588
|
+
end
|
589
|
+
|
590
|
+
def test_cmds_def_local_multi
|
591
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'default')
|
592
|
+
aaa_a_service.groups_method_set(tacacs_groups[0..2], :local)
|
593
|
+
|
594
|
+
p = get_pattern(:commands, 'default', tacacs_groups[0..2], :local)
|
595
|
+
assert_show_match(command: show_cmd, pattern: p)
|
596
|
+
end
|
597
|
+
|
598
|
+
def test_cmds_def_all_def
|
599
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'default')
|
600
|
+
method = aaa_a_service.default_method
|
601
|
+
groups = aaa_a_service.default_groups
|
602
|
+
aaa_a_service.groups_method_set(groups, method)
|
603
|
+
|
604
|
+
p = get_pattern(:commands, 'default', groups, method)
|
605
|
+
assert_show_match(command: show_cmd, pattern: p)
|
606
|
+
end
|
607
|
+
|
608
|
+
def test_cmds_con_unselected_single
|
609
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'console')
|
610
|
+
aaa_a_service.groups_method_set(tacacs_groups[0], :unselected)
|
611
|
+
|
612
|
+
p = get_pattern(:commands, 'console', tacacs_groups[0])
|
613
|
+
assert_show_match(command: show_cmd, pattern: p)
|
614
|
+
end
|
615
|
+
|
616
|
+
def test_cmds_con_unselected_multi
|
617
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'console')
|
618
|
+
aaa_a_service.groups_method_set(tacacs_groups[0..2], :unselected)
|
619
|
+
|
620
|
+
p = get_pattern(:commands, 'console', tacacs_groups[0..2])
|
621
|
+
assert_show_match(command: show_cmd, pattern: p)
|
622
|
+
end
|
623
|
+
|
624
|
+
def test_cmds_con_local_multi
|
625
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'console')
|
626
|
+
aaa_a_service.groups_method_set(tacacs_groups[0..2], :local)
|
627
|
+
|
628
|
+
p = get_pattern(:commands, 'console', tacacs_groups[0..2], :local)
|
629
|
+
assert_show_match(command: show_cmd, pattern: p)
|
630
|
+
end
|
631
|
+
|
632
|
+
def test_cmds_con_all_def
|
633
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'console')
|
634
|
+
method = aaa_a_service.default_method
|
635
|
+
groups = aaa_a_service.default_groups
|
636
|
+
aaa_a_service.groups_method_set(groups, method)
|
637
|
+
|
638
|
+
p = get_pattern(:commands, 'console', groups, method)
|
639
|
+
assert_show_match(command: show_cmd, pattern: p)
|
640
|
+
end
|
641
|
+
|
642
|
+
def test_cfg_cmds_def_unselected_single
|
643
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'default')
|
644
|
+
aaa_a_service.groups_method_set(tacacs_groups[0], :unselected)
|
645
|
+
|
646
|
+
p = get_pattern(:config_commands, 'default', tacacs_groups[0])
|
647
|
+
assert_show_match(command: show_cmd, pattern: p)
|
648
|
+
end
|
649
|
+
|
650
|
+
def test_cfg_cmds_def_unselected_multi
|
651
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'default')
|
652
|
+
aaa_a_service.groups_method_set(tacacs_groups[0..2], :unselected)
|
653
|
+
|
654
|
+
p = get_pattern(:config_commands, 'default', tacacs_groups[0..2])
|
655
|
+
assert_show_match(command: show_cmd, pattern: p)
|
656
|
+
end
|
657
|
+
|
658
|
+
def test_cfg_cmds_def_local_multi
|
659
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'default')
|
660
|
+
aaa_a_service.groups_method_set(tacacs_groups[0..2], :local)
|
661
|
+
|
662
|
+
p = get_pattern(:config_commands, 'default', tacacs_groups[0..2], :local)
|
663
|
+
assert_show_match(command: show_cmd, pattern: p)
|
664
|
+
end
|
665
|
+
|
666
|
+
def test_cfg_cmds_def_all_def
|
667
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'default')
|
668
|
+
|
669
|
+
method = aaa_a_service.default_method
|
670
|
+
groups = aaa_a_service.default_groups
|
671
|
+
aaa_a_service.groups_method_set(groups, method)
|
672
|
+
|
673
|
+
p = get_pattern(:config_commands, 'default', groups, method)
|
674
|
+
assert_show_match(command: show_cmd, pattern: p)
|
675
|
+
end
|
676
|
+
|
677
|
+
def test_cfg_cmds_con_unselected_single
|
678
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'console')
|
679
|
+
aaa_a_service.groups_method_set(tacacs_groups[0], :unselected)
|
680
|
+
|
681
|
+
p = get_pattern(:config_commands, 'console', tacacs_groups[0])
|
682
|
+
assert_show_match(command: show_cmd, pattern: p)
|
683
|
+
end
|
684
|
+
|
685
|
+
def test_cfg_cmds_con_unselected_multi
|
686
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'console')
|
687
|
+
aaa_a_service.groups_method_set(tacacs_groups[0..2], :unselected)
|
688
|
+
|
689
|
+
p = get_pattern(:config_commands, 'console', tacacs_groups[0..2])
|
690
|
+
assert_show_match(command: show_cmd, pattern: p)
|
691
|
+
end
|
692
|
+
|
693
|
+
def test_cfg_cmds_con_local_multi
|
694
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'console')
|
695
|
+
aaa_a_service.groups_method_set(tacacs_groups[0..2], :local)
|
696
|
+
|
697
|
+
p = get_pattern(:config_commands, 'console', tacacs_groups[0..2], :local)
|
698
|
+
assert_show_match(command: show_cmd, pattern: p)
|
699
|
+
end
|
700
|
+
|
701
|
+
def test_cfg_cmds_con_all_def
|
702
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'console')
|
703
|
+
method = aaa_a_service.default_method
|
704
|
+
groups = aaa_a_service.default_groups
|
705
|
+
aaa_a_service.groups_method_set(groups, method)
|
706
|
+
|
707
|
+
p = get_pattern(:config_commands, 'console', groups, method)
|
708
|
+
assert_show_match(command: show_cmd, pattern: p)
|
709
|
+
end
|
710
|
+
|
711
|
+
def test_cmds_grps_method_set_inv
|
712
|
+
# Commands, with service default
|
713
|
+
type = :commands
|
714
|
+
service = 'default'
|
715
|
+
aaa_a_service = AaaAuthorizationService.new(type, service)
|
716
|
+
|
717
|
+
# Single invalid group
|
718
|
+
groups = ['test1']
|
719
|
+
assert_raises(Cisco::CliError) do
|
720
|
+
aaa_a_service.groups_method_set(groups, :unselected)
|
721
|
+
end
|
722
|
+
|
723
|
+
# Multi groups with invalid group
|
724
|
+
groups = %w(rtp10 test2 bxb100)
|
725
|
+
assert_raises(Cisco::CliError) do
|
726
|
+
aaa_a_service.groups_method_set(groups, :local)
|
727
|
+
end
|
728
|
+
aaa_a_service.destroy
|
729
|
+
|
730
|
+
# Repeat the test for service 'console'
|
731
|
+
service = 'console'
|
732
|
+
aaa_a_service = AaaAuthorizationService.new(type, service)
|
733
|
+
|
734
|
+
# Single invalid group
|
735
|
+
groups = ['test1']
|
736
|
+
assert_raises(Cisco::CliError) do
|
737
|
+
aaa_a_service.groups_method_set(groups, :unselected)
|
738
|
+
end
|
739
|
+
|
740
|
+
# Multi group with invalid group
|
741
|
+
groups = %w(rtp10 test1 bxb100)
|
742
|
+
assert_raises(Cisco::CliError) do
|
743
|
+
aaa_a_service.groups_method_set(groups, :local)
|
744
|
+
end
|
745
|
+
|
746
|
+
# Multiple group with group and invalid method
|
747
|
+
groups = %w(rtp10 bxb100)
|
748
|
+
assert_raises(TypeError) do
|
749
|
+
aaa_a_service.groups_method_set(groups, 45)
|
750
|
+
end
|
751
|
+
|
752
|
+
aaa_a_service.destroy
|
753
|
+
end
|
754
|
+
|
755
|
+
def test_cfg_cmds_set_grps_inv
|
756
|
+
# Commands, with service default
|
757
|
+
type = :config_commands
|
758
|
+
service = 'default'
|
759
|
+
aaa_a_service = AaaAuthorizationService.new(type, service)
|
760
|
+
|
761
|
+
# Single invalid group
|
762
|
+
groups = ['test1']
|
763
|
+
assert_raises(Cisco::CliError) do
|
764
|
+
aaa_a_service.groups_method_set(groups, :unselected)
|
765
|
+
end
|
766
|
+
|
767
|
+
# Multi groups with invalid group
|
768
|
+
groups = %w(rtp10 test2 bxb100)
|
769
|
+
assert_raises(Cisco::CliError) do
|
770
|
+
aaa_a_service.groups_method_set(groups, :local)
|
771
|
+
end
|
772
|
+
aaa_a_service.destroy
|
773
|
+
|
774
|
+
# Repeat the test for service 'console'
|
775
|
+
service = 'console'
|
776
|
+
aaa_a_service = AaaAuthorizationService.new(type, service)
|
777
|
+
|
778
|
+
# one invalid group
|
779
|
+
groups = ['test1']
|
780
|
+
assert_raises(Cisco::CliError) do
|
781
|
+
aaa_a_service.groups_method_set(groups, :unselected)
|
782
|
+
end
|
783
|
+
|
784
|
+
# multiple group with invalid group
|
785
|
+
groups = %w(rtp10 test1 bxb100)
|
786
|
+
assert_raises(Cisco::CliError) do
|
787
|
+
aaa_a_service.groups_method_set(groups, :local)
|
788
|
+
end
|
789
|
+
|
790
|
+
# Multiple group with group and invalid method
|
791
|
+
groups = %w(rtp10 bxb100)
|
792
|
+
assert_raises(TypeError) do
|
793
|
+
aaa_a_service.groups_method_set(groups, 45)
|
794
|
+
end
|
795
|
+
|
796
|
+
aaa_a_service.destroy
|
797
|
+
end
|
798
|
+
|
799
|
+
def test_cmds_method_inv
|
800
|
+
# Commands, with service default
|
801
|
+
type = :commands
|
802
|
+
service = 'default'
|
803
|
+
aaa_a_service = AaaAuthorizationService.new(type, service)
|
804
|
+
|
805
|
+
# No group and invalid method
|
806
|
+
groups = []
|
807
|
+
assert_raises(TypeError) do
|
808
|
+
aaa_a_service.groups_method_set(groups, 'test')
|
809
|
+
end
|
810
|
+
|
811
|
+
# Multiple group with group and invalid method
|
812
|
+
groups = %w(rtp10 bxb100)
|
813
|
+
assert_raises(TypeError) do
|
814
|
+
aaa_a_service.groups_method_set(groups, 45)
|
815
|
+
end
|
816
|
+
aaa_a_service.destroy
|
817
|
+
|
818
|
+
# Repeat the test for service 'console'
|
819
|
+
service = 'console'
|
820
|
+
aaa_a_service = AaaAuthorizationService.new(type, service)
|
821
|
+
|
822
|
+
# No group and invalid method
|
823
|
+
groups = []
|
824
|
+
assert_raises(TypeError) do
|
825
|
+
aaa_a_service.groups_method_set(groups, 'test')
|
826
|
+
end
|
827
|
+
|
828
|
+
# Multiple group with group and invalid method
|
829
|
+
groups = %w(rtp10 bxb100)
|
830
|
+
assert_raises(TypeError) do
|
831
|
+
aaa_a_service.groups_method_set(groups, 45)
|
832
|
+
end
|
833
|
+
|
834
|
+
aaa_a_service.destroy
|
835
|
+
end
|
836
|
+
|
837
|
+
def test_cfg_cmds_method_inv
|
838
|
+
# Commands, with service default
|
839
|
+
type = :config_commands
|
840
|
+
service = 'default'
|
841
|
+
aaa_a_service = AaaAuthorizationService.new(type, service)
|
842
|
+
|
843
|
+
# No group and invalid method
|
844
|
+
groups = []
|
845
|
+
assert_raises(TypeError) do
|
846
|
+
aaa_a_service.groups_method_set(groups, 'test')
|
847
|
+
end
|
848
|
+
|
849
|
+
# Multiple group with group and invalid method
|
850
|
+
groups = %w(rtp10 bxb100)
|
851
|
+
assert_raises(TypeError) do
|
852
|
+
aaa_a_service.groups_method_set(groups, 45)
|
853
|
+
end
|
854
|
+
aaa_a_service.destroy
|
855
|
+
|
856
|
+
# Repeat the test for service 'console'
|
857
|
+
service = 'console'
|
858
|
+
aaa_a_service = AaaAuthorizationService.new(type, service)
|
859
|
+
|
860
|
+
# No group and invalid method
|
861
|
+
groups = []
|
862
|
+
assert_raises(TypeError) do
|
863
|
+
aaa_a_service.groups_method_set(groups, 'test')
|
864
|
+
end
|
865
|
+
|
866
|
+
# Multiple group with group and invalid method
|
867
|
+
groups = %w(rtp10 bxb100)
|
868
|
+
assert_raises(TypeError) do
|
869
|
+
aaa_a_service.groups_method_set(groups, 45)
|
870
|
+
end
|
871
|
+
|
872
|
+
aaa_a_service.destroy
|
873
|
+
end
|
874
|
+
end
|