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,761 @@
|
|
1
|
+
# Copyright (c) 2014-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/aaa_authentication_login_service'
|
17
|
+
|
18
|
+
AAA_AUTH_LOGIN_SERVICE_METHOD_NONE = :none
|
19
|
+
AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL = :local
|
20
|
+
AAA_AUTH_LOGIN_SERVICE_METHOD_UNSELECTED = :unselected
|
21
|
+
|
22
|
+
# Test class for AAA Authentication Login Service
|
23
|
+
class TestAaaAuthenLoginSvc < CiscoTestCase
|
24
|
+
@skip_unless_supported = 'aaa_auth_login_service'
|
25
|
+
|
26
|
+
def setup
|
27
|
+
super
|
28
|
+
skip_legacy_defect?('7.0.3.I3.1',
|
29
|
+
'CSCuz44696: Cannot configure aaa group server tacacs')
|
30
|
+
end
|
31
|
+
|
32
|
+
def unconfig_tacacs
|
33
|
+
config('no feature tacacs+')
|
34
|
+
end
|
35
|
+
|
36
|
+
def unconfig_aaa
|
37
|
+
# configure defaults = unconfigure
|
38
|
+
config('aaa authentication login default local')
|
39
|
+
config('aaa authentication login console local')
|
40
|
+
end
|
41
|
+
|
42
|
+
def config_tacacs_servers(servers)
|
43
|
+
config('feature tacacs+')
|
44
|
+
servers.each do |server|
|
45
|
+
config("aaa group server tacacs+ #{server}")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def aaaauthloginservices_default
|
50
|
+
config('aaa authentication login default local')
|
51
|
+
config('aaa authentication login console local')
|
52
|
+
end
|
53
|
+
|
54
|
+
def aaaauthloginservice_detach(authloginservice, revert=true)
|
55
|
+
aaaauthloginservices_default if revert != false
|
56
|
+
authloginservice.destroy
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_create_empty_service
|
60
|
+
assert_raises(ArgumentError) do
|
61
|
+
AaaAuthenticationLoginService.new('')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_create_invalid_service
|
66
|
+
assert_raises(TypeError) do
|
67
|
+
AaaAuthenticationLoginService.new(:test)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_create_service_default
|
72
|
+
aaaauthloginservice = AaaAuthenticationLoginService.new('default')
|
73
|
+
refute_nil(aaaauthloginservice,
|
74
|
+
'Error: login service default create')
|
75
|
+
aaaauthloginservice_detach(aaaauthloginservice) unless
|
76
|
+
aaaauthloginservice.nil?
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_create_service_console
|
80
|
+
aaaauthloginservice = AaaAuthenticationLoginService.new('console')
|
81
|
+
refute_nil(aaaauthloginservice,
|
82
|
+
'Error: login service console create')
|
83
|
+
aaaauthloginservice_detach(aaaauthloginservice) unless
|
84
|
+
aaaauthloginservice.nil?
|
85
|
+
end
|
86
|
+
|
87
|
+
# Test with service default
|
88
|
+
def test_collection_svc_def
|
89
|
+
unconfig_aaa
|
90
|
+
aaaauthloginservice_list = AaaAuthenticationLoginService.services
|
91
|
+
refute_empty(aaaauthloginservice_list,
|
92
|
+
'Error: service collection is not filled')
|
93
|
+
assert(aaaauthloginservice_list.key?('default'),
|
94
|
+
'Error: collection does contain default')
|
95
|
+
aaaauthloginservice_list.each do |name, aaaauthloginservice|
|
96
|
+
assert_equal(name, aaaauthloginservice.name,
|
97
|
+
"Error: Invalid name #{name} in collection")
|
98
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL,
|
99
|
+
aaaauthloginservice.method,
|
100
|
+
'Error: Invalid method for defaultin collection')
|
101
|
+
assert_empty(aaaauthloginservice.groups,
|
102
|
+
'Error: Invalid groups for default in collection')
|
103
|
+
aaaauthloginservice_detach(aaaauthloginservice, false)
|
104
|
+
end
|
105
|
+
aaaauthloginservices_default
|
106
|
+
end
|
107
|
+
|
108
|
+
# Test with service default and console
|
109
|
+
def test_collection_svc_def_con
|
110
|
+
unconfig_aaa
|
111
|
+
# preconfig console
|
112
|
+
config('aaa authentication login console none')
|
113
|
+
|
114
|
+
aaaauthloginservice_list = AaaAuthenticationLoginService.services
|
115
|
+
refute_empty(aaaauthloginservice_list,
|
116
|
+
'Error: service collection is not filled')
|
117
|
+
assert_equal(2, aaaauthloginservice_list.size,
|
118
|
+
'Error: collection not reporting correct size')
|
119
|
+
assert(aaaauthloginservice_list.key?('default'),
|
120
|
+
'Error: collection does contain default')
|
121
|
+
assert(aaaauthloginservice_list.key?('console'),
|
122
|
+
'Error: collection does contain console')
|
123
|
+
aaaauthloginservice_list.each do |name, aaaauthloginservice|
|
124
|
+
assert_equal(name, aaaauthloginservice.name,
|
125
|
+
"Error: Invalid name #{name} in collection")
|
126
|
+
if name == 'default'
|
127
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL,
|
128
|
+
aaaauthloginservice.method,
|
129
|
+
'Error: Invalid method for default in collection')
|
130
|
+
end
|
131
|
+
|
132
|
+
if name == 'console'
|
133
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
134
|
+
aaaauthloginservice.method,
|
135
|
+
'Error: Invalid method for console in collection')
|
136
|
+
end
|
137
|
+
|
138
|
+
assert_equal([], aaaauthloginservice.groups,
|
139
|
+
'Error: Invalid groups for default in collection')
|
140
|
+
aaaauthloginservice_detach(aaaauthloginservice, false)
|
141
|
+
end
|
142
|
+
aaaauthloginservices_default
|
143
|
+
end
|
144
|
+
|
145
|
+
# Test with service default and console with group
|
146
|
+
def test_collection_svc_def_con_grp
|
147
|
+
# preconfig servers
|
148
|
+
servers = %w(group1 group2)
|
149
|
+
config_tacacs_servers(servers)
|
150
|
+
|
151
|
+
# preconfig console
|
152
|
+
# we need in some specific order
|
153
|
+
config('aaa authentication login default group group2 group1 none',
|
154
|
+
'aaa authentication login console group group1')
|
155
|
+
|
156
|
+
aaaauthloginservice_list = AaaAuthenticationLoginService.services
|
157
|
+
refute_empty(aaaauthloginservice_list,
|
158
|
+
'Error: service collection is not filled')
|
159
|
+
assert_equal(2, aaaauthloginservice_list.size,
|
160
|
+
'Error: Login collection not reporting correct size')
|
161
|
+
assert(aaaauthloginservice_list.key?('default'),
|
162
|
+
'Error: collection does contain default')
|
163
|
+
assert(aaaauthloginservice_list.key?('console'),
|
164
|
+
'Error: collection does contain console')
|
165
|
+
aaaauthloginservice_list.each do |name, aaaauthloginservice|
|
166
|
+
assert_equal(name, aaaauthloginservice.name,
|
167
|
+
"Error: Invalid name #{name} in collection")
|
168
|
+
|
169
|
+
if name == 'default'
|
170
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
171
|
+
aaaauthloginservice.method,
|
172
|
+
'Error: Invalid method for default in collection')
|
173
|
+
groups = %w(group2 group1)
|
174
|
+
assert_equal(groups, aaaauthloginservice.groups,
|
175
|
+
'Error: Invalid groups for default in collection')
|
176
|
+
end
|
177
|
+
|
178
|
+
if name == 'console'
|
179
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_UNSELECTED,
|
180
|
+
aaaauthloginservice.method,
|
181
|
+
'Error: Invalid method for console in collection')
|
182
|
+
groups = ['group1']
|
183
|
+
assert_equal(groups, aaaauthloginservice.groups,
|
184
|
+
'Error: Invalid groups for default in collection')
|
185
|
+
end
|
186
|
+
aaaauthloginservice_detach(aaaauthloginservice, false)
|
187
|
+
end
|
188
|
+
aaaauthloginservices_default
|
189
|
+
unconfig_tacacs
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_service_default_get_method
|
193
|
+
aaaauthloginservice =
|
194
|
+
AaaAuthenticationLoginService.new('default')
|
195
|
+
|
196
|
+
# default case
|
197
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL,
|
198
|
+
aaaauthloginservice.method,
|
199
|
+
'Error: login service default get method for local')
|
200
|
+
|
201
|
+
# preconfig default
|
202
|
+
config('aaa authentication login default none')
|
203
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
204
|
+
aaaauthloginservice.method,
|
205
|
+
'Error: login service default get method for none')
|
206
|
+
|
207
|
+
# preconfig servers
|
208
|
+
servers = %w(bxb100 bxb200)
|
209
|
+
config_tacacs_servers(servers)
|
210
|
+
|
211
|
+
# preconfig default
|
212
|
+
config('aaa authentication login default group bxb100 bxb200')
|
213
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_UNSELECTED,
|
214
|
+
aaaauthloginservice.method,
|
215
|
+
'Error: login service group or method incorrect')
|
216
|
+
|
217
|
+
# preconfig default
|
218
|
+
config('aaa authentication login default group bxb200 none')
|
219
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
220
|
+
aaaauthloginservice.method,
|
221
|
+
"Error: login service group incorrect or method not 'none'")
|
222
|
+
|
223
|
+
# cleanup
|
224
|
+
aaaauthloginservice_detach(aaaauthloginservice)
|
225
|
+
unconfig_tacacs
|
226
|
+
end
|
227
|
+
|
228
|
+
def test_service_console_get_method
|
229
|
+
aaaauthloginservice = AaaAuthenticationLoginService.new('console')
|
230
|
+
|
231
|
+
# default case
|
232
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL,
|
233
|
+
aaaauthloginservice.method,
|
234
|
+
"Error: login service method not 'local'")
|
235
|
+
|
236
|
+
# preconfig console
|
237
|
+
config('aaa authentication login console none')
|
238
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
239
|
+
aaaauthloginservice.method,
|
240
|
+
"Error: login service method not 'none'")
|
241
|
+
|
242
|
+
# preconfig servers
|
243
|
+
servers = %w(bxb100 bxb200)
|
244
|
+
config_tacacs_servers(servers)
|
245
|
+
|
246
|
+
# preconfig console
|
247
|
+
config('aaa authentication login console group bxb100 bxb200')
|
248
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_UNSELECTED,
|
249
|
+
aaaauthloginservice.method,
|
250
|
+
"Error: login service method not 'unselected'")
|
251
|
+
|
252
|
+
# preconfig console
|
253
|
+
config('aaa authentication login console group bxb200 none')
|
254
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
255
|
+
aaaauthloginservice.method,
|
256
|
+
"Error: login service group incorrect or method not 'none'")
|
257
|
+
|
258
|
+
# cleanup
|
259
|
+
aaaauthloginservice_detach(aaaauthloginservice)
|
260
|
+
unconfig_tacacs
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_get_default_method
|
264
|
+
# service default
|
265
|
+
aaaauthloginservice =
|
266
|
+
AaaAuthenticationLoginService.new('default')
|
267
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL,
|
268
|
+
aaaauthloginservice.default_method,
|
269
|
+
'Error: login service default, default method')
|
270
|
+
aaaauthloginservice_detach(aaaauthloginservice)
|
271
|
+
|
272
|
+
# service console
|
273
|
+
aaaauthloginservice =
|
274
|
+
AaaAuthenticationLoginService.new('console')
|
275
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL,
|
276
|
+
aaaauthloginservice.default_method,
|
277
|
+
'Error: login service console, default method')
|
278
|
+
aaaauthloginservice_detach(aaaauthloginservice, false)
|
279
|
+
end
|
280
|
+
|
281
|
+
def test_service_default_get_groups
|
282
|
+
aaaauthloginservice =
|
283
|
+
AaaAuthenticationLoginService.new('default')
|
284
|
+
|
285
|
+
# default case
|
286
|
+
assert_equal(aaaauthloginservice.default_groups, aaaauthloginservice.groups,
|
287
|
+
'Error: login service default get groups for default')
|
288
|
+
|
289
|
+
# preconfig servers
|
290
|
+
servers = %w(bxb100 sjc200 rtp10)
|
291
|
+
config_tacacs_servers(servers)
|
292
|
+
|
293
|
+
# preconfig default
|
294
|
+
config('aaa authentication login default group bxb100 sjc200')
|
295
|
+
groups = %w(bxb100 sjc200)
|
296
|
+
assert_equal(groups, aaaauthloginservice.groups,
|
297
|
+
'Error: login service default get groups')
|
298
|
+
|
299
|
+
# preconfig default
|
300
|
+
config('aaa authentication login default group sjc200 bxb100 rtp10 none')
|
301
|
+
groups = %w(sjc200 bxb100 rtp10)
|
302
|
+
assert_equal(groups, aaaauthloginservice.groups,
|
303
|
+
'Error: login service default get groups')
|
304
|
+
|
305
|
+
# cleanup
|
306
|
+
aaaauthloginservice_detach(aaaauthloginservice)
|
307
|
+
unconfig_tacacs
|
308
|
+
end
|
309
|
+
|
310
|
+
def test_service_console_get_groups
|
311
|
+
aaaauthloginservice =
|
312
|
+
AaaAuthenticationLoginService.new('console')
|
313
|
+
|
314
|
+
# default case
|
315
|
+
assert_equal(aaaauthloginservice.default_groups, aaaauthloginservice.groups,
|
316
|
+
'Error: login service console get groups for default')
|
317
|
+
|
318
|
+
# preconfig servers
|
319
|
+
servers = %w(bxb100 sjc200 rtp10)
|
320
|
+
config_tacacs_servers(servers)
|
321
|
+
|
322
|
+
# preconfig console
|
323
|
+
config('aaa authentication login console group bxb100 sjc200')
|
324
|
+
groups = %w(bxb100 sjc200)
|
325
|
+
assert_equal(groups, aaaauthloginservice.groups,
|
326
|
+
"Error: login service console get groups #{groups}")
|
327
|
+
|
328
|
+
# preconfig console
|
329
|
+
config('aaa authentication login console group rtp10 bxb100 none')
|
330
|
+
groups = %w(rtp10 bxb100)
|
331
|
+
assert_equal(groups, aaaauthloginservice.groups,
|
332
|
+
"Error: login service console get groups #{groups}")
|
333
|
+
|
334
|
+
# preconfig console
|
335
|
+
config('aaa authentication login console group sjc200 bxb100 rtp10')
|
336
|
+
groups = %w(sjc200 bxb100 rtp10)
|
337
|
+
assert_equal(groups, aaaauthloginservice.groups,
|
338
|
+
"Error: login service console get groups #{groups}")
|
339
|
+
|
340
|
+
# cleanup
|
341
|
+
aaaauthloginservice_detach(aaaauthloginservice)
|
342
|
+
unconfig_tacacs
|
343
|
+
end
|
344
|
+
|
345
|
+
# rubocop:disable Metrics/MethodLength
|
346
|
+
# TODO: Consider refactoring this method
|
347
|
+
def test_service_default_and_console_mix
|
348
|
+
aaaauthloginservice_default =
|
349
|
+
AaaAuthenticationLoginService.new('default')
|
350
|
+
aaaauthloginservice_console =
|
351
|
+
AaaAuthenticationLoginService.new('console')
|
352
|
+
|
353
|
+
# default cases
|
354
|
+
assert_equal(aaaauthloginservice_default.default_groups,
|
355
|
+
aaaauthloginservice_default.groups,
|
356
|
+
'Error: login default, get groups default')
|
357
|
+
assert_equal(aaaauthloginservice_console.default_groups,
|
358
|
+
aaaauthloginservice_console.groups,
|
359
|
+
'Error: login console, get groups default')
|
360
|
+
assert_equal(aaaauthloginservice_default.default_method,
|
361
|
+
aaaauthloginservice_default.method,
|
362
|
+
'Error: login default, get method default')
|
363
|
+
assert_equal(aaaauthloginservice_console.default_method,
|
364
|
+
aaaauthloginservice_console.method,
|
365
|
+
'Error: login console, get method default')
|
366
|
+
|
367
|
+
# preconfig servers
|
368
|
+
servers = %w(bxb100 sjc200 rtp10)
|
369
|
+
config_tacacs_servers(servers)
|
370
|
+
|
371
|
+
groups = %w(bxb100 sjc200)
|
372
|
+
aaaauthloginservice_default.groups_method_set(
|
373
|
+
groups, AAA_AUTH_LOGIN_SERVICE_METHOD_UNSELECTED)
|
374
|
+
|
375
|
+
assert_equal(groups, aaaauthloginservice_default.groups,
|
376
|
+
"Error: login default, get groups #{groups}")
|
377
|
+
assert_empty(aaaauthloginservice_console.groups,
|
378
|
+
'Error: login console, get groups non empty')
|
379
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_UNSELECTED,
|
380
|
+
aaaauthloginservice_default.method,
|
381
|
+
'Error: login default, get method')
|
382
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL,
|
383
|
+
aaaauthloginservice_console.method,
|
384
|
+
'Error: login console, get method')
|
385
|
+
|
386
|
+
# set groups
|
387
|
+
aaaauthloginservice_default.groups_method_set(
|
388
|
+
[], AAA_AUTH_LOGIN_SERVICE_METHOD_NONE)
|
389
|
+
aaaauthloginservice_console.groups_method_set(
|
390
|
+
[], AAA_AUTH_LOGIN_SERVICE_METHOD_NONE)
|
391
|
+
|
392
|
+
# get
|
393
|
+
assert(aaaauthloginservice_default.groups.empty?,
|
394
|
+
'Error: login default ,get groups non empty')
|
395
|
+
assert_empty(aaaauthloginservice_console.groups,
|
396
|
+
'Error: login console, get groups empty')
|
397
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
398
|
+
aaaauthloginservice_default.method,
|
399
|
+
'Error: login default, get method none')
|
400
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
401
|
+
aaaauthloginservice_console.method,
|
402
|
+
'Error: login console, get method none')
|
403
|
+
|
404
|
+
# set groups
|
405
|
+
aaaauthloginservice_default.groups_method_set(
|
406
|
+
[], AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL)
|
407
|
+
aaaauthloginservice_console.groups_method_set(
|
408
|
+
[], AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL)
|
409
|
+
|
410
|
+
# get
|
411
|
+
assert_empty(aaaauthloginservice_default.groups,
|
412
|
+
'Error: login default, get groups non-empty')
|
413
|
+
assert_empty(aaaauthloginservice_console.groups,
|
414
|
+
'Error: login console, get groups non-empty')
|
415
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL,
|
416
|
+
aaaauthloginservice_default.method,
|
417
|
+
'Error: login default, get method local')
|
418
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL,
|
419
|
+
aaaauthloginservice_console.method,
|
420
|
+
'Error: login console, get method local')
|
421
|
+
|
422
|
+
# set groups
|
423
|
+
aaaauthloginservice_default.groups_method_set(
|
424
|
+
[], AAA_AUTH_LOGIN_SERVICE_METHOD_NONE)
|
425
|
+
aaaauthloginservice_console.groups_method_set(
|
426
|
+
[], AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL)
|
427
|
+
|
428
|
+
# get
|
429
|
+
assert_empty(aaaauthloginservice_default.groups,
|
430
|
+
'Error: login default, get groups non-empty')
|
431
|
+
assert_empty(aaaauthloginservice_console.groups,
|
432
|
+
'Error: login console, get groups non-empty')
|
433
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
434
|
+
aaaauthloginservice_default.method,
|
435
|
+
'Error: login default, get method none')
|
436
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL,
|
437
|
+
aaaauthloginservice_console.method,
|
438
|
+
'Error: login console, get method local')
|
439
|
+
|
440
|
+
# set groups
|
441
|
+
aaaauthloginservice_default.groups_method_set(
|
442
|
+
[], AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL)
|
443
|
+
aaaauthloginservice_console.groups_method_set(
|
444
|
+
[], AAA_AUTH_LOGIN_SERVICE_METHOD_NONE)
|
445
|
+
|
446
|
+
# get
|
447
|
+
assert_empty(aaaauthloginservice_default.groups,
|
448
|
+
'Error: login default, get groups non-empty')
|
449
|
+
assert_empty(aaaauthloginservice_console.groups,
|
450
|
+
'Error: login console, get groups non-empty')
|
451
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL,
|
452
|
+
aaaauthloginservice_default.method,
|
453
|
+
'Error: login default, get method local')
|
454
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
455
|
+
aaaauthloginservice_console.method,
|
456
|
+
'Error: login console, get method none')
|
457
|
+
|
458
|
+
# set groups
|
459
|
+
groups_default = ['bxb100']
|
460
|
+
groups_console = %w(bxb100 sjc200)
|
461
|
+
aaaauthloginservice_default.groups_method_set(
|
462
|
+
groups_default, AAA_AUTH_LOGIN_SERVICE_METHOD_UNSELECTED)
|
463
|
+
aaaauthloginservice_console.groups_method_set(
|
464
|
+
groups_console, AAA_AUTH_LOGIN_SERVICE_METHOD_NONE)
|
465
|
+
|
466
|
+
# get
|
467
|
+
assert_equal(groups_default,
|
468
|
+
aaaauthloginservice_default.groups,
|
469
|
+
"Error: login default, get groups #{groups}")
|
470
|
+
assert_equal(groups_console,
|
471
|
+
aaaauthloginservice_console.groups,
|
472
|
+
"Error: login console, get groups #{groups}")
|
473
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_UNSELECTED,
|
474
|
+
aaaauthloginservice_default.method,
|
475
|
+
'Error: login default, get method local')
|
476
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
477
|
+
aaaauthloginservice_console.method,
|
478
|
+
'Error: login console, get method none')
|
479
|
+
|
480
|
+
# set same groups and method
|
481
|
+
groups = ['bxb100']
|
482
|
+
aaaauthloginservice_default.groups_method_set(
|
483
|
+
groups, AAA_AUTH_LOGIN_SERVICE_METHOD_NONE)
|
484
|
+
aaaauthloginservice_console.groups_method_set(
|
485
|
+
groups, AAA_AUTH_LOGIN_SERVICE_METHOD_NONE)
|
486
|
+
# get
|
487
|
+
assert_equal(groups,
|
488
|
+
aaaauthloginservice_default.groups,
|
489
|
+
"Error: login default, get groups #{groups}")
|
490
|
+
assert_equal(groups,
|
491
|
+
aaaauthloginservice_console.groups,
|
492
|
+
"Error: login console, get groups #{groups}")
|
493
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
494
|
+
aaaauthloginservice_default.method,
|
495
|
+
'Error: login default, get method none')
|
496
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
497
|
+
aaaauthloginservice_console.method,
|
498
|
+
'Error: login console, get method none')
|
499
|
+
|
500
|
+
# set group for console and empty for default
|
501
|
+
groups = %w(bxb100 rtp10)
|
502
|
+
aaaauthloginservice_default.groups_method_set(
|
503
|
+
[], AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL)
|
504
|
+
aaaauthloginservice_console.groups_method_set(
|
505
|
+
groups, AAA_AUTH_LOGIN_SERVICE_METHOD_NONE)
|
506
|
+
|
507
|
+
# get
|
508
|
+
assert_empty(aaaauthloginservice_default.groups,
|
509
|
+
'Error: login default, get groups non empty')
|
510
|
+
assert_equal(groups,
|
511
|
+
aaaauthloginservice_console.groups,
|
512
|
+
"Error: login console, get groups #{groups}")
|
513
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL,
|
514
|
+
aaaauthloginservice_default.method,
|
515
|
+
'Error: login default, get method local')
|
516
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
517
|
+
aaaauthloginservice_console.method,
|
518
|
+
'Error: login console, get method none')
|
519
|
+
|
520
|
+
# set groups for default and empty for console
|
521
|
+
groups = %w(bxb100 rtp10)
|
522
|
+
aaaauthloginservice_default.groups_method_set(
|
523
|
+
groups, AAA_AUTH_LOGIN_SERVICE_METHOD_NONE)
|
524
|
+
aaaauthloginservice_console.groups_method_set(
|
525
|
+
[], AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL)
|
526
|
+
|
527
|
+
# get
|
528
|
+
assert_equal(groups,
|
529
|
+
aaaauthloginservice_default.groups,
|
530
|
+
"Error: login default, get groups #{groups}")
|
531
|
+
assert_empty(aaaauthloginservice_console.groups,
|
532
|
+
'Error: login console, get groups non-empty')
|
533
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
534
|
+
aaaauthloginservice_default.method,
|
535
|
+
'Error: login default, get method none')
|
536
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL,
|
537
|
+
aaaauthloginservice_console.method,
|
538
|
+
'Error: login console, get method local')
|
539
|
+
|
540
|
+
# set group for default and empty for console, same methos none
|
541
|
+
groups = %w(bxb100 rtp10)
|
542
|
+
aaaauthloginservice_default.groups_method_set(
|
543
|
+
groups, AAA_AUTH_LOGIN_SERVICE_METHOD_NONE)
|
544
|
+
aaaauthloginservice_console.groups_method_set(
|
545
|
+
[], AAA_AUTH_LOGIN_SERVICE_METHOD_NONE)
|
546
|
+
|
547
|
+
# get
|
548
|
+
assert_equal(groups,
|
549
|
+
aaaauthloginservice_default.groups,
|
550
|
+
"Error: login default, get groups #{groups}")
|
551
|
+
assert_empty(aaaauthloginservice_console.groups,
|
552
|
+
'Error: login console, get groups non-empty')
|
553
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
554
|
+
aaaauthloginservice_default.method,
|
555
|
+
'Error: login default, get method none')
|
556
|
+
assert_equal(AAA_AUTH_LOGIN_SERVICE_METHOD_NONE,
|
557
|
+
aaaauthloginservice_console.method,
|
558
|
+
'Error: login console, get method none')
|
559
|
+
|
560
|
+
# cleanup
|
561
|
+
aaaauthloginservice_detach(aaaauthloginservice_default)
|
562
|
+
aaaauthloginservice_detach(aaaauthloginservice_console)
|
563
|
+
unconfig_tacacs
|
564
|
+
end
|
565
|
+
# rubocop:enable Metrics/MethodLength,Metrics/AbcSize
|
566
|
+
|
567
|
+
def test_get_default_groups
|
568
|
+
# service default
|
569
|
+
aaaauthloginservice =
|
570
|
+
AaaAuthenticationLoginService.new('default')
|
571
|
+
assert_empty(aaaauthloginservice.default_groups,
|
572
|
+
'Error: login default, default groups')
|
573
|
+
aaaauthloginservice_detach(aaaauthloginservice)
|
574
|
+
|
575
|
+
# service console
|
576
|
+
aaaauthloginservice =
|
577
|
+
AaaAuthenticationLoginService.new('console')
|
578
|
+
assert_empty(aaaauthloginservice.default_groups,
|
579
|
+
'Error: login console, default groups')
|
580
|
+
aaaauthloginservice_detach(aaaauthloginservice)
|
581
|
+
end
|
582
|
+
|
583
|
+
def test_service_default_set_groups
|
584
|
+
# preconfig servers
|
585
|
+
prefix = '^aaa authentication login default group '
|
586
|
+
servers = %w(bxb100 sjc200 rtp10)
|
587
|
+
config_tacacs_servers(servers)
|
588
|
+
|
589
|
+
# service default
|
590
|
+
service = 'default'
|
591
|
+
aaaauthloginservice =
|
592
|
+
AaaAuthenticationLoginService.new(service)
|
593
|
+
|
594
|
+
# one group and method is unselected
|
595
|
+
method = AAA_AUTH_LOGIN_SERVICE_METHOD_UNSELECTED
|
596
|
+
groups = ['bxb100']
|
597
|
+
aaaauthloginservice.groups_method_set(groups, method)
|
598
|
+
assert_show_match(command: 'show run aaa all | no-more',
|
599
|
+
pattern: Regexp.new(prefix + groups.join(' ')))
|
600
|
+
|
601
|
+
# multiple group and method is unselected
|
602
|
+
method = AAA_AUTH_LOGIN_SERVICE_METHOD_UNSELECTED
|
603
|
+
groups = %w(bxb100 sjc200)
|
604
|
+
aaaauthloginservice.groups_method_set(groups, method)
|
605
|
+
assert_show_match(command: 'show run aaa all | no-more',
|
606
|
+
pattern: Regexp.new(prefix + groups.join(' ')))
|
607
|
+
|
608
|
+
# multi group and method is none
|
609
|
+
method = AAA_AUTH_LOGIN_SERVICE_METHOD_NONE
|
610
|
+
groups = %w(rtp10 bxb100 sjc200)
|
611
|
+
aaaauthloginservice.groups_method_set(groups, method)
|
612
|
+
assert_show_match(command: 'show run aaa all | no-more',
|
613
|
+
pattern: Regexp.new(prefix + groups.join(' ')))
|
614
|
+
|
615
|
+
# default group and method
|
616
|
+
method = aaaauthloginservice.default_method
|
617
|
+
groups = aaaauthloginservice.default_groups
|
618
|
+
aaaauthloginservice.groups_method_set(groups, method)
|
619
|
+
assert_show_match(command: 'show run aaa all | no-more',
|
620
|
+
pattern: /^aaa authentication login default local/)
|
621
|
+
|
622
|
+
aaaauthloginservice_detach(aaaauthloginservice)
|
623
|
+
unconfig_tacacs
|
624
|
+
end
|
625
|
+
|
626
|
+
def test_service_console_set_groups
|
627
|
+
# preconfig servers
|
628
|
+
prefix = '^aaa authentication login console group '
|
629
|
+
servers = %w(bxb100 sjc200 rtp10)
|
630
|
+
config_tacacs_servers(servers)
|
631
|
+
|
632
|
+
# service console
|
633
|
+
service = 'console'
|
634
|
+
aaaauthloginservice =
|
635
|
+
AaaAuthenticationLoginService.new(service)
|
636
|
+
|
637
|
+
# one group and method is unselected
|
638
|
+
method = AAA_AUTH_LOGIN_SERVICE_METHOD_UNSELECTED
|
639
|
+
groups = ['bxb100']
|
640
|
+
aaaauthloginservice.groups_method_set(groups, method)
|
641
|
+
assert_show_match(command: 'show run aaa all | no-more',
|
642
|
+
pattern: Regexp.new(prefix + groups.join(' ')))
|
643
|
+
|
644
|
+
# multi group and method is unselected
|
645
|
+
method = AAA_AUTH_LOGIN_SERVICE_METHOD_UNSELECTED
|
646
|
+
groups = %w(bxb100 sjc200)
|
647
|
+
aaaauthloginservice.groups_method_set(groups, method)
|
648
|
+
assert_show_match(command: 'show run aaa all | no-more',
|
649
|
+
pattern: Regexp.new(prefix + groups.join(' ')))
|
650
|
+
|
651
|
+
# multi group and method is none
|
652
|
+
method = AAA_AUTH_LOGIN_SERVICE_METHOD_NONE
|
653
|
+
groups = %w(rtp10 bxb100 sjc200)
|
654
|
+
aaaauthloginservice.groups_method_set(groups, method)
|
655
|
+
assert_show_match(command: 'show run aaa all | no-more',
|
656
|
+
pattern: Regexp.new(prefix + groups.join(' ')))
|
657
|
+
|
658
|
+
aaaauthloginservice_detach(aaaauthloginservice)
|
659
|
+
unconfig_tacacs
|
660
|
+
end
|
661
|
+
|
662
|
+
def test_service_set_groups_invalid_groups
|
663
|
+
# preconfig servers
|
664
|
+
servers = %w(bxb100 sjc200 rtp10)
|
665
|
+
config_tacacs_servers(servers)
|
666
|
+
|
667
|
+
# service default
|
668
|
+
service = 'default'
|
669
|
+
aaaauthloginservice =
|
670
|
+
AaaAuthenticationLoginService.new(service)
|
671
|
+
|
672
|
+
# one invalid group
|
673
|
+
groups = ['test1']
|
674
|
+
assert_raises(RuntimeError) do
|
675
|
+
aaaauthloginservice.groups_method_set(
|
676
|
+
groups, AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL)
|
677
|
+
end
|
678
|
+
|
679
|
+
# multiple groups with invalid group
|
680
|
+
groups = %w(rtp10 test2 bxb100)
|
681
|
+
assert_raises(CliError) do
|
682
|
+
aaaauthloginservice.groups_method_set(
|
683
|
+
groups, AAA_AUTH_LOGIN_SERVICE_METHOD_NONE)
|
684
|
+
end
|
685
|
+
|
686
|
+
# multiple groups with invalid group
|
687
|
+
groups = %w(test4 test2 bxb100)
|
688
|
+
assert_raises(CliError) do
|
689
|
+
aaaauthloginservice.groups_method_set(
|
690
|
+
groups, AAA_AUTH_LOGIN_SERVICE_METHOD_NONE)
|
691
|
+
end
|
692
|
+
|
693
|
+
# invalid array
|
694
|
+
groups = ['bxb100', 100, 'bxb100']
|
695
|
+
assert_raises(TypeError) do
|
696
|
+
aaaauthloginservice.groups_method_set(
|
697
|
+
groups, AAA_AUTH_LOGIN_SERVICE_METHOD_NONE)
|
698
|
+
end
|
699
|
+
aaaauthloginservice_detach(aaaauthloginservice)
|
700
|
+
|
701
|
+
# repeat the test for service 'console'
|
702
|
+
service = 'console'
|
703
|
+
aaaauthloginservice =
|
704
|
+
AaaAuthenticationLoginService.new(service)
|
705
|
+
|
706
|
+
# one invalid group
|
707
|
+
groups = ['test1']
|
708
|
+
assert_raises(CliError) do
|
709
|
+
aaaauthloginservice.groups_method_set(
|
710
|
+
groups, AAA_AUTH_LOGIN_SERVICE_METHOD_UNSELECTED)
|
711
|
+
end
|
712
|
+
|
713
|
+
# multiple group with invalid group
|
714
|
+
groups = %w(rtp1 test1 bxb100)
|
715
|
+
assert_raises(RuntimeError) do
|
716
|
+
aaaauthloginservice.groups_method_set(
|
717
|
+
groups, AAA_AUTH_LOGIN_SERVICE_METHOD_LOCAL)
|
718
|
+
end
|
719
|
+
|
720
|
+
# multiple group with invalid group
|
721
|
+
groups = %w(rtp10 test1 bxb100)
|
722
|
+
assert_raises(CliError) do
|
723
|
+
aaaauthloginservice.groups_method_set(
|
724
|
+
groups, AAA_AUTH_LOGIN_SERVICE_METHOD_NONE)
|
725
|
+
end
|
726
|
+
aaaauthloginservice_detach(aaaauthloginservice)
|
727
|
+
unconfig_tacacs
|
728
|
+
end
|
729
|
+
|
730
|
+
def test_service_set_groups_invalid_method
|
731
|
+
# service default
|
732
|
+
service = 'default'
|
733
|
+
aaaauthloginservice =
|
734
|
+
AaaAuthenticationLoginService.new(service)
|
735
|
+
|
736
|
+
assert_raises(TypeError) do
|
737
|
+
aaaauthloginservice.groups_method_set([], 'bxb100')
|
738
|
+
end
|
739
|
+
|
740
|
+
assert_raises(ArgumentError) do
|
741
|
+
aaaauthloginservice.groups_method_set([], :invalid)
|
742
|
+
end
|
743
|
+
|
744
|
+
aaaauthloginservice_detach(aaaauthloginservice)
|
745
|
+
|
746
|
+
# service console
|
747
|
+
service = 'console'
|
748
|
+
aaaauthloginservice =
|
749
|
+
AaaAuthenticationLoginService.new(service)
|
750
|
+
|
751
|
+
assert_raises(TypeError) do
|
752
|
+
aaaauthloginservice.groups_method_set([], 'test')
|
753
|
+
end
|
754
|
+
|
755
|
+
assert_raises(TypeError) do
|
756
|
+
aaaauthloginservice.groups_method_set([], 15)
|
757
|
+
end
|
758
|
+
|
759
|
+
aaaauthloginservice_detach(aaaauthloginservice)
|
760
|
+
end
|
761
|
+
end
|