cisco_node_utils 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rspec +2 -0
- data/.rubocop.yml +13 -0
- data/.travis.yml +4 -1
- data/CHANGELOG.md +81 -2
- data/CONTRIBUTING.md +2 -17
- data/Gemfile +5 -0
- data/README.md +92 -47
- data/Rakefile +23 -1
- data/bin/git/hooks/hook_lib +7 -0
- data/bin/git/hooks/pre-commit/check_unstaged_changes +18 -0
- data/bin/git/hooks/pre-commit/rubocop +7 -2
- data/bin/git/hooks/pre-commit/validate-diffs +18 -4
- data/bin/git/hooks/pre-commit/validate-yaml +18 -0
- data/bin/git/update-hooks +64 -6
- data/cisco_node_utils.gemspec +9 -6
- data/docs/README-develop-best-practices.md +149 -50
- data/docs/README-develop-node-utils-APIs.md +92 -42
- data/docs/README-maintainers.md +7 -4
- data/docs/README-test-execution.md +57 -0
- data/docs/cisco_node_utils.yaml.example +30 -0
- data/docs/template-router.rb +4 -0
- data/ext/mkrf_conf.rb +63 -0
- data/lib/.rubocop.yml +2 -2
- data/lib/cisco_node_utils.rb +5 -0
- data/lib/cisco_node_utils/aaa_authentication_login.rb +5 -6
- data/lib/cisco_node_utils/aaa_authorization_service.rb +1 -1
- data/lib/cisco_node_utils/ace.rb +165 -12
- data/lib/cisco_node_utils/acl.rb +2 -1
- data/lib/cisco_node_utils/bgp.rb +184 -21
- data/lib/cisco_node_utils/bgp_af.rb +94 -249
- data/lib/cisco_node_utils/bgp_neighbor.rb +94 -14
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +75 -8
- data/lib/cisco_node_utils/bridge_domain.rb +183 -0
- data/lib/cisco_node_utils/bridge_domain_vni.rb +206 -0
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +85 -2
- data/lib/cisco_node_utils/client.rb +35 -0
- data/lib/cisco_node_utils/client/client.rb +234 -0
- data/lib/cisco_node_utils/client/grpc.rb +33 -0
- data/lib/cisco_node_utils/client/grpc/client.rb +311 -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/nxapi.rb +31 -0
- data/lib/cisco_node_utils/client/nxapi/client.rb +305 -0
- data/lib/cisco_node_utils/client/utils.rb +164 -0
- data/lib/cisco_node_utils/cmd_ref/README_YAML.md +222 -254
- data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +11 -8
- data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +22 -15
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +11 -8
- data/lib/cisco_node_utils/cmd_ref/acl.yaml +21 -16
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +239 -109
- data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +114 -55
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +76 -52
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +106 -62
- data/lib/cisco_node_utils/cmd_ref/bridge_domain.yaml +71 -0
- data/lib/cisco_node_utils/cmd_ref/bridge_domain_vni.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +35 -14
- data/lib/cisco_node_utils/cmd_ref/encapsulation.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +23 -17
- data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +94 -83
- data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +22 -17
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +76 -26
- data/lib/cisco_node_utils/cmd_ref/images.yaml +3 -2
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +381 -153
- data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +21 -11
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +21 -21
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +30 -21
- data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +18 -13
- data/lib/cisco_node_utils/cmd_ref/inventory.yaml +26 -31
- 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 +17 -6
- data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +10 -3
- data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +17 -5
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +33 -29
- data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +12 -10
- data/lib/cisco_node_utils/cmd_ref/pim.yaml +16 -19
- data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +40 -25
- data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +17 -12
- data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +71 -35
- data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +10 -5
- data/lib/cisco_node_utils/cmd_ref/show_system.yaml +6 -2
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +47 -43
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +13 -11
- data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +4 -2
- data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +23 -21
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +26 -22
- data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +19 -17
- data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +18 -6
- data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +234 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +24 -9
- data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +5 -3
- data/lib/cisco_node_utils/cmd_ref/system.yaml +4 -3
- data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +22 -20
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +27 -15
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +45 -16
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +21 -11
- data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +3 -2
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +60 -32
- data/lib/cisco_node_utils/cmd_ref/vpc.yaml +118 -101
- data/lib/cisco_node_utils/cmd_ref/vrf.yaml +54 -58
- data/lib/cisco_node_utils/cmd_ref/vrf_af.yaml +118 -0
- data/lib/cisco_node_utils/cmd_ref/vtp.yaml +19 -25
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +28 -18
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +34 -17
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +6 -4
- data/lib/cisco_node_utils/command_reference.rb +261 -142
- data/lib/cisco_node_utils/constants.rb +33 -0
- data/lib/cisco_node_utils/encapsulation.rb +112 -0
- data/lib/cisco_node_utils/environment.rb +102 -0
- data/lib/cisco_node_utils/evpn_vni.rb +5 -3
- data/lib/cisco_node_utils/exceptions.rb +111 -0
- data/lib/cisco_node_utils/fabricpath_global.rb +52 -35
- data/lib/cisco_node_utils/fabricpath_topology.rb +44 -57
- data/lib/cisco_node_utils/feature.rb +165 -3
- data/lib/cisco_node_utils/interface.rb +1051 -260
- data/lib/cisco_node_utils/interface_channel_group.rb +11 -10
- data/lib/cisco_node_utils/interface_ospf.rb +1 -2
- data/lib/cisco_node_utils/interface_portchannel.rb +4 -12
- data/lib/cisco_node_utils/interface_service_vni.rb +7 -7
- data/lib/cisco_node_utils/itd_device_group.rb +248 -0
- data/lib/cisco_node_utils/itd_device_group_node.rb +144 -0
- data/lib/cisco_node_utils/itd_service.rb +523 -0
- data/lib/cisco_node_utils/logger.rb +75 -0
- data/lib/cisco_node_utils/node.rb +62 -192
- data/lib/cisco_node_utils/node_util.rb +56 -10
- data/lib/cisco_node_utils/overlay_global.rb +2 -2
- data/lib/cisco_node_utils/pim.rb +2 -13
- data/lib/cisco_node_utils/pim_group_list.rb +1 -1
- data/lib/cisco_node_utils/pim_rp_address.rb +1 -1
- data/lib/cisco_node_utils/platform.rb +52 -21
- data/lib/cisco_node_utils/portchannel_global.rb +89 -19
- data/lib/cisco_node_utils/radius_server.rb +168 -37
- data/lib/cisco_node_utils/router_ospf.rb +20 -35
- data/lib/cisco_node_utils/router_ospf_vrf.rb +4 -4
- data/lib/cisco_node_utils/snmpserver.rb +1 -6
- data/lib/cisco_node_utils/snmpuser.rb +6 -4
- data/lib/cisco_node_utils/stp_global.rb +676 -0
- data/lib/cisco_node_utils/syslog_server.rb +77 -18
- data/lib/cisco_node_utils/syslog_settings.rb +1 -1
- data/lib/cisco_node_utils/tacacs_server_group.rb +8 -4
- data/lib/cisco_node_utils/tacacs_server_host.rb +115 -25
- data/lib/cisco_node_utils/vdc.rb +12 -0
- data/lib/cisco_node_utils/version.rb +1 -1
- data/lib/cisco_node_utils/vlan.rb +147 -29
- data/lib/cisco_node_utils/vpc.rb +55 -3
- data/lib/cisco_node_utils/vrf.rb +72 -11
- data/lib/cisco_node_utils/vrf_af.rb +114 -29
- data/lib/cisco_node_utils/vtp.rb +34 -52
- data/lib/cisco_node_utils/vxlan_vtep.rb +34 -8
- data/lib/cisco_node_utils/vxlan_vtep_vni.rb +36 -4
- 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 +263 -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 +75 -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 +2 -2
- data/tests/CSCuxdublin-1.0.0-7.0.3.I3.1.lib32_n9000.rpm +0 -0
- data/tests/basetest.rb +96 -36
- data/tests/ciscotest.rb +220 -12
- data/tests/cmd_config.yaml +71 -49
- data/tests/cmd_config_invalid.yaml +1 -1
- data/tests/test_aaa_authentication_login.rb +1 -0
- data/tests/test_aaa_authentication_login_service.rb +9 -0
- data/tests/test_aaa_authorization_service.rb +173 -367
- data/tests/test_ace.rb +171 -100
- data/tests/test_acl.rb +10 -1
- data/tests/test_bgp_af.rb +395 -728
- data/tests/test_bgp_neighbor.rb +274 -115
- data/tests/test_bgp_neighbor_af.rb +178 -77
- data/tests/test_bridge_domain.rb +191 -0
- data/tests/test_bridge_domain_vni.rb +116 -0
- data/tests/test_client_utils.rb +111 -0
- data/tests/test_command_config.rb +9 -5
- data/tests/test_command_reference.rb +380 -102
- data/tests/test_dns_domain.rb +13 -3
- data/tests/test_domain_name.rb +13 -3
- data/tests/test_encapsulation.rb +77 -0
- data/tests/test_evpn_vni.rb +25 -7
- data/tests/test_fabricpath_global.rb +167 -163
- data/tests/test_fabricpath_topology.rb +12 -33
- data/tests/test_feature.rb +215 -0
- data/tests/test_grpc.rb +166 -0
- data/tests/test_interface.rb +585 -344
- data/tests/test_interface_bdi.rb +80 -0
- data/tests/test_interface_channel_group.rb +6 -3
- data/tests/test_interface_ospf.rb +26 -24
- data/tests/test_interface_portchannel.rb +1 -0
- data/tests/test_interface_private_vlan.rb +724 -0
- data/tests/test_interface_service_vni.rb +37 -66
- data/tests/test_interface_svi.rb +98 -101
- data/tests/test_interface_switchport.rb +419 -549
- 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 +298 -0
- data/tests/test_logger.rb +43 -0
- data/tests/test_name_server.rb +11 -2
- data/tests/test_node.rb +16 -75
- data/tests/test_node_ext.rb +174 -163
- data/tests/test_node_util.rb +119 -0
- data/tests/test_ntp_config.rb +5 -1
- data/tests/test_ntp_server.rb +2 -2
- data/tests/test_nxapi.rb +221 -0
- data/tests/test_overlay_global.rb +47 -38
- data/tests/test_pim.rb +2 -0
- data/tests/test_pim_group_list.rb +2 -0
- data/tests/test_pim_rp_address.rb +2 -0
- data/tests/test_platform.rb +86 -39
- data/tests/test_portchannel_global.rb +211 -135
- data/tests/test_radius_global.rb +13 -5
- data/tests/test_radius_server.rb +256 -104
- data/tests/test_radius_server_group.rb +2 -0
- data/tests/test_router_bgp.rb +781 -485
- data/tests/test_router_ospf.rb +26 -103
- data/tests/test_router_ospf_vrf.rb +52 -57
- data/tests/test_snmp_notification_receiver.rb +2 -0
- data/tests/test_snmpcommunity.rb +2 -0
- data/tests/test_snmpgroup.rb +2 -0
- data/tests/test_snmpnotification.rb +40 -21
- data/tests/test_snmpserver.rb +2 -0
- data/tests/test_snmpuser.rb +2 -0
- data/tests/test_stp_global.rb +563 -0
- data/tests/test_syslog_server.rb +32 -8
- data/tests/test_syslog_settings.rb +22 -9
- data/tests/test_tacacs_server.rb +32 -27
- data/tests/test_tacacs_server_group.rb +100 -45
- data/tests/test_tacacs_server_host.rb +135 -43
- data/tests/test_vdc.rb +2 -16
- data/tests/test_vlan.rb +106 -54
- data/tests/test_vlan_mt_full.rb +11 -21
- data/tests/test_vlan_private.rb +669 -0
- data/tests/test_vpc.rb +312 -159
- data/tests/test_vrf.rb +122 -113
- data/tests/test_vrf_af.rb +238 -0
- data/tests/test_vtp.rb +58 -102
- data/tests/test_vxlan_vtep.rb +38 -17
- data/tests/test_vxlan_vtep_vni.rb +61 -9
- data/tests/test_yum.rb +49 -25
- metadata +122 -36
- data/lib/cisco_node_utils/cmd_ref/fex.yaml +0 -9
- data/lib/cisco_node_utils/cmd_ref/vni.yaml +0 -76
- data/lib/cisco_node_utils/vni.rb +0 -227
- data/tests/test_vni.rb +0 -106
|
@@ -17,57 +17,84 @@ require_relative '../lib/cisco_node_utils/aaa_authorization_service'
|
|
|
17
17
|
|
|
18
18
|
# TestAaaAuthorizationService - Minitest for AaaAuthorizationService util
|
|
19
19
|
class TestAaaAuthorizationService < CiscoTestCase
|
|
20
|
+
@skip_unless_supported = 'aaa_authorization_service'
|
|
21
|
+
@@pre_clean_needed = true # rubocop:disable Style/ClassVars
|
|
22
|
+
|
|
20
23
|
def setup
|
|
21
24
|
super
|
|
25
|
+
# TBD: Remove once CSCuz44696 is resolved.
|
|
26
|
+
skip('This test is not currently supported on 7.0(3)I3 images') if
|
|
27
|
+
node.os_version[/7.0\(3\)I3\(/]
|
|
28
|
+
|
|
29
|
+
cleanup_aaa if @@pre_clean_needed
|
|
30
|
+
@@pre_clean_needed = false # rubocop:disable Style/ClassVars
|
|
22
31
|
feature_tacacs
|
|
32
|
+
preconfig_tacacs_server_access(tacacs_groups[0])
|
|
33
|
+
config_tacacs_servers(tacacs_groups[1..3])
|
|
23
34
|
end
|
|
24
35
|
|
|
25
36
|
def teardown
|
|
37
|
+
cleanup_aaa
|
|
26
38
|
feature_tacacs(false)
|
|
27
39
|
super
|
|
28
40
|
end
|
|
29
41
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if keep
|
|
35
|
-
config('tacacs-server key testing123',
|
|
36
|
-
'tacacs-server host 10.122.197.197 key testing123',
|
|
37
|
-
"aaa group server tacacs+ #{group_name}",
|
|
38
|
-
'server 10.122.197.197',
|
|
39
|
-
'use-vrf management',
|
|
40
|
-
'source-interface mgmt0',
|
|
41
|
-
'aaa authentication login ascii-authentication')
|
|
42
|
-
else
|
|
43
|
-
config("no aaa group server tacacs+ #{group_name}")
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def feature_tacacs(feature=true)
|
|
48
|
-
if feature
|
|
49
|
-
config('feature tacacs')
|
|
50
|
-
else
|
|
51
|
-
config('no feature tacacs',
|
|
52
|
-
'no aaa authentication login ascii-authentication')
|
|
42
|
+
def cleanup_aaa
|
|
43
|
+
cmds = config('show run aaa').scan(/^aaa auth.*/)
|
|
44
|
+
cmds.each do |cmd|
|
|
45
|
+
config("no #{cmd}")
|
|
53
46
|
end
|
|
54
47
|
end
|
|
55
48
|
|
|
56
49
|
def config_tacacs_servers(servers)
|
|
57
|
-
config('feature tacacs+')
|
|
58
50
|
servers.each do |server|
|
|
59
51
|
config("aaa group server tacacs+ #{server}")
|
|
60
52
|
end
|
|
61
53
|
end
|
|
62
54
|
|
|
63
|
-
def
|
|
64
|
-
|
|
55
|
+
def feature_tacacs(feature=true)
|
|
56
|
+
state = feature ? '' : 'no'
|
|
57
|
+
config("#{state} feature tacacs+")
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Helper method to get regexp for aaa authorization commands
|
|
61
|
+
def get_pattern(cmd_type, service, groups, method=:unselected)
|
|
62
|
+
cmd_type = cmd_type == :config_commands ? 'config-commands' : cmd_type.to_s
|
|
63
|
+
groups = groups.join(' ') if groups.is_a? Array
|
|
64
|
+
method = method == :unselected ? '' : method.to_s
|
|
65
|
+
p = prefix
|
|
66
|
+
p << ' ' + cmd_type
|
|
67
|
+
p << ' ' + service
|
|
68
|
+
p << ' group ' + groups unless groups.empty?
|
|
69
|
+
p << ' ' + method unless method.empty?
|
|
70
|
+
Regexp.new(p)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Method to pre-configure a valid tacacs server and aaa group. This
|
|
74
|
+
# group can be included in the testing such access to the device
|
|
75
|
+
# never is compromised.
|
|
76
|
+
def preconfig_tacacs_server_access(group_name)
|
|
77
|
+
config('tacacs-server key testing123',
|
|
78
|
+
'tacacs-server host 10.122.197.197 key testing123',
|
|
79
|
+
"aaa group server tacacs+ #{group_name}",
|
|
80
|
+
'server 10.122.197.197',
|
|
81
|
+
'use-vrf management',
|
|
82
|
+
'source-interface mgmt0',
|
|
83
|
+
'aaa authentication login ascii-authentication')
|
|
65
84
|
end
|
|
66
85
|
|
|
67
86
|
def prefix
|
|
68
87
|
'aaa authorization'
|
|
69
88
|
end
|
|
70
89
|
|
|
90
|
+
def show_cmd
|
|
91
|
+
'show run aaa all | no-more'
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def tacacs_groups
|
|
95
|
+
%w(tac_group bxb100 sjc200 rtp10)
|
|
96
|
+
end
|
|
97
|
+
|
|
71
98
|
def test_create_unsupported_type
|
|
72
99
|
assert_raises(ArgumentError) do
|
|
73
100
|
AaaAuthorizationService.new(:none, 'default')
|
|
@@ -355,57 +382,31 @@ class TestAaaAuthorizationService < CiscoTestCase
|
|
|
355
382
|
'Error: AaaAuthorizationService commands, ' \
|
|
356
383
|
'get groups for default')
|
|
357
384
|
|
|
358
|
-
# Preconfigure tacacs, tacacs server and AAA valid group
|
|
359
|
-
group0 = 'tac_group'
|
|
360
|
-
preconfig_tacacs_server_access(group0)
|
|
361
|
-
|
|
362
|
-
# Preconfig for test
|
|
363
|
-
group1 = 'bxb100'
|
|
364
|
-
group2 = 'sjc200'
|
|
365
|
-
group3 = 'rtp10'
|
|
366
|
-
servers = [group1, group2, group3]
|
|
367
|
-
config_tacacs_servers(servers)
|
|
368
|
-
|
|
369
385
|
config('aaa authorization commands default group ' \
|
|
370
|
-
"#{
|
|
386
|
+
"#{tacacs_groups[0..2].join(' ')}")
|
|
371
387
|
|
|
372
|
-
|
|
373
|
-
assert_equal(
|
|
374
|
-
'Error: AaaAuthorizationService default get groups, 0/1/2')
|
|
375
|
-
assert_equal(:unselected, aaa_a_service.method,
|
|
376
|
-
'Error: AaaAuthorizationService default get method, 0/1/2')
|
|
388
|
+
assert_equal(tacacs_groups[0..2], aaa_a_service.groups)
|
|
389
|
+
assert_equal(:unselected, aaa_a_service.method)
|
|
377
390
|
|
|
378
391
|
# Change the config to have different groups and method
|
|
379
392
|
config('aaa authorization commands default group ' \
|
|
380
|
-
"#{
|
|
393
|
+
"#{tacacs_groups[0]} #{tacacs_groups[3]} #{tacacs_groups[1]} local")
|
|
381
394
|
|
|
382
|
-
|
|
383
|
-
assert_equal(
|
|
384
|
-
|
|
385
|
-
assert_equal(:local, aaa_a_service.method,
|
|
386
|
-
'Error: AaaAuthorizationService default get method, 0/3/1')
|
|
395
|
+
conf_groups = [tacacs_groups[0], tacacs_groups[3], tacacs_groups[1]]
|
|
396
|
+
assert_equal(conf_groups, aaa_a_service.groups)
|
|
397
|
+
assert_equal(:local, aaa_a_service.method)
|
|
387
398
|
|
|
388
399
|
# Mix default and console, but since our instance is for 'default'
|
|
389
400
|
# service we should only get 'default' groups and not 'console'
|
|
390
401
|
# groups.
|
|
391
402
|
aaa_cmd1 = 'aaa authorization commands default group ' \
|
|
392
|
-
"#{
|
|
403
|
+
"#{tacacs_groups.join(' ')} local"
|
|
393
404
|
aaa_cmd2 = 'aaa authorization commands console group ' \
|
|
394
|
-
"#{
|
|
405
|
+
"#{tacacs_groups[1..3].join(' ')} local"
|
|
395
406
|
config(aaa_cmd1, aaa_cmd2)
|
|
396
407
|
|
|
397
|
-
|
|
398
|
-
assert_equal(
|
|
399
|
-
'Error: AaaAuthorizationService default get groups, 0/2/1/3')
|
|
400
|
-
assert_equal(:local, aaa_a_service.method,
|
|
401
|
-
'Error: AaaAuthorizationService default get method, 0/3/1')
|
|
402
|
-
|
|
403
|
-
# Cleanup
|
|
404
|
-
aaa_a_service.destroy
|
|
405
|
-
config("no #{aaa_cmd1}", "no #{aaa_cmd2}")
|
|
406
|
-
|
|
407
|
-
# Unconfigure tacacs, tacacs server and AAA valid group
|
|
408
|
-
preconfig_tacacs_server_access(group0, false)
|
|
408
|
+
assert_equal(tacacs_groups, aaa_a_service.groups)
|
|
409
|
+
assert_equal(:local, aaa_a_service.method)
|
|
409
410
|
end
|
|
410
411
|
|
|
411
412
|
def test_collection_groups_commands_console
|
|
@@ -413,62 +414,33 @@ class TestAaaAuthorizationService < CiscoTestCase
|
|
|
413
414
|
aaa_a_service = AaaAuthorizationService.new(type, 'console')
|
|
414
415
|
|
|
415
416
|
# Default case
|
|
416
|
-
assert_equal(aaa_a_service.default_groups, aaa_a_service.groups
|
|
417
|
-
'Error: AaaAuthorizationService commands, ' \
|
|
418
|
-
'get groups for console')
|
|
419
|
-
|
|
420
|
-
# Preconfigure tacacs, tacacs server and AAA valid group
|
|
421
|
-
group0 = 'tac_group'
|
|
422
|
-
preconfig_tacacs_server_access(group0)
|
|
423
|
-
|
|
424
|
-
# Preconfig for test
|
|
425
|
-
group1 = 'bxb100'
|
|
426
|
-
group2 = 'sjc200'
|
|
427
|
-
group3 = 'rtp10'
|
|
428
|
-
servers = [group1, group2, group3]
|
|
429
|
-
config_tacacs_servers(servers)
|
|
417
|
+
assert_equal(aaa_a_service.default_groups, aaa_a_service.groups)
|
|
430
418
|
|
|
431
419
|
config('aaa authorization commands console group ' \
|
|
432
|
-
"#{
|
|
420
|
+
"#{tacacs_groups[0..2].join(' ')}")
|
|
433
421
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
assert_equal(groups, aaa_a_service.groups,
|
|
437
|
-
'Error: AaaAuthorizationService console get groups, 0/1/2')
|
|
438
|
-
assert_equal(:unselected, aaa_a_service.method,
|
|
439
|
-
'Error: AaaAuthorizationService default get method, 0/1/2')
|
|
422
|
+
assert_equal(tacacs_groups[0..2], aaa_a_service.groups)
|
|
423
|
+
assert_equal(:unselected, aaa_a_service.method)
|
|
440
424
|
|
|
441
425
|
# Change the config to have different groups and method
|
|
442
426
|
config('aaa authorization commands console group ' \
|
|
443
|
-
"#{
|
|
427
|
+
"#{tacacs_groups[0]} #{tacacs_groups[3]} #{tacacs_groups[1]} local")
|
|
444
428
|
|
|
445
|
-
|
|
446
|
-
assert_equal(
|
|
447
|
-
|
|
448
|
-
assert_equal(:local, aaa_a_service.method,
|
|
449
|
-
'Error: AaaAuthorizationService default get method, 0/3/1')
|
|
429
|
+
conf_groups = [tacacs_groups[0], tacacs_groups[3], tacacs_groups[1]]
|
|
430
|
+
assert_equal(conf_groups, aaa_a_service.groups)
|
|
431
|
+
assert_equal(:local, aaa_a_service.method)
|
|
450
432
|
|
|
451
433
|
# Mix default and console, but since our instance is for 'console'
|
|
452
434
|
# service we should only get 'console' groups and not 'default'
|
|
453
435
|
# groups.
|
|
454
436
|
aaa_cmd1 = 'aaa authorization commands console group ' \
|
|
455
|
-
"#{
|
|
437
|
+
"#{tacacs_groups.join(' ')} local"
|
|
456
438
|
aaa_cmd2 = 'aaa authorization commands default group ' \
|
|
457
|
-
"#{
|
|
439
|
+
"#{tacacs_groups[1..3].join(' ')} local"
|
|
458
440
|
config(aaa_cmd1, aaa_cmd2)
|
|
459
441
|
|
|
460
|
-
|
|
461
|
-
assert_equal(
|
|
462
|
-
'Error: AaaAuthorizationService console get groups, 0/2/1/3')
|
|
463
|
-
assert_equal(:local, aaa_a_service.method,
|
|
464
|
-
'Error: AaaAuthorizationService default get method, 0/2/1/3')
|
|
465
|
-
|
|
466
|
-
# Cleanup
|
|
467
|
-
aaa_a_service.destroy
|
|
468
|
-
config("no #{aaa_cmd1}", "no #{aaa_cmd2}")
|
|
469
|
-
|
|
470
|
-
# Unconfigure tacacs, tacacs server and AAA valid group
|
|
471
|
-
preconfig_tacacs_server_access(group0, false)
|
|
442
|
+
assert_equal(tacacs_groups, aaa_a_service.groups)
|
|
443
|
+
assert_equal(:local, aaa_a_service.method)
|
|
472
444
|
end
|
|
473
445
|
|
|
474
446
|
def test_collection_groups_config_commands_default
|
|
@@ -476,62 +448,33 @@ class TestAaaAuthorizationService < CiscoTestCase
|
|
|
476
448
|
aaa_a_service = AaaAuthorizationService.new(type, 'default')
|
|
477
449
|
|
|
478
450
|
# Default case
|
|
479
|
-
assert_equal(aaa_a_service.default_groups, aaa_a_service.groups
|
|
480
|
-
'Error: AaaAuthorizationService config-commands, ' \
|
|
481
|
-
'get groups for default')
|
|
482
|
-
|
|
483
|
-
# Preconfigure tacacs, tacacs server and AAA valid group
|
|
484
|
-
group0 = 'tac_group'
|
|
485
|
-
preconfig_tacacs_server_access(group0)
|
|
486
|
-
|
|
487
|
-
# Preconfig for test
|
|
488
|
-
group1 = 'bxb100'
|
|
489
|
-
group2 = 'sjc200'
|
|
490
|
-
group3 = 'rtp10'
|
|
491
|
-
servers = [group1, group2, group3]
|
|
492
|
-
config_tacacs_servers(servers)
|
|
451
|
+
assert_equal(aaa_a_service.default_groups, aaa_a_service.groups)
|
|
493
452
|
|
|
494
453
|
config('aaa authorization config-commands default group ' \
|
|
495
|
-
"#{
|
|
454
|
+
"#{tacacs_groups[0]} #{tacacs_groups[1]} #{tacacs_groups[2]}")
|
|
496
455
|
|
|
497
|
-
|
|
498
|
-
assert_equal(
|
|
499
|
-
'Error: AaaAuthorizationService default get groups, 0/1/2')
|
|
500
|
-
assert_equal(:unselected, aaa_a_service.method,
|
|
501
|
-
'Error: AaaAuthorizationService default get method, 0/1/2')
|
|
456
|
+
assert_equal(tacacs_groups[0..2], aaa_a_service.groups)
|
|
457
|
+
assert_equal(:unselected, aaa_a_service.method)
|
|
502
458
|
|
|
503
459
|
# Change the config to have different groups and method
|
|
504
460
|
config('aaa authorization config-commands default group ' \
|
|
505
|
-
"#{
|
|
461
|
+
"#{tacacs_groups[0]} #{tacacs_groups[3]} #{tacacs_groups[1]} local")
|
|
506
462
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
assert_equal(
|
|
510
|
-
'Error: AaaAuthorizationService default get groups, 0/3/1')
|
|
511
|
-
assert_equal(:local, aaa_a_service.method,
|
|
512
|
-
'Error: AaaAuthorizationService default get method, 0/3/1')
|
|
463
|
+
conf_groups = [tacacs_groups[0], tacacs_groups[3], tacacs_groups[1]]
|
|
464
|
+
assert_equal(conf_groups, aaa_a_service.groups)
|
|
465
|
+
assert_equal(:local, aaa_a_service.method)
|
|
513
466
|
|
|
514
467
|
# Mix default and console, but since our instance is for 'default'
|
|
515
468
|
# service we should only get 'default' groups and not 'console'
|
|
516
469
|
# groups.
|
|
517
470
|
aaa_cmd1 = 'aaa authorization config-commands default group ' \
|
|
518
|
-
"#{
|
|
471
|
+
"#{tacacs_groups.join(' ')} local"
|
|
519
472
|
aaa_cmd2 = 'aaa authorization config-commands console group ' \
|
|
520
|
-
"#{
|
|
473
|
+
"#{tacacs_groups[1..3].join(' ')} local"
|
|
521
474
|
config(aaa_cmd1, aaa_cmd2)
|
|
522
475
|
|
|
523
|
-
|
|
524
|
-
assert_equal(
|
|
525
|
-
'Error: AaaAuthorizationService default get groups, 0/2/1/3')
|
|
526
|
-
assert_equal(:local, aaa_a_service.method,
|
|
527
|
-
'Error: AaaAuthorizationService default get method, 0/2/1/3')
|
|
528
|
-
|
|
529
|
-
# Cleanup
|
|
530
|
-
aaa_a_service.destroy
|
|
531
|
-
config("no #{aaa_cmd1}", "no #{aaa_cmd2}")
|
|
532
|
-
|
|
533
|
-
# Unconfigure tacacs, tacacs server and AAA valid group
|
|
534
|
-
preconfig_tacacs_server_access(group0, false)
|
|
476
|
+
assert_equal(tacacs_groups, aaa_a_service.groups)
|
|
477
|
+
assert_equal(:local, aaa_a_service.method)
|
|
535
478
|
end
|
|
536
479
|
|
|
537
480
|
def test_collection_groups_config_commands_console
|
|
@@ -539,62 +482,33 @@ class TestAaaAuthorizationService < CiscoTestCase
|
|
|
539
482
|
aaa_a_service = AaaAuthorizationService.new(type, 'console')
|
|
540
483
|
|
|
541
484
|
# Default case
|
|
542
|
-
assert_equal(aaa_a_service.default_groups, aaa_a_service.groups
|
|
543
|
-
'Error: AaaAuthorizationService config-commands, ' \
|
|
544
|
-
'get groups for console')
|
|
545
|
-
|
|
546
|
-
# Preconfigure tacacs, tacacs server and AAA valid group
|
|
547
|
-
group0 = 'tac_group'
|
|
548
|
-
preconfig_tacacs_server_access(group0)
|
|
549
|
-
|
|
550
|
-
# Preconfig for test
|
|
551
|
-
group1 = 'bxb100'
|
|
552
|
-
group2 = 'sjc200'
|
|
553
|
-
group3 = 'rtp10'
|
|
554
|
-
servers = [group1, group2, group3]
|
|
555
|
-
config_tacacs_servers(servers)
|
|
485
|
+
assert_equal(aaa_a_service.default_groups, aaa_a_service.groups)
|
|
556
486
|
|
|
557
487
|
config('aaa authorization config-commands console group ' \
|
|
558
|
-
"#{
|
|
488
|
+
"#{tacacs_groups[0..2].join(' ')}")
|
|
559
489
|
|
|
560
|
-
|
|
561
|
-
assert_equal(
|
|
562
|
-
'Error: AaaAuthorizationService console get groups, 0/1/2')
|
|
563
|
-
assert_equal(:unselected, aaa_a_service.method,
|
|
564
|
-
'Error: AaaAuthorizationService default get method, 0/1/2')
|
|
490
|
+
assert_equal(tacacs_groups[0..2], aaa_a_service.groups)
|
|
491
|
+
assert_equal(:unselected, aaa_a_service.method)
|
|
565
492
|
|
|
566
493
|
# Change the config to have different groups and method
|
|
567
494
|
config('aaa authorization config-commands console group ' \
|
|
568
|
-
"#{
|
|
495
|
+
"#{tacacs_groups[0]} #{tacacs_groups[3]} #{tacacs_groups[1]} local")
|
|
569
496
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
assert_equal(
|
|
573
|
-
'Error: AaaAuthorizationService console get groups, 0/3/1')
|
|
574
|
-
assert_equal(:local, aaa_a_service.method,
|
|
575
|
-
'Error: AaaAuthorizationService default get method, 0/3/1')
|
|
497
|
+
conf_groups = [tacacs_groups[0], tacacs_groups[3], tacacs_groups[1]]
|
|
498
|
+
assert_equal(conf_groups, aaa_a_service.groups)
|
|
499
|
+
assert_equal(:local, aaa_a_service.method)
|
|
576
500
|
|
|
577
501
|
# Mix default and console, but since our instance is for 'console'
|
|
578
502
|
# service we should only get 'console' groups and not 'default'
|
|
579
503
|
# groups.
|
|
580
504
|
aaa_cmd1 = 'aaa authorization config-commands console group ' \
|
|
581
|
-
"#{
|
|
505
|
+
"#{tacacs_groups.join(' ')} local"
|
|
582
506
|
aaa_cmd2 = 'aaa authorization config-commands default group ' \
|
|
583
|
-
"#{
|
|
507
|
+
"#{tacacs_groups[1..3].join(' ')} local"
|
|
584
508
|
config(aaa_cmd1, aaa_cmd2)
|
|
585
509
|
|
|
586
|
-
|
|
587
|
-
assert_equal(
|
|
588
|
-
'Error: AaaAuthorizationService console get groups, 0/2/1/3')
|
|
589
|
-
assert_equal(:local, aaa_a_service.method,
|
|
590
|
-
'Error: AaaAuthorizationService default get method, 0/2/1/3')
|
|
591
|
-
|
|
592
|
-
# Cleanup
|
|
593
|
-
aaa_a_service.destroy
|
|
594
|
-
config("no #{aaa_cmd1}", "no #{aaa_cmd2}")
|
|
595
|
-
|
|
596
|
-
# Unconfigure tacacs, tacacs server and AAA valid group
|
|
597
|
-
preconfig_tacacs_server_access(group0, false)
|
|
510
|
+
assert_equal(tacacs_groups, aaa_a_service.groups)
|
|
511
|
+
assert_equal(:local, aaa_a_service.method)
|
|
598
512
|
end
|
|
599
513
|
|
|
600
514
|
def test_get_default_groups
|
|
@@ -630,240 +544,144 @@ class TestAaaAuthorizationService < CiscoTestCase
|
|
|
630
544
|
aaa_a_service.destroy
|
|
631
545
|
end
|
|
632
546
|
|
|
633
|
-
def
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
preconfig_tacacs_server_access(group0)
|
|
637
|
-
|
|
638
|
-
# Preconfig for test
|
|
639
|
-
group1 = 'bxb100'
|
|
640
|
-
group2 = 'sjc200'
|
|
641
|
-
group3 = 'rtp10'
|
|
642
|
-
servers = [group1, group2, group3]
|
|
643
|
-
config_tacacs_servers(servers)
|
|
644
|
-
|
|
645
|
-
# Commands, service default
|
|
646
|
-
type_str = 'commands'
|
|
647
|
-
type = :commands
|
|
648
|
-
service = 'default'
|
|
649
|
-
aaa_a_service = AaaAuthorizationService.new(type, service)
|
|
650
|
-
|
|
651
|
-
# Single group, with method 'unselected'
|
|
652
|
-
method = :unselected
|
|
653
|
-
groups = [group0]
|
|
654
|
-
aaa_a_service.groups_method_set(groups, method)
|
|
547
|
+
def test_commands_default_unselected_single
|
|
548
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'default')
|
|
549
|
+
aaa_a_service.groups_method_set(tacacs_groups[0], :unselected)
|
|
655
550
|
|
|
656
|
-
p =
|
|
551
|
+
p = get_pattern(:commands, 'default', tacacs_groups[0])
|
|
657
552
|
assert_show_match(command: show_cmd, pattern: p)
|
|
553
|
+
end
|
|
658
554
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
aaa_a_service.groups_method_set(groups, method)
|
|
555
|
+
def test_commands_default_unselected_multi
|
|
556
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'default')
|
|
557
|
+
aaa_a_service.groups_method_set(tacacs_groups[0..2], :unselected)
|
|
663
558
|
|
|
664
|
-
p =
|
|
559
|
+
p = get_pattern(:commands, 'default', tacacs_groups[0..2])
|
|
665
560
|
assert_show_match(command: show_cmd, pattern: p)
|
|
561
|
+
end
|
|
666
562
|
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
aaa_a_service.groups_method_set(groups, method)
|
|
563
|
+
def test_commands_default_local_multi
|
|
564
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'default')
|
|
565
|
+
aaa_a_service.groups_method_set(tacacs_groups[0..2], :local)
|
|
671
566
|
|
|
672
|
-
|
|
673
|
-
p = /#{prefix} #{type_str} #{service} #{group_str} local/
|
|
567
|
+
p = get_pattern(:commands, 'default', tacacs_groups[0..2], :local)
|
|
674
568
|
assert_show_match(command: show_cmd, pattern: p)
|
|
569
|
+
end
|
|
675
570
|
|
|
676
|
-
|
|
571
|
+
def test_commands_default_all_default
|
|
572
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'default')
|
|
677
573
|
method = aaa_a_service.default_method
|
|
678
574
|
groups = aaa_a_service.default_groups
|
|
679
575
|
aaa_a_service.groups_method_set(groups, method)
|
|
680
576
|
|
|
681
|
-
p =
|
|
577
|
+
p = get_pattern(:commands, 'default', groups, method)
|
|
682
578
|
assert_show_match(command: show_cmd, pattern: p)
|
|
683
|
-
|
|
684
|
-
# Cleanup
|
|
685
|
-
aaa_a_service.destroy
|
|
686
|
-
|
|
687
|
-
# Unconfigure tacacs, tacacs server and AAA valid group
|
|
688
|
-
preconfig_tacacs_server_access(group0, false)
|
|
689
579
|
end
|
|
690
580
|
|
|
691
|
-
def
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
preconfig_tacacs_server_access(group0)
|
|
695
|
-
|
|
696
|
-
# Preconfig for test
|
|
697
|
-
group1 = 'bxb100'
|
|
698
|
-
group2 = 'sjc200'
|
|
699
|
-
group3 = 'rtp10'
|
|
700
|
-
servers = [group1, group2, group3]
|
|
701
|
-
config_tacacs_servers(servers)
|
|
702
|
-
|
|
703
|
-
# Commands, service console
|
|
704
|
-
type_str = 'commands'
|
|
705
|
-
type = :commands
|
|
706
|
-
service = 'console'
|
|
707
|
-
aaa_a_service = AaaAuthorizationService.new(type, service)
|
|
708
|
-
|
|
709
|
-
# Single group, with method 'unselected'
|
|
710
|
-
method = :unselected
|
|
711
|
-
groups = [group0]
|
|
712
|
-
aaa_a_service.groups_method_set(groups, method)
|
|
581
|
+
def test_commands_console_unselected_single
|
|
582
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'console')
|
|
583
|
+
aaa_a_service.groups_method_set(tacacs_groups[0], :unselected)
|
|
713
584
|
|
|
714
|
-
p =
|
|
585
|
+
p = get_pattern(:commands, 'console', tacacs_groups[0])
|
|
715
586
|
assert_show_match(command: show_cmd, pattern: p)
|
|
587
|
+
end
|
|
716
588
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
aaa_a_service.groups_method_set(groups, method)
|
|
589
|
+
def test_commands_console_unselected_multi
|
|
590
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'console')
|
|
591
|
+
aaa_a_service.groups_method_set(tacacs_groups[0..2], :unselected)
|
|
721
592
|
|
|
722
|
-
p =
|
|
593
|
+
p = get_pattern(:commands, 'console', tacacs_groups[0..2])
|
|
723
594
|
assert_show_match(command: show_cmd, pattern: p)
|
|
595
|
+
end
|
|
724
596
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
aaa_a_service.groups_method_set(groups, method)
|
|
597
|
+
def test_commands_console_local_multi
|
|
598
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'console')
|
|
599
|
+
aaa_a_service.groups_method_set(tacacs_groups[0..2], :local)
|
|
729
600
|
|
|
730
|
-
|
|
731
|
-
p = /#{prefix} #{type_str} #{service} #{group_str} local/
|
|
601
|
+
p = get_pattern(:commands, 'console', tacacs_groups[0..2], :local)
|
|
732
602
|
assert_show_match(command: show_cmd, pattern: p)
|
|
603
|
+
end
|
|
733
604
|
|
|
734
|
-
|
|
605
|
+
def test_commans_console_all_default
|
|
606
|
+
aaa_a_service = AaaAuthorizationService.new(:commands, 'console')
|
|
735
607
|
method = aaa_a_service.default_method
|
|
736
608
|
groups = aaa_a_service.default_groups
|
|
737
609
|
aaa_a_service.groups_method_set(groups, method)
|
|
738
610
|
|
|
739
|
-
p =
|
|
611
|
+
p = get_pattern(:commands, 'console', groups, method)
|
|
740
612
|
assert_show_match(command: show_cmd, pattern: p)
|
|
741
|
-
|
|
742
|
-
aaa_a_service.destroy
|
|
743
|
-
|
|
744
|
-
# Unconfigure tacacs, tacacs server and AAA valid group
|
|
745
|
-
preconfig_tacacs_server_access(group0, false)
|
|
746
613
|
end
|
|
747
614
|
|
|
748
|
-
def
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
preconfig_tacacs_server_access(group0)
|
|
752
|
-
|
|
753
|
-
# Preconfig for test
|
|
754
|
-
group1 = 'bxb100'
|
|
755
|
-
group2 = 'sjc200'
|
|
756
|
-
group3 = 'rtp10'
|
|
757
|
-
servers = [group1, group2, group3]
|
|
758
|
-
config_tacacs_servers(servers)
|
|
759
|
-
|
|
760
|
-
# Commands, service default
|
|
761
|
-
type_str = 'config-commands'
|
|
762
|
-
type = :config_commands
|
|
763
|
-
service = 'default'
|
|
764
|
-
aaa_a_service = AaaAuthorizationService.new(type, service)
|
|
765
|
-
|
|
766
|
-
# Single group, with method 'unselected'
|
|
767
|
-
method = :unselected
|
|
768
|
-
groups = [group0]
|
|
769
|
-
aaa_a_service.groups_method_set(groups, method)
|
|
615
|
+
def test_config_commands_default_unselected_single
|
|
616
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'default')
|
|
617
|
+
aaa_a_service.groups_method_set(tacacs_groups[0], :unselected)
|
|
770
618
|
|
|
771
|
-
p =
|
|
619
|
+
p = get_pattern(:config_commands, 'default', tacacs_groups[0])
|
|
772
620
|
assert_show_match(command: show_cmd, pattern: p)
|
|
621
|
+
end
|
|
773
622
|
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
aaa_a_service.groups_method_set(groups, method)
|
|
623
|
+
def test_config_commands_default_unselected_multi
|
|
624
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'default')
|
|
625
|
+
aaa_a_service.groups_method_set(tacacs_groups[0..2], :unselected)
|
|
778
626
|
|
|
779
|
-
p =
|
|
627
|
+
p = get_pattern(:config_commands, 'default', tacacs_groups[0..2])
|
|
780
628
|
assert_show_match(command: show_cmd, pattern: p)
|
|
629
|
+
end
|
|
781
630
|
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
aaa_a_service.groups_method_set(groups, method)
|
|
631
|
+
def test_config_commands_default_local_multi
|
|
632
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'default')
|
|
633
|
+
aaa_a_service.groups_method_set(tacacs_groups[0..2], :local)
|
|
786
634
|
|
|
787
|
-
|
|
788
|
-
p = /#{prefix} #{type_str} #{service} #{group_str} local/
|
|
635
|
+
p = get_pattern(:config_commands, 'default', tacacs_groups[0..2], :local)
|
|
789
636
|
assert_show_match(command: show_cmd, pattern: p)
|
|
637
|
+
end
|
|
638
|
+
|
|
639
|
+
def test_config_commands_default_all_default
|
|
640
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'default')
|
|
790
641
|
|
|
791
|
-
# Default group and method
|
|
792
642
|
method = aaa_a_service.default_method
|
|
793
643
|
groups = aaa_a_service.default_groups
|
|
794
644
|
aaa_a_service.groups_method_set(groups, method)
|
|
795
645
|
|
|
796
|
-
p =
|
|
646
|
+
p = get_pattern(:config_commands, 'default', groups, method)
|
|
797
647
|
assert_show_match(command: show_cmd, pattern: p)
|
|
798
|
-
|
|
799
|
-
aaa_a_service.destroy
|
|
800
|
-
|
|
801
|
-
# Unconfigure tacacs, tacacs server and AAA valid group
|
|
802
|
-
preconfig_tacacs_server_access(group0, false)
|
|
803
648
|
end
|
|
804
649
|
|
|
805
|
-
def
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
preconfig_tacacs_server_access(group0)
|
|
809
|
-
|
|
810
|
-
# Preconfig for test
|
|
811
|
-
group1 = 'bxb100'
|
|
812
|
-
group2 = 'sjc200'
|
|
813
|
-
group3 = 'rtp10'
|
|
814
|
-
servers = [group1, group2, group3]
|
|
815
|
-
config_tacacs_servers(servers)
|
|
816
|
-
|
|
817
|
-
# Commands, service console
|
|
818
|
-
type_str = 'config-commands'
|
|
819
|
-
type = :config_commands
|
|
820
|
-
service = 'console'
|
|
821
|
-
aaa_a_service = AaaAuthorizationService.new(type, service)
|
|
822
|
-
|
|
823
|
-
# Single group, with method 'unselected'
|
|
824
|
-
method = :unselected
|
|
825
|
-
groups = [group0]
|
|
826
|
-
aaa_a_service.groups_method_set(groups, method)
|
|
650
|
+
def test_config_commands_console_unselected_single
|
|
651
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'console')
|
|
652
|
+
aaa_a_service.groups_method_set(tacacs_groups[0], :unselected)
|
|
827
653
|
|
|
828
|
-
p =
|
|
654
|
+
p = get_pattern(:config_commands, 'console', tacacs_groups[0])
|
|
829
655
|
assert_show_match(command: show_cmd, pattern: p)
|
|
656
|
+
end
|
|
830
657
|
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
aaa_a_service.groups_method_set(groups, method)
|
|
658
|
+
def test_config_commands_console_unselected_multi
|
|
659
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'console')
|
|
660
|
+
aaa_a_service.groups_method_set(tacacs_groups[0..2], :unselected)
|
|
835
661
|
|
|
836
|
-
p =
|
|
662
|
+
p = get_pattern(:config_commands, 'console', tacacs_groups[0..2])
|
|
837
663
|
assert_show_match(command: show_cmd, pattern: p)
|
|
664
|
+
end
|
|
838
665
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
aaa_a_service.groups_method_set(groups, method)
|
|
666
|
+
def test_config_commands_console_local_multi
|
|
667
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'console')
|
|
668
|
+
aaa_a_service.groups_method_set(tacacs_groups[0..2], :local)
|
|
843
669
|
|
|
844
|
-
|
|
845
|
-
p = /#{prefix} #{type_str} #{service} #{group_str} local/
|
|
670
|
+
p = get_pattern(:config_commands, 'console', tacacs_groups[0..2], :local)
|
|
846
671
|
assert_show_match(command: show_cmd, pattern: p)
|
|
672
|
+
end
|
|
847
673
|
|
|
848
|
-
|
|
674
|
+
def test_config_commands_console_all_default
|
|
675
|
+
aaa_a_service = AaaAuthorizationService.new(:config_commands, 'console')
|
|
849
676
|
method = aaa_a_service.default_method
|
|
850
677
|
groups = aaa_a_service.default_groups
|
|
851
678
|
aaa_a_service.groups_method_set(groups, method)
|
|
852
679
|
|
|
853
|
-
p =
|
|
680
|
+
p = get_pattern(:config_commands, 'console', groups, method)
|
|
854
681
|
assert_show_match(command: show_cmd, pattern: p)
|
|
855
|
-
|
|
856
|
-
aaa_a_service.destroy
|
|
857
|
-
|
|
858
|
-
# Unconfigure tacacs, tacacs server and AAA valid group
|
|
859
|
-
preconfig_tacacs_server_access(group0, false)
|
|
860
682
|
end
|
|
861
683
|
|
|
862
684
|
def test_commands_invalid_groups_method_set_groups
|
|
863
|
-
# preconfig servers
|
|
864
|
-
servers = %w(bxb100 sjc200 rtp10)
|
|
865
|
-
config_tacacs_servers(servers)
|
|
866
|
-
|
|
867
685
|
# Commands, with service default
|
|
868
686
|
type = :commands
|
|
869
687
|
service = 'default'
|
|
@@ -908,10 +726,6 @@ class TestAaaAuthorizationService < CiscoTestCase
|
|
|
908
726
|
end
|
|
909
727
|
|
|
910
728
|
def test_config_commands_invalid_set_groups
|
|
911
|
-
# preconfig servers
|
|
912
|
-
servers = %w(bxb100 sjc200 rtp10)
|
|
913
|
-
config_tacacs_servers(servers)
|
|
914
|
-
|
|
915
729
|
# Commands, with service default
|
|
916
730
|
type = :config_commands
|
|
917
731
|
service = 'default'
|
|
@@ -956,10 +770,6 @@ class TestAaaAuthorizationService < CiscoTestCase
|
|
|
956
770
|
end
|
|
957
771
|
|
|
958
772
|
def test_commands_invalid_method
|
|
959
|
-
# preconfig servers
|
|
960
|
-
servers = %w(bxb100 sjc200 rtp10)
|
|
961
|
-
config_tacacs_servers(servers)
|
|
962
|
-
|
|
963
773
|
# Commands, with service default
|
|
964
774
|
type = :commands
|
|
965
775
|
service = 'default'
|
|
@@ -998,10 +808,6 @@ class TestAaaAuthorizationService < CiscoTestCase
|
|
|
998
808
|
end
|
|
999
809
|
|
|
1000
810
|
def test_config_commands_invalid_method
|
|
1001
|
-
# preconfig servers
|
|
1002
|
-
servers = %w(bxb100 sjc200 rtp10)
|
|
1003
|
-
config_tacacs_servers(servers)
|
|
1004
|
-
|
|
1005
811
|
# Commands, with service default
|
|
1006
812
|
type = :config_commands
|
|
1007
813
|
service = 'default'
|