cisco_node_utils 1.3.0 → 1.4.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 +1 -0
- data/CHANGELOG.md +66 -0
- data/Gemfile +1 -0
- data/README.md +44 -43
- data/bin/.rubocop.yml +18 -0
- data/bin/show_running_yang.rb +233 -0
- data/cisco_node_utils.gemspec +1 -1
- data/docs/README-maintainers.md +1 -0
- data/docs/README-utilities.md +14 -0
- data/lib/.rubocop.yml +1 -1
- data/lib/cisco_node_utils/aaa_authentication_login_service.rb +8 -3
- data/lib/cisco_node_utils/aaa_authorization_service.rb +6 -0
- data/lib/cisco_node_utils/bfd_global.rb +300 -0
- data/lib/cisco_node_utils/bgp.rb +6 -4
- data/lib/cisco_node_utils/bgp_af.rb +2 -0
- data/lib/cisco_node_utils/bgp_neighbor.rb +14 -0
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +4 -1
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +126 -0
- data/lib/cisco_node_utils/client/client.rb +6 -2
- data/lib/cisco_node_utils/client/grpc/client.rb +120 -36
- data/lib/cisco_node_utils/client/nxapi/client.rb +6 -2
- data/lib/cisco_node_utils/cmd_ref/DEPRECATED.yaml +118 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +14 -0
- data/lib/cisco_node_utils/cmd_ref/bfd_global.yaml +117 -0
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +7 -7
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/dhcp_relay_global.yaml +125 -0
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +10 -0
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +141 -49
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +44 -0
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +6 -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 +0 -3
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +3 -3
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +39 -15
- data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +43 -21
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +48 -19
- data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +0 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_global.yaml +30 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +18 -6
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +4 -0
- data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +1 -0
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +23 -10
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +8 -2
- data/lib/cisco_node_utils/cmd_ref/yang.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +10 -1
- data/lib/cisco_node_utils/constants.rb +8 -1
- data/lib/cisco_node_utils/dhcp_relay_global.rb +302 -0
- data/lib/cisco_node_utils/exceptions.rb +29 -0
- data/lib/cisco_node_utils/feature.rb +28 -0
- data/lib/cisco_node_utils/interface.rb +493 -402
- data/lib/cisco_node_utils/interface_DEPRECATED.rb +513 -0
- data/lib/cisco_node_utils/interface_ospf.rb +126 -0
- data/lib/cisco_node_utils/interface_portchannel.rb +16 -0
- data/lib/cisco_node_utils/logger.rb +3 -0
- data/lib/cisco_node_utils/node.rb +29 -1
- data/lib/cisco_node_utils/overlay_global.rb +1 -12
- data/lib/cisco_node_utils/pim.rb +1 -0
- data/lib/cisco_node_utils/pim_group_list.rb +1 -0
- data/lib/cisco_node_utils/pim_rp_address.rb +1 -0
- data/lib/cisco_node_utils/platform.rb +9 -2
- data/lib/cisco_node_utils/router_ospf.rb +1 -1
- 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 +17 -0
- data/lib/cisco_node_utils/snmp_notification_receiver.rb +27 -9
- data/lib/cisco_node_utils/snmpcommunity.rb +34 -8
- data/lib/cisco_node_utils/snmpserver.rb +4 -4
- data/lib/cisco_node_utils/snmpuser.rb +0 -0
- data/lib/cisco_node_utils/tacacs_global.rb +102 -0
- data/lib/cisco_node_utils/tacacs_server.rb +8 -7
- data/lib/cisco_node_utils/vdc.rb +25 -7
- data/lib/cisco_node_utils/version.rb +1 -1
- data/lib/cisco_node_utils/vlan.rb +30 -56
- data/lib/cisco_node_utils/vlan_DEPRECATED.rb +108 -0
- data/lib/cisco_node_utils/yang.rb +160 -0
- data/lib/cisco_node_utils/yum.rb +25 -32
- data/tests/.rubocop.yml +3 -0
- data/tests/ciscotest.rb +136 -19
- data/tests/cmd_config_invalid.yaml +1 -1
- data/tests/noop.rb +7 -0
- data/tests/tacacs_server.yaml.example +6 -0
- data/tests/test_aaa_authentication_login.rb +24 -1
- data/tests/test_aaa_authentication_login_service.rb +9 -16
- data/tests/test_aaa_authorization_service.rb +111 -84
- data/tests/test_bfd_global.rb +278 -0
- data/tests/test_bgp_neighbor.rb +20 -0
- data/tests/test_bridge_domain_vni.rb +2 -9
- data/tests/test_cmn_utils.rb +76 -0
- data/tests/test_dhcp_relay_global.rb +284 -0
- data/tests/test_dns_domain.rb +4 -4
- data/tests/test_domain_name.rb +2 -2
- data/tests/test_encapsulation.rb +2 -4
- data/tests/test_evpn_vni.rb +14 -7
- data/tests/test_fabricpath_global.rb +12 -13
- data/tests/test_feature.rb +35 -17
- data/tests/test_interface.rb +352 -127
- data/tests/test_interface_bdi.rb +2 -2
- data/tests/test_interface_channel_group.rb +1 -1
- data/tests/test_interface_ospf.rb +153 -23
- data/tests/test_interface_portchannel.rb +15 -6
- data/tests/test_interface_private_vlan.rb +200 -576
- data/tests/test_interface_svi.rb +5 -52
- data/tests/test_interface_switchport.rb +80 -240
- data/tests/test_itd_device_group.rb +2 -2
- data/tests/test_itd_device_group_node.rb +2 -2
- data/tests/test_itd_service.rb +1 -1
- data/tests/test_name_server.rb +3 -3
- data/tests/test_node_ext.rb +15 -17
- data/tests/test_ntp_config.rb +1 -1
- data/tests/test_ntp_server.rb +3 -3
- data/tests/test_nxapi.rb +1 -0
- data/tests/test_overlay_global.rb +15 -19
- data/tests/test_pim.rb +5 -5
- data/tests/test_pim_group_list.rb +1 -37
- data/tests/test_pim_rp_address.rb +1 -1
- data/tests/test_platform.rb +9 -11
- data/tests/test_portchannel_global.rb +43 -3
- data/tests/test_radius_server.rb +1 -1
- data/tests/test_radius_server_group.rb +1 -1
- data/tests/test_router_bgp.rb +17 -30
- 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 +17 -0
- data/tests/test_snmp_notification_receiver.rb +11 -11
- data/tests/test_snmpcommunity.rb +177 -69
- data/tests/test_snmpgroup.rb +7 -7
- data/tests/test_snmpserver.rb +164 -253
- data/tests/test_snmpuser.rb +73 -69
- data/tests/test_stp_global.rb +15 -15
- data/tests/test_syslog_settings.rb +1 -1
- data/tests/test_tacacs_global.rb +80 -0
- data/tests/test_tacacs_server.rb +129 -51
- data/tests/test_tacacs_server_group.rb +3 -29
- data/tests/test_tacacs_server_host.rb +24 -27
- data/tests/test_vlan.rb +57 -59
- data/tests/test_vlan_private.rb +271 -284
- data/tests/test_vpc.rb +10 -4
- data/tests/test_vrf.rb +2 -0
- data/tests/test_vrf_af.rb +2 -5
- data/tests/test_vtp.rb +5 -2
- data/tests/test_vxlan_vtep.rb +20 -44
- data/tests/test_vxlan_vtep_vni.rb +23 -16
- data/tests/test_yang.rb +369 -0
- data/tests/test_yum.rb +34 -42
- data/tests/yum_package.yaml +35 -0
- metadata +31 -4
- data/tests/test_vlan_mt_full.rb +0 -85
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
# Copyright (c) 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/router_ospf'
|
|
17
|
+
require_relative '../lib/cisco_node_utils/router_ospf_vrf'
|
|
18
|
+
require_relative '../lib/cisco_node_utils/router_ospf_area_vlink'
|
|
19
|
+
|
|
20
|
+
# TestRouterOspfAreaVirtualLink - Minitest for RouterOspfAreaVirtualLink
|
|
21
|
+
# node utility class
|
|
22
|
+
class TestRouterOspfAreaVirtualLink < CiscoTestCase
|
|
23
|
+
@skip_unless_supported = 'ospf_area_vlink'
|
|
24
|
+
@@pre_clean_needed = true # rubocop:disable Style/ClassVars
|
|
25
|
+
|
|
26
|
+
def setup
|
|
27
|
+
super
|
|
28
|
+
remove_all_ospfs if @@pre_clean_needed
|
|
29
|
+
@@pre_clean_needed = false # rubocop:disable Style/ClassVars
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def teardown
|
|
33
|
+
remove_all_ospfs
|
|
34
|
+
super
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def create_routerospfarea_default_virtual_link(router='Wolfpack',
|
|
38
|
+
name='default',
|
|
39
|
+
area_id='1.1.1.1',
|
|
40
|
+
vl='2.2.2.2')
|
|
41
|
+
RouterOspfAreaVirtualLink.new(router, name, area_id, vl)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def create_routerospfarea_vrf_virtual_link(router='Wolfpack',
|
|
45
|
+
name='blue',
|
|
46
|
+
area_id='1450',
|
|
47
|
+
vl='3.3.3.3')
|
|
48
|
+
RouterOspfAreaVirtualLink.new(router, name, area_id, vl)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_collection_size
|
|
52
|
+
dvl1 = create_routerospfarea_default_virtual_link
|
|
53
|
+
assert_equal(1, RouterOspfAreaVirtualLink.virtual_links['Wolfpack']['default']['1.1.1.1'].size)
|
|
54
|
+
dvl2 = create_routerospfarea_default_virtual_link('Wolfpack', 'default', '1.1.1.1', '5.5.5.5')
|
|
55
|
+
assert_equal(2, RouterOspfAreaVirtualLink.virtual_links['Wolfpack']['default']['1.1.1.1'].size)
|
|
56
|
+
dvl3 = create_routerospfarea_default_virtual_link('Wolfpack', 'default', '6.6.6.6', '5.5.5.5')
|
|
57
|
+
assert_equal(1, RouterOspfAreaVirtualLink.virtual_links['Wolfpack']['default']['6.6.6.6'].size)
|
|
58
|
+
vvl1 = create_routerospfarea_vrf_virtual_link
|
|
59
|
+
assert_equal(1, RouterOspfAreaVirtualLink.virtual_links['Wolfpack']['blue']['0.0.5.170'].size)
|
|
60
|
+
vvl2 = create_routerospfarea_vrf_virtual_link('Wolfpack', 'blue', '1000', '5.5.5.5')
|
|
61
|
+
assert_equal(1, RouterOspfAreaVirtualLink.virtual_links['Wolfpack']['blue']['0.0.3.232'].size)
|
|
62
|
+
vvl3 = create_routerospfarea_vrf_virtual_link('Wolfpack', 'red', '1000', '5.5.5.5')
|
|
63
|
+
assert_equal(1, RouterOspfAreaVirtualLink.virtual_links['Wolfpack']['red']['0.0.3.232'].size)
|
|
64
|
+
vvl4 = create_routerospfarea_vrf_virtual_link('Wolfpack', 'red', '2000', '5.5.5.5')
|
|
65
|
+
assert_equal(1, RouterOspfAreaVirtualLink.virtual_links['Wolfpack']['red']['0.0.7.208'].size)
|
|
66
|
+
vvl5 = create_routerospfarea_vrf_virtual_link('Wolfpack', 'red', '2000', '2.2.2.2')
|
|
67
|
+
assert_equal(2, RouterOspfAreaVirtualLink.virtual_links['Wolfpack']['red']['0.0.7.208'].size)
|
|
68
|
+
dvl1.destroy
|
|
69
|
+
dvl2.destroy
|
|
70
|
+
dvl3.destroy
|
|
71
|
+
vvl1.destroy
|
|
72
|
+
vvl2.destroy
|
|
73
|
+
vvl3.destroy
|
|
74
|
+
vvl4.destroy
|
|
75
|
+
vvl5.destroy
|
|
76
|
+
assert_empty(RouterOspfAreaVirtualLink.virtual_links)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_dead_interval
|
|
80
|
+
dvl = create_routerospfarea_default_virtual_link
|
|
81
|
+
assert_equal(dvl.default_dead_interval, dvl.dead_interval)
|
|
82
|
+
dvl.dead_interval = 500
|
|
83
|
+
assert_equal(500, dvl.dead_interval)
|
|
84
|
+
dvl.dead_interval = dvl.default_dead_interval
|
|
85
|
+
assert_equal(dvl.default_dead_interval, dvl.dead_interval)
|
|
86
|
+
vvl = create_routerospfarea_vrf_virtual_link
|
|
87
|
+
assert_equal(vvl.default_dead_interval, vvl.dead_interval)
|
|
88
|
+
vvl.dead_interval = 1000
|
|
89
|
+
assert_equal(1000, vvl.dead_interval)
|
|
90
|
+
vvl.dead_interval = vvl.default_dead_interval
|
|
91
|
+
assert_equal(vvl.default_dead_interval, vvl.dead_interval)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def test_hello_interval
|
|
95
|
+
dvl = create_routerospfarea_default_virtual_link
|
|
96
|
+
assert_equal(dvl.default_hello_interval, dvl.hello_interval)
|
|
97
|
+
dvl.hello_interval = 1500
|
|
98
|
+
assert_equal(1500, dvl.hello_interval)
|
|
99
|
+
dvl.hello_interval = dvl.default_hello_interval
|
|
100
|
+
assert_equal(dvl.default_hello_interval, dvl.hello_interval)
|
|
101
|
+
vvl = create_routerospfarea_vrf_virtual_link
|
|
102
|
+
assert_equal(vvl.default_hello_interval, vvl.hello_interval)
|
|
103
|
+
vvl.hello_interval = 2000
|
|
104
|
+
assert_equal(2000, vvl.hello_interval)
|
|
105
|
+
vvl.hello_interval = vvl.default_hello_interval
|
|
106
|
+
assert_equal(vvl.default_hello_interval, vvl.hello_interval)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def test_retransmit_interval
|
|
110
|
+
dvl = create_routerospfarea_default_virtual_link
|
|
111
|
+
assert_equal(dvl.default_retransmit_interval, dvl.retransmit_interval)
|
|
112
|
+
dvl.retransmit_interval = 200
|
|
113
|
+
assert_equal(200, dvl.retransmit_interval)
|
|
114
|
+
dvl.retransmit_interval = dvl.default_retransmit_interval
|
|
115
|
+
assert_equal(dvl.default_retransmit_interval, dvl.retransmit_interval)
|
|
116
|
+
vvl = create_routerospfarea_vrf_virtual_link
|
|
117
|
+
assert_equal(vvl.default_retransmit_interval, vvl.retransmit_interval)
|
|
118
|
+
vvl.retransmit_interval = 10_000
|
|
119
|
+
assert_equal(10_000, vvl.retransmit_interval)
|
|
120
|
+
vvl.retransmit_interval = vvl.default_retransmit_interval
|
|
121
|
+
assert_equal(vvl.default_retransmit_interval, vvl.retransmit_interval)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def test_transmit_delay
|
|
125
|
+
dvl = create_routerospfarea_default_virtual_link
|
|
126
|
+
assert_equal(dvl.default_transmit_delay, dvl.transmit_delay)
|
|
127
|
+
dvl.transmit_delay = 250
|
|
128
|
+
assert_equal(250, dvl.transmit_delay)
|
|
129
|
+
dvl.transmit_delay = dvl.default_transmit_delay
|
|
130
|
+
assert_equal(dvl.default_transmit_delay, dvl.transmit_delay)
|
|
131
|
+
vvl = create_routerospfarea_vrf_virtual_link
|
|
132
|
+
assert_equal(vvl.default_transmit_delay, vvl.transmit_delay)
|
|
133
|
+
vvl.transmit_delay = 400
|
|
134
|
+
assert_equal(400, vvl.transmit_delay)
|
|
135
|
+
vvl.transmit_delay = vvl.default_transmit_delay
|
|
136
|
+
assert_equal(vvl.default_transmit_delay, vvl.transmit_delay)
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def test_auth_key_chain
|
|
140
|
+
dvl = create_routerospfarea_default_virtual_link
|
|
141
|
+
assert_equal(dvl.default_auth_key_chain, dvl.auth_key_chain)
|
|
142
|
+
dvl.auth_key_chain = 'testing123'
|
|
143
|
+
assert_equal('testing123', dvl.auth_key_chain)
|
|
144
|
+
dvl.auth_key_chain = dvl.default_auth_key_chain
|
|
145
|
+
assert_equal(dvl.default_auth_key_chain, dvl.auth_key_chain)
|
|
146
|
+
vvl = create_routerospfarea_vrf_virtual_link
|
|
147
|
+
assert_equal(vvl.default_auth_key_chain, vvl.auth_key_chain)
|
|
148
|
+
vvl.auth_key_chain = 'awesome'
|
|
149
|
+
assert_equal('awesome', vvl.auth_key_chain)
|
|
150
|
+
vvl.auth_key_chain = vvl.default_auth_key_chain
|
|
151
|
+
assert_equal(vvl.default_auth_key_chain, vvl.auth_key_chain)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def test_authentication
|
|
155
|
+
dvl = create_routerospfarea_default_virtual_link
|
|
156
|
+
assert_equal(dvl.default_authentication, dvl.authentication)
|
|
157
|
+
dvl.authentication = 'md5'
|
|
158
|
+
assert_equal('md5', dvl.authentication)
|
|
159
|
+
dvl.authentication = 'cleartext'
|
|
160
|
+
assert_equal('cleartext', dvl.authentication)
|
|
161
|
+
dvl.authentication = 'null'
|
|
162
|
+
assert_equal('null', dvl.authentication)
|
|
163
|
+
dvl.authentication = dvl.default_authentication
|
|
164
|
+
assert_equal(dvl.default_authentication, dvl.authentication)
|
|
165
|
+
vvl = create_routerospfarea_vrf_virtual_link
|
|
166
|
+
assert_equal(vvl.default_authentication, vvl.authentication)
|
|
167
|
+
vvl.authentication = 'md5'
|
|
168
|
+
assert_equal('md5', vvl.authentication)
|
|
169
|
+
vvl.authentication = 'cleartext'
|
|
170
|
+
assert_equal('cleartext', vvl.authentication)
|
|
171
|
+
vvl.authentication = 'null'
|
|
172
|
+
assert_equal('null', vvl.authentication)
|
|
173
|
+
vvl.authentication = vvl.default_authentication
|
|
174
|
+
assert_equal(vvl.default_authentication, vvl.authentication)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def test_authentication_key
|
|
178
|
+
dvl = create_routerospfarea_default_virtual_link
|
|
179
|
+
assert_equal(dvl.default_authentication_key_encryption_type,
|
|
180
|
+
dvl.authentication_key_encryption_type)
|
|
181
|
+
assert_equal(dvl.default_authentication_key_password,
|
|
182
|
+
dvl.authentication_key_password)
|
|
183
|
+
encr = :"3des"
|
|
184
|
+
encr_pw = '762bc328e3bdf235'
|
|
185
|
+
dvl.authentication_key_set(encr, encr_pw)
|
|
186
|
+
assert_equal(encr, dvl.authentication_key_encryption_type)
|
|
187
|
+
assert_equal(encr_pw, dvl.authentication_key_password)
|
|
188
|
+
encr = :cisco_type_7
|
|
189
|
+
encr_pw = '12345678901234567890'
|
|
190
|
+
dvl.authentication_key_set(encr, encr_pw)
|
|
191
|
+
assert_equal(encr, dvl.authentication_key_encryption_type)
|
|
192
|
+
assert_equal(encr_pw, dvl.authentication_key_password)
|
|
193
|
+
dvl.authentication_key_set(dvl.default_authentication_key_encryption_type,
|
|
194
|
+
dvl.default_authentication_key_password)
|
|
195
|
+
assert_equal(dvl.default_authentication_key_encryption_type,
|
|
196
|
+
dvl.authentication_key_encryption_type)
|
|
197
|
+
assert_equal(dvl.default_authentication_key_password,
|
|
198
|
+
dvl.authentication_key_password)
|
|
199
|
+
vvl = create_routerospfarea_vrf_virtual_link
|
|
200
|
+
assert_equal(vvl.default_authentication_key_encryption_type,
|
|
201
|
+
vvl.authentication_key_encryption_type)
|
|
202
|
+
assert_equal(vvl.default_authentication_key_password,
|
|
203
|
+
vvl.authentication_key_password)
|
|
204
|
+
encr = :"3des"
|
|
205
|
+
encr_pw = '1347c56888deb142'
|
|
206
|
+
vvl.authentication_key_set(encr, encr_pw)
|
|
207
|
+
assert_equal(encr, vvl.authentication_key_encryption_type)
|
|
208
|
+
assert_equal(encr_pw, vvl.authentication_key_password)
|
|
209
|
+
encr = :cisco_type_7
|
|
210
|
+
encr_pw = '046E1803362E595C260E0B240619050A2D'
|
|
211
|
+
vvl.authentication_key_set(encr, encr_pw)
|
|
212
|
+
assert_equal(encr, vvl.authentication_key_encryption_type)
|
|
213
|
+
assert_equal(encr_pw, vvl.authentication_key_password)
|
|
214
|
+
vvl.authentication_key_set(vvl.default_authentication_key_encryption_type,
|
|
215
|
+
vvl.default_authentication_key_password)
|
|
216
|
+
assert_equal(vvl.default_authentication_key_encryption_type,
|
|
217
|
+
vvl.authentication_key_encryption_type)
|
|
218
|
+
assert_equal(vvl.default_authentication_key_password,
|
|
219
|
+
vvl.authentication_key_password)
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def test_message_digest_key
|
|
223
|
+
dvl = create_routerospfarea_default_virtual_link
|
|
224
|
+
assert_equal(dvl.default_message_digest_algorithm_type,
|
|
225
|
+
dvl.message_digest_algorithm_type)
|
|
226
|
+
assert_equal(dvl.default_message_digest_encryption_type,
|
|
227
|
+
dvl.message_digest_encryption_type)
|
|
228
|
+
assert_equal(dvl.default_message_digest_key_id,
|
|
229
|
+
dvl.message_digest_key_id)
|
|
230
|
+
assert_equal(dvl.default_message_digest_password,
|
|
231
|
+
dvl.message_digest_password)
|
|
232
|
+
key = 45
|
|
233
|
+
alg = :md5
|
|
234
|
+
encr = :"3des"
|
|
235
|
+
encr_pw = '1347c56888deb142'
|
|
236
|
+
dvl.message_digest_key_set(key, alg, encr, encr_pw)
|
|
237
|
+
assert_equal(key, dvl.message_digest_key_id)
|
|
238
|
+
assert_equal(alg, dvl.message_digest_algorithm_type)
|
|
239
|
+
assert_equal(encr, dvl.message_digest_encryption_type)
|
|
240
|
+
assert_equal(encr_pw, dvl.message_digest_password)
|
|
241
|
+
key = 200
|
|
242
|
+
encr = :cisco_type_7
|
|
243
|
+
encr_pw = '046E1803362E595C260E0B240619050A2D'
|
|
244
|
+
dvl.message_digest_key_set(key, alg, encr, encr_pw)
|
|
245
|
+
assert_equal(key, dvl.message_digest_key_id)
|
|
246
|
+
assert_equal(alg, dvl.message_digest_algorithm_type)
|
|
247
|
+
assert_equal(encr, dvl.message_digest_encryption_type)
|
|
248
|
+
assert_equal(encr_pw, dvl.message_digest_password)
|
|
249
|
+
dvl.message_digest_key_set(dvl.message_digest_key_id,
|
|
250
|
+
dvl.default_message_digest_algorithm_type,
|
|
251
|
+
dvl.default_message_digest_encryption_type,
|
|
252
|
+
dvl.default_message_digest_password)
|
|
253
|
+
assert_equal(dvl.default_message_digest_algorithm_type,
|
|
254
|
+
dvl.message_digest_algorithm_type)
|
|
255
|
+
assert_equal(dvl.default_message_digest_encryption_type,
|
|
256
|
+
dvl.message_digest_encryption_type)
|
|
257
|
+
assert_equal(dvl.default_message_digest_key_id,
|
|
258
|
+
dvl.message_digest_key_id)
|
|
259
|
+
assert_equal(dvl.default_message_digest_password,
|
|
260
|
+
dvl.message_digest_password)
|
|
261
|
+
vvl = create_routerospfarea_vrf_virtual_link
|
|
262
|
+
assert_equal(vvl.default_message_digest_algorithm_type,
|
|
263
|
+
vvl.message_digest_algorithm_type)
|
|
264
|
+
assert_equal(vvl.default_message_digest_encryption_type,
|
|
265
|
+
vvl.message_digest_encryption_type)
|
|
266
|
+
assert_equal(vvl.default_message_digest_key_id,
|
|
267
|
+
vvl.message_digest_key_id)
|
|
268
|
+
assert_equal(vvl.default_message_digest_password,
|
|
269
|
+
vvl.message_digest_password)
|
|
270
|
+
key = 82
|
|
271
|
+
encr = :"3des"
|
|
272
|
+
encr_pw = '762bc328e3bdf235'
|
|
273
|
+
vvl.message_digest_key_set(key, alg, encr, encr_pw)
|
|
274
|
+
assert_equal(key, vvl.message_digest_key_id)
|
|
275
|
+
assert_equal(alg, vvl.message_digest_algorithm_type)
|
|
276
|
+
assert_equal(encr, vvl.message_digest_encryption_type)
|
|
277
|
+
assert_equal(encr_pw, vvl.message_digest_password)
|
|
278
|
+
key = 5
|
|
279
|
+
encr = :cisco_type_7
|
|
280
|
+
encr_pw = '12345678901234567890'
|
|
281
|
+
vvl.message_digest_key_set(key, alg, encr, encr_pw)
|
|
282
|
+
assert_equal(key, vvl.message_digest_key_id)
|
|
283
|
+
assert_equal(alg, vvl.message_digest_algorithm_type)
|
|
284
|
+
assert_equal(encr, vvl.message_digest_encryption_type)
|
|
285
|
+
assert_equal(encr_pw, vvl.message_digest_password)
|
|
286
|
+
vvl.message_digest_key_set(key, vvl.default_message_digest_algorithm_type,
|
|
287
|
+
vvl.default_message_digest_encryption_type,
|
|
288
|
+
vvl.default_message_digest_password)
|
|
289
|
+
assert_equal(vvl.default_message_digest_algorithm_type,
|
|
290
|
+
vvl.message_digest_algorithm_type)
|
|
291
|
+
assert_equal(vvl.default_message_digest_encryption_type,
|
|
292
|
+
vvl.message_digest_encryption_type)
|
|
293
|
+
assert_equal(vvl.default_message_digest_key_id,
|
|
294
|
+
vvl.message_digest_key_id)
|
|
295
|
+
assert_equal(vvl.default_message_digest_password,
|
|
296
|
+
vvl.message_digest_password)
|
|
297
|
+
end
|
|
298
|
+
end
|
|
@@ -274,6 +274,23 @@ class TestRouterOspfVrf < CiscoTestCase
|
|
|
274
274
|
vrf.parent.destroy
|
|
275
275
|
end
|
|
276
276
|
|
|
277
|
+
def test_bfd
|
|
278
|
+
routerospf = create_routerospf
|
|
279
|
+
vrf = create_routerospfvrf(routerospf.name)
|
|
280
|
+
vrf1 = create_routerospfvrf(routerospf.name, 'testvrf')
|
|
281
|
+
assert_equal(vrf.default_bfd, vrf.bfd)
|
|
282
|
+
assert_equal(vrf1.default_bfd, vrf1.bfd)
|
|
283
|
+
vrf.bfd = true
|
|
284
|
+
vrf1.bfd = true
|
|
285
|
+
assert_equal(true, vrf.bfd)
|
|
286
|
+
assert_equal(true, vrf1.bfd)
|
|
287
|
+
vrf.bfd = vrf.default_bfd
|
|
288
|
+
vrf1.bfd = vrf1.default_bfd
|
|
289
|
+
assert_equal(vrf.default_bfd, vrf.bfd)
|
|
290
|
+
assert_equal(vrf1.default_bfd, vrf1.bfd)
|
|
291
|
+
routerospf.destroy
|
|
292
|
+
end
|
|
293
|
+
|
|
277
294
|
def test_default_metric
|
|
278
295
|
vrf = create_routerospfvrf
|
|
279
296
|
metric = 30_000
|
|
@@ -20,20 +20,20 @@ require_relative '../lib/cisco_node_utils/snmp_notification_receiver'
|
|
|
20
20
|
|
|
21
21
|
# TestSnmpNotificationReceiver - Minitest for SnmpNotificationReceiver
|
|
22
22
|
# node utility.
|
|
23
|
-
class
|
|
23
|
+
class TestSnmpNotifRcvr < CiscoTestCase
|
|
24
24
|
@skip_unless_supported = 'snmp_notification_receiver'
|
|
25
25
|
|
|
26
26
|
def setup
|
|
27
27
|
# setup runs at the beginning of each test
|
|
28
28
|
super
|
|
29
29
|
no_snmpnotificationreceiver
|
|
30
|
-
config('vrf context red')
|
|
30
|
+
config('vrf context red') if platform == :nexus
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def teardown
|
|
34
34
|
# teardown runs at the end of each test
|
|
35
35
|
no_snmpnotificationreceiver
|
|
36
|
-
config('no vrf context red')
|
|
36
|
+
config('no vrf context red') if platform == :nexus
|
|
37
37
|
super
|
|
38
38
|
end
|
|
39
39
|
|
|
@@ -58,13 +58,13 @@ class TestSnmpNotificationReceiver < CiscoTestCase
|
|
|
58
58
|
username: 'ab',
|
|
59
59
|
port: '45',
|
|
60
60
|
vrf: 'red',
|
|
61
|
-
source_interface: interfaces[0].downcase)
|
|
61
|
+
source_interface: interfaces[0].downcase)
|
|
62
62
|
|
|
63
63
|
assert_includes(Cisco::SnmpNotificationReceiver.receivers, id)
|
|
64
64
|
assert_equal(receiver, Cisco::SnmpNotificationReceiver.receivers[id])
|
|
65
65
|
|
|
66
66
|
assert_equal(interfaces[0].downcase,
|
|
67
|
-
Cisco::SnmpNotificationReceiver.receivers[id].source_interface)
|
|
67
|
+
Cisco::SnmpNotificationReceiver.receivers[id].source_interface)
|
|
68
68
|
assert_equal('45', Cisco::SnmpNotificationReceiver.receivers[id].port)
|
|
69
69
|
assert_equal('informs', Cisco::SnmpNotificationReceiver.receivers[id].type)
|
|
70
70
|
assert_equal('ab', Cisco::SnmpNotificationReceiver.receivers[id].username)
|
|
@@ -89,13 +89,13 @@ class TestSnmpNotificationReceiver < CiscoTestCase
|
|
|
89
89
|
username: 'ab',
|
|
90
90
|
port: '45',
|
|
91
91
|
vrf: 'red',
|
|
92
|
-
source_interface: interfaces[0].downcase)
|
|
92
|
+
source_interface: interfaces[0].downcase)
|
|
93
93
|
|
|
94
94
|
assert_includes(Cisco::SnmpNotificationReceiver.receivers, id)
|
|
95
95
|
assert_equal(receiver, Cisco::SnmpNotificationReceiver.receivers[id])
|
|
96
96
|
|
|
97
97
|
assert_equal(interfaces[0].downcase,
|
|
98
|
-
Cisco::SnmpNotificationReceiver.receivers[id].source_interface)
|
|
98
|
+
Cisco::SnmpNotificationReceiver.receivers[id].source_interface)
|
|
99
99
|
assert_equal('45', Cisco::SnmpNotificationReceiver.receivers[id].port)
|
|
100
100
|
assert_equal('informs', Cisco::SnmpNotificationReceiver.receivers[id].type)
|
|
101
101
|
assert_equal('ab', Cisco::SnmpNotificationReceiver.receivers[id].username)
|
|
@@ -123,7 +123,7 @@ class TestSnmpNotificationReceiver < CiscoTestCase
|
|
|
123
123
|
username: 'ab',
|
|
124
124
|
port: '45',
|
|
125
125
|
vrf: 'red',
|
|
126
|
-
source_interface: interfaces[0].downcase)
|
|
126
|
+
source_interface: interfaces[0].downcase)
|
|
127
127
|
|
|
128
128
|
receiver2 = \
|
|
129
129
|
Cisco::SnmpNotificationReceiver.new(id2,
|
|
@@ -134,13 +134,13 @@ class TestSnmpNotificationReceiver < CiscoTestCase
|
|
|
134
134
|
username: 'cd',
|
|
135
135
|
port: '46',
|
|
136
136
|
vrf: 'red',
|
|
137
|
-
source_interface: interfaces[1].downcase)
|
|
137
|
+
source_interface: interfaces[1].downcase)
|
|
138
138
|
|
|
139
139
|
assert_includes(Cisco::SnmpNotificationReceiver.receivers, id)
|
|
140
140
|
assert_equal(receiver, Cisco::SnmpNotificationReceiver.receivers[id])
|
|
141
141
|
|
|
142
142
|
assert_equal(interfaces[0].downcase,
|
|
143
|
-
Cisco::SnmpNotificationReceiver.receivers[id].source_interface)
|
|
143
|
+
Cisco::SnmpNotificationReceiver.receivers[id].source_interface) if platform == :nexus
|
|
144
144
|
assert_equal('45', Cisco::SnmpNotificationReceiver.receivers[id].port)
|
|
145
145
|
assert_equal('informs', Cisco::SnmpNotificationReceiver.receivers[id].type)
|
|
146
146
|
assert_equal('ab', Cisco::SnmpNotificationReceiver.receivers[id].username)
|
|
@@ -152,7 +152,7 @@ class TestSnmpNotificationReceiver < CiscoTestCase
|
|
|
152
152
|
assert_equal(receiver2, Cisco::SnmpNotificationReceiver.receivers[id2])
|
|
153
153
|
|
|
154
154
|
assert_equal(interfaces[1].downcase,
|
|
155
|
-
Cisco::SnmpNotificationReceiver.receivers[id2].source_interface)
|
|
155
|
+
Cisco::SnmpNotificationReceiver.receivers[id2].source_interface)
|
|
156
156
|
assert_equal('46', Cisco::SnmpNotificationReceiver.receivers[id2].port)
|
|
157
157
|
assert_equal('traps', Cisco::SnmpNotificationReceiver.receivers[id2].type)
|
|
158
158
|
assert_equal('cd', Cisco::SnmpNotificationReceiver.receivers[id2].username)
|
data/tests/test_snmpcommunity.rb
CHANGED
|
@@ -34,116 +34,156 @@ class TestSnmpCommunity < CiscoTestCase
|
|
|
34
34
|
|
|
35
35
|
def setup
|
|
36
36
|
super
|
|
37
|
-
|
|
37
|
+
if platform != :ios_xr
|
|
38
|
+
@default_show_command = 'show run snmp all | no-more'
|
|
39
|
+
else
|
|
40
|
+
@default_show_command = 'show running-config snmp'
|
|
41
|
+
end
|
|
38
42
|
end
|
|
39
43
|
|
|
40
|
-
def
|
|
44
|
+
def test_collection_empty
|
|
41
45
|
# This test requires all the snmp communities removed from device
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
pattern = /#{cmd_prefix}\s\S+\sgroup\s\S+/
|
|
46
|
-
until (md = pattern.match(s)).nil?
|
|
47
|
-
# puts "md : #{md}"
|
|
48
|
-
config("no #{md}")
|
|
49
|
-
s = md.post_match
|
|
50
|
-
end
|
|
46
|
+
original_list = SnmpCommunity.communities
|
|
47
|
+
cleanup_snmp_communities(original_list)
|
|
48
|
+
|
|
51
49
|
snmpcommunities = SnmpCommunity.communities
|
|
52
50
|
assert_equal(true, snmpcommunities.empty?,
|
|
53
51
|
'SnmpCommunity collection is not empty')
|
|
54
52
|
end
|
|
55
53
|
|
|
56
|
-
def
|
|
54
|
+
def test_collection_not_empty
|
|
55
|
+
snmpcommunities = SnmpCommunity.communities
|
|
56
|
+
cleanup_snmp_communities(snmpcommunities)
|
|
57
|
+
|
|
57
58
|
# This test require some snmp community exist in device
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
if platform != :ios_xr
|
|
60
|
+
config('snmp-server community com1 group network-admin',
|
|
61
|
+
'snmp-server community com2')
|
|
62
|
+
else
|
|
63
|
+
config('snmp-server community com1',
|
|
64
|
+
'snmp-server community com2')
|
|
65
|
+
end
|
|
60
66
|
snmpcommunities = SnmpCommunity.communities
|
|
67
|
+
|
|
61
68
|
assert_equal(false, snmpcommunities.empty?,
|
|
62
69
|
'SnmpCommunity collection is empty')
|
|
63
70
|
cleanup_snmp_communities(snmpcommunities)
|
|
64
71
|
end
|
|
65
72
|
|
|
66
|
-
def
|
|
73
|
+
def test_collection_valid
|
|
67
74
|
# This test require some snmp community exist in device
|
|
68
|
-
|
|
69
|
-
|
|
75
|
+
if platform != :ios_xr
|
|
76
|
+
config('snmp-server community com12 group network-operator',
|
|
77
|
+
'snmp-server community com22 group network-admin')
|
|
78
|
+
else
|
|
79
|
+
config('snmp-server community com12',
|
|
80
|
+
'snmp-server community com22')
|
|
81
|
+
end
|
|
70
82
|
# get collection
|
|
83
|
+
|
|
71
84
|
snmpcommunities = SnmpCommunity.communities
|
|
72
|
-
|
|
85
|
+
if platform != :ios_xr
|
|
86
|
+
s = @device.cmd('show run snmp all | no-more')
|
|
87
|
+
else
|
|
88
|
+
s = @device.cmd('show running-config snmp')
|
|
89
|
+
end
|
|
73
90
|
cmd = 'snmp-server community'
|
|
74
|
-
snmpcommunities.each do |name,
|
|
75
|
-
line = /#{cmd}\s#{name}\
|
|
91
|
+
snmpcommunities.each do |name, _snmpcommunity|
|
|
92
|
+
line = /#{cmd}\s#{name}\s.*/.match(s)
|
|
76
93
|
# puts "line: #{line}"
|
|
77
94
|
assert_equal(false, line.nil?)
|
|
78
95
|
end
|
|
79
96
|
cleanup_snmp_communities(snmpcommunities)
|
|
80
97
|
end
|
|
81
98
|
|
|
82
|
-
def
|
|
99
|
+
def test_create_name_nil
|
|
83
100
|
assert_raises(TypeError) do
|
|
84
101
|
SnmpCommunity.new(nil, 'network-operator')
|
|
85
102
|
end
|
|
86
103
|
end
|
|
87
104
|
|
|
88
|
-
def
|
|
105
|
+
def test_create_group_nil
|
|
89
106
|
assert_raises(TypeError) do
|
|
90
107
|
SnmpCommunity.new('test', nil)
|
|
91
108
|
end
|
|
92
109
|
end
|
|
93
110
|
|
|
94
|
-
def
|
|
111
|
+
def test_create_name_zero_length
|
|
95
112
|
assert_raises(Cisco::CliError) do
|
|
96
113
|
SnmpCommunity.new('', 'network-operator')
|
|
97
114
|
end
|
|
98
115
|
end
|
|
99
116
|
|
|
100
|
-
def
|
|
117
|
+
def test_create_group_zero_length
|
|
101
118
|
assert_raises(Cisco::CliError) do
|
|
102
119
|
SnmpCommunity.new('test', '')
|
|
103
120
|
end
|
|
104
121
|
end
|
|
105
122
|
|
|
106
|
-
def
|
|
123
|
+
def test_create_name_too_long
|
|
107
124
|
name = 'co' + 'c' * SNMP_COMMUNITY_NAME_STR
|
|
108
125
|
assert_raises(Cisco::CliError) do
|
|
109
|
-
|
|
126
|
+
if platform != :ios_xr
|
|
127
|
+
SnmpCommunity.new(name, 'network-operator')
|
|
128
|
+
else
|
|
129
|
+
SnmpCommunity.new(name, '')
|
|
130
|
+
end
|
|
110
131
|
end
|
|
111
132
|
end
|
|
112
133
|
|
|
113
|
-
def
|
|
134
|
+
def test_create_group_too_long
|
|
114
135
|
group = 'gr' + 'g' * SNMP_GROUP_NAME_STR
|
|
115
136
|
assert_raises(Cisco::CliError) do
|
|
116
137
|
SnmpCommunity.new('test', group)
|
|
117
138
|
end
|
|
118
139
|
end
|
|
119
140
|
|
|
120
|
-
def
|
|
141
|
+
def test_create_group_invalid
|
|
121
142
|
name = 'ciscotest'
|
|
122
143
|
group = 'network-operator-invalid'
|
|
144
|
+
skip if platform == :ios_xr
|
|
123
145
|
assert_raises(Cisco::CliError) do
|
|
124
146
|
SnmpCommunity.new(name, group)
|
|
125
147
|
end
|
|
126
148
|
end
|
|
127
149
|
|
|
128
|
-
def
|
|
150
|
+
def test_create_valid
|
|
129
151
|
name = 'cisco'
|
|
130
152
|
group = 'network-operator'
|
|
131
153
|
snmpcommunity = SnmpCommunity.new(name, group)
|
|
132
|
-
|
|
133
|
-
|
|
154
|
+
if platform != :ios_xr
|
|
155
|
+
assert_show_match(
|
|
156
|
+
pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
|
|
157
|
+
else
|
|
158
|
+
assert_show_match(
|
|
159
|
+
pattern: /snmp-server community\s#{name}/)
|
|
160
|
+
assert_show_match(
|
|
161
|
+
pattern: /snmp-server group\s#{group}/)
|
|
162
|
+
assert_show_match(
|
|
163
|
+
pattern: /snmp-server community-map\s#{name}\starget-list\s#{group}/)
|
|
164
|
+
end
|
|
134
165
|
cleanup_snmpcommunity(snmpcommunity)
|
|
135
166
|
end
|
|
136
167
|
|
|
137
|
-
def
|
|
168
|
+
def test_name_alpha
|
|
138
169
|
name = 'cisco128lab'
|
|
139
170
|
group = 'network-operator'
|
|
140
171
|
snmpcommunity = SnmpCommunity.new(name, group)
|
|
141
|
-
|
|
142
|
-
|
|
172
|
+
if platform != :ios_xr
|
|
173
|
+
assert_show_match(
|
|
174
|
+
pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
|
|
175
|
+
else
|
|
176
|
+
assert_show_match(
|
|
177
|
+
pattern: /snmp-server community\s#{name}/)
|
|
178
|
+
assert_show_match(
|
|
179
|
+
pattern: /snmp-server group\s#{group}/)
|
|
180
|
+
assert_show_match(
|
|
181
|
+
pattern: /snmp-server community-map\s#{name}\starget-list\s#{group}/)
|
|
182
|
+
end
|
|
143
183
|
cleanup_snmpcommunity(snmpcommunity)
|
|
144
184
|
end
|
|
145
185
|
|
|
146
|
-
def
|
|
186
|
+
def test_get_group
|
|
147
187
|
name = 'ciscogetgrp'
|
|
148
188
|
group = 'network-operator'
|
|
149
189
|
snmpcommunity = SnmpCommunity.new(name, group)
|
|
@@ -151,7 +191,7 @@ class TestSnmpCommunity < CiscoTestCase
|
|
|
151
191
|
cleanup_snmpcommunity(snmpcommunity)
|
|
152
192
|
end
|
|
153
193
|
|
|
154
|
-
def
|
|
194
|
+
def test_group_set_zero_length
|
|
155
195
|
name = 'ciscogroupsetcom'
|
|
156
196
|
group = 'network-operator'
|
|
157
197
|
snmpcommunity = SnmpCommunity.new(name, group)
|
|
@@ -161,7 +201,8 @@ class TestSnmpCommunity < CiscoTestCase
|
|
|
161
201
|
cleanup_snmpcommunity(snmpcommunity)
|
|
162
202
|
end
|
|
163
203
|
|
|
164
|
-
def
|
|
204
|
+
def test_group_set_too_long
|
|
205
|
+
skip if platform == :ios_xr
|
|
165
206
|
name = 'ciscogroupsetcom'
|
|
166
207
|
group = 'network-operator'
|
|
167
208
|
snmpcommunity = SnmpCommunity.new(name, group)
|
|
@@ -171,7 +212,8 @@ class TestSnmpCommunity < CiscoTestCase
|
|
|
171
212
|
cleanup_snmpcommunity(snmpcommunity)
|
|
172
213
|
end
|
|
173
214
|
|
|
174
|
-
def
|
|
215
|
+
def test_group_set_invalid
|
|
216
|
+
skip if platform == :ios_xr
|
|
175
217
|
name = 'ciscogroupsetcom'
|
|
176
218
|
group = 'network-operator'
|
|
177
219
|
snmpcommunity = SnmpCommunity.new(name, group)
|
|
@@ -181,47 +223,80 @@ class TestSnmpCommunity < CiscoTestCase
|
|
|
181
223
|
cleanup_snmpcommunity(snmpcommunity)
|
|
182
224
|
end
|
|
183
225
|
|
|
184
|
-
def
|
|
226
|
+
def test_group_set_valid
|
|
185
227
|
name = 'ciscogroupsetcom'
|
|
186
228
|
group = 'network-operator'
|
|
187
229
|
snmpcommunity = SnmpCommunity.new(name, group)
|
|
188
230
|
# new group
|
|
189
231
|
group = 'network-admin'
|
|
190
232
|
snmpcommunity.group = group
|
|
191
|
-
|
|
192
|
-
|
|
233
|
+
if platform != :ios_xr
|
|
234
|
+
assert_show_match(
|
|
235
|
+
pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
|
|
236
|
+
else
|
|
237
|
+
assert_show_match(
|
|
238
|
+
pattern: /snmp-server community\s#{name}/)
|
|
239
|
+
assert_show_match(
|
|
240
|
+
pattern: /snmp-server group\s#{group}/)
|
|
241
|
+
assert_show_match(
|
|
242
|
+
pattern: /snmp-server community-map\s#{name}\starget-list\s#{group}/)
|
|
243
|
+
end
|
|
244
|
+
|
|
193
245
|
cleanup_snmpcommunity(snmpcommunity)
|
|
194
246
|
end
|
|
195
247
|
|
|
196
|
-
def
|
|
248
|
+
def test_group_set_default
|
|
197
249
|
name = 'ciscogroupsetcom'
|
|
198
250
|
group = 'network-operator'
|
|
199
251
|
snmpcommunity = SnmpCommunity.new(name, group)
|
|
200
252
|
# new group identity
|
|
201
253
|
group = 'vdc-admin'
|
|
202
254
|
snmpcommunity.group = group
|
|
203
|
-
|
|
204
|
-
|
|
255
|
+
if platform != :ios_xr
|
|
256
|
+
assert_show_match(
|
|
257
|
+
pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
|
|
258
|
+
else
|
|
259
|
+
assert_show_match(
|
|
260
|
+
pattern: /snmp-server community\s#{name}/)
|
|
261
|
+
assert_show_match(
|
|
262
|
+
pattern: /snmp-server group\s#{group}/)
|
|
263
|
+
assert_show_match(
|
|
264
|
+
pattern: /snmp-server community-map\s#{name}\starget-list\s#{group}/)
|
|
265
|
+
end
|
|
205
266
|
|
|
206
267
|
# Restore group default
|
|
207
268
|
group = SnmpCommunity.default_group
|
|
208
269
|
snmpcommunity.group = group
|
|
209
|
-
|
|
210
|
-
|
|
270
|
+
if platform != :ios_xr
|
|
271
|
+
assert_show_match(
|
|
272
|
+
pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
|
|
273
|
+
else
|
|
274
|
+
assert_show_match(
|
|
275
|
+
pattern: /snmp-server community\s#{name}/)
|
|
276
|
+
assert_show_match(
|
|
277
|
+
pattern: /snmp-server group\s#{group}/)
|
|
278
|
+
assert_show_match(
|
|
279
|
+
pattern: /snmp-server community-map\s#{name}\starget-list\s#{group}/)
|
|
280
|
+
end
|
|
211
281
|
|
|
212
282
|
cleanup_snmpcommunity(snmpcommunity)
|
|
213
283
|
end
|
|
214
284
|
|
|
215
|
-
def
|
|
285
|
+
def test_destroy_valid
|
|
216
286
|
name = 'ciscotest'
|
|
217
287
|
group = 'network-operator'
|
|
218
288
|
snmpcommunity = SnmpCommunity.new(name, group)
|
|
219
289
|
snmpcommunity.destroy
|
|
220
|
-
|
|
221
|
-
|
|
290
|
+
if platform != :ios_xr
|
|
291
|
+
refute_show_match(
|
|
292
|
+
pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
|
|
293
|
+
else
|
|
294
|
+
refute_show_match(
|
|
295
|
+
pattern: /snmp-server community\s#{name}/)
|
|
296
|
+
end
|
|
222
297
|
end
|
|
223
298
|
|
|
224
|
-
def
|
|
299
|
+
def test_acl_get_no_acl
|
|
225
300
|
name = 'cisconoaclget'
|
|
226
301
|
group = 'network-operator'
|
|
227
302
|
snmpcommunity = SnmpCommunity.new(name, group)
|
|
@@ -229,19 +304,26 @@ class TestSnmpCommunity < CiscoTestCase
|
|
|
229
304
|
cleanup_snmpcommunity(snmpcommunity)
|
|
230
305
|
end
|
|
231
306
|
|
|
232
|
-
def
|
|
307
|
+
def test_acl_get
|
|
233
308
|
name = 'ciscoaclget'
|
|
234
309
|
group = 'network-operator'
|
|
235
310
|
snmpcommunity = SnmpCommunity.new(name, group)
|
|
236
311
|
snmpcommunity.acl = 'ciscoacl'
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
312
|
+
if platform != :ios_xr
|
|
313
|
+
line = assert_show_match(
|
|
314
|
+
pattern: /snmp-server community\s#{name}\suse-acl\s\S+/)
|
|
315
|
+
acl = line.to_s.gsub(/snmp-server community\s#{name}\suse-acl\s/, '').strip
|
|
316
|
+
assert_equal(snmpcommunity.acl, acl)
|
|
317
|
+
else
|
|
318
|
+
line = assert_show_match(
|
|
319
|
+
pattern: /snmp-server community\s#{name}\sIPv4\s\S+/)
|
|
320
|
+
acl = line.to_s.gsub(/snmp-server community\s#{name}\sIPv4\s/, '').strip
|
|
321
|
+
assert_equal(snmpcommunity.acl, acl)
|
|
322
|
+
end
|
|
241
323
|
cleanup_snmpcommunity(snmpcommunity)
|
|
242
324
|
end
|
|
243
325
|
|
|
244
|
-
def
|
|
326
|
+
def test_acl_set_nil
|
|
245
327
|
name = 'cisco'
|
|
246
328
|
group = 'network-operator'
|
|
247
329
|
snmpcommunity = SnmpCommunity.new(name, group)
|
|
@@ -251,41 +333,61 @@ class TestSnmpCommunity < CiscoTestCase
|
|
|
251
333
|
cleanup_snmpcommunity(snmpcommunity)
|
|
252
334
|
end
|
|
253
335
|
|
|
254
|
-
def
|
|
336
|
+
def test_acl_set_valid
|
|
255
337
|
name = 'ciscoadmin'
|
|
256
338
|
group = 'network-admin'
|
|
257
339
|
acl = 'ciscoadminacl'
|
|
258
340
|
snmpcommunity = SnmpCommunity.new(name, group)
|
|
259
341
|
snmpcommunity.acl = acl
|
|
260
|
-
|
|
261
|
-
|
|
342
|
+
if platform != :ios_xr
|
|
343
|
+
assert_show_match(
|
|
344
|
+
pattern: /snmp-server community\s#{name}\suse-acl\s#{acl}/)
|
|
345
|
+
else
|
|
346
|
+
assert_show_match(
|
|
347
|
+
pattern: /snmp-server community\s#{name}\sIPv4\s#{acl}/)
|
|
348
|
+
end
|
|
262
349
|
cleanup_snmpcommunity(snmpcommunity)
|
|
263
350
|
end
|
|
264
351
|
|
|
265
|
-
def
|
|
352
|
+
def test_acl_set_zero_length
|
|
266
353
|
name = 'ciscooper'
|
|
267
354
|
group = 'network-operator'
|
|
268
355
|
acl = 'ciscooperacl'
|
|
269
356
|
snmpcommunity = SnmpCommunity.new(name, group)
|
|
270
357
|
# puts "set acl #{acl}"
|
|
271
358
|
snmpcommunity.acl = acl
|
|
272
|
-
|
|
273
|
-
|
|
359
|
+
if platform != :ios_xr
|
|
360
|
+
assert_show_match(
|
|
361
|
+
pattern: /snmp-server community\s#{name}\suse-acl\s#{acl}/)
|
|
362
|
+
else
|
|
363
|
+
assert_show_match(
|
|
364
|
+
pattern: /snmp-server community\s#{name}\sIPv4\s#{acl}/)
|
|
365
|
+
end
|
|
274
366
|
# remove acl
|
|
275
367
|
snmpcommunity.acl = ''
|
|
276
|
-
|
|
277
|
-
|
|
368
|
+
if platform != :ios_xr
|
|
369
|
+
refute_show_match(
|
|
370
|
+
pattern: /snmp-server community\s#{name}\suse-acl\s#{acl}/)
|
|
371
|
+
else
|
|
372
|
+
refute_show_match(
|
|
373
|
+
pattern: /snmp-server community\s#{name}\sIPv4\s#{acl}/)
|
|
374
|
+
end
|
|
278
375
|
cleanup_snmpcommunity(snmpcommunity)
|
|
279
376
|
end
|
|
280
377
|
|
|
281
|
-
def
|
|
378
|
+
def test_acl_set_default
|
|
282
379
|
name = 'cisco'
|
|
283
380
|
group = 'network-operator'
|
|
284
381
|
acl = 'cisco_test_acl'
|
|
285
382
|
snmpcommunity = SnmpCommunity.new(name, group)
|
|
286
383
|
snmpcommunity.acl = acl
|
|
287
|
-
|
|
288
|
-
|
|
384
|
+
if platform != :ios_xr
|
|
385
|
+
assert_show_match(
|
|
386
|
+
pattern: /snmp-server community\s#{name}\suse-acl\s#{acl}/)
|
|
387
|
+
else
|
|
388
|
+
assert_show_match(
|
|
389
|
+
pattern: /snmp-server community\s#{name}\sIPv4\s#{acl}/)
|
|
390
|
+
end
|
|
289
391
|
|
|
290
392
|
# Check default_acl
|
|
291
393
|
assert_equal(DEFAULT_SNMP_COMMUNITY_ACL,
|
|
@@ -295,8 +397,14 @@ class TestSnmpCommunity < CiscoTestCase
|
|
|
295
397
|
# Set acl to default
|
|
296
398
|
acl = SnmpCommunity.default_acl
|
|
297
399
|
snmpcommunity.acl = acl
|
|
298
|
-
|
|
299
|
-
|
|
400
|
+
if platform != :ios_xr
|
|
401
|
+
refute_show_match(
|
|
402
|
+
pattern: /snmp-server community\s#{name}\suse-acl\s#{acl}/)
|
|
403
|
+
else
|
|
404
|
+
refute_show_match(
|
|
405
|
+
pattern: /snmp-server community\s#{name}\sIPv4\s#{acl}/)
|
|
406
|
+
end
|
|
407
|
+
|
|
300
408
|
cleanup_snmpcommunity(snmpcommunity)
|
|
301
409
|
end
|
|
302
410
|
end
|