cisco_node_utils 0.9.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 +7 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +293 -0
- data/CHANGELOG.md +5 -0
- data/CONTRIBUTING.md +31 -0
- data/Gemfile +4 -0
- data/LICENSE +201 -0
- data/README.md +113 -0
- data/Rakefile +4 -0
- data/cisco_node_utils.gemspec +30 -0
- data/lib/cisco_node_utils.rb +33 -0
- data/lib/cisco_node_utils/README_YAML.md +333 -0
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +92 -0
- data/lib/cisco_node_utils/command_reference.rb +415 -0
- data/lib/cisco_node_utils/command_reference_common.yaml +845 -0
- data/lib/cisco_node_utils/command_reference_n3064.yaml +13 -0
- data/lib/cisco_node_utils/command_reference_n7k.yaml +48 -0
- data/lib/cisco_node_utils/command_reference_n9k.yaml +35 -0
- data/lib/cisco_node_utils/configparser_lib.rb +196 -0
- data/lib/cisco_node_utils/interface.rb +501 -0
- data/lib/cisco_node_utils/interface_ospf.rb +241 -0
- data/lib/cisco_node_utils/node.rb +673 -0
- data/lib/cisco_node_utils/platform.rb +184 -0
- data/lib/cisco_node_utils/platform_info.rb +58 -0
- data/lib/cisco_node_utils/platform_info.yaml +10 -0
- data/lib/cisco_node_utils/router_ospf.rb +96 -0
- data/lib/cisco_node_utils/router_ospf_vrf.rb +258 -0
- data/lib/cisco_node_utils/snmpcommunity.rb +91 -0
- data/lib/cisco_node_utils/snmpgroup.rb +55 -0
- data/lib/cisco_node_utils/snmpserver.rb +150 -0
- data/lib/cisco_node_utils/snmpuser.rb +342 -0
- data/lib/cisco_node_utils/tacacs_server.rb +175 -0
- data/lib/cisco_node_utils/tacacs_server_host.rb +128 -0
- data/lib/cisco_node_utils/version.rb +17 -0
- data/lib/cisco_node_utils/vlan.rb +153 -0
- data/lib/cisco_node_utils/vtp.rb +127 -0
- data/lib/cisco_node_utils/yum.rb +84 -0
- data/tests/basetest.rb +93 -0
- data/tests/ciscotest.rb +136 -0
- data/tests/cmd_config.yaml +51 -0
- data/tests/cmd_config_invalid.yaml +16 -0
- data/tests/test_all_cisco.rb +46 -0
- data/tests/test_command_config.rb +192 -0
- data/tests/test_command_reference.rb +222 -0
- data/tests/test_interface.rb +1017 -0
- data/tests/test_interface_ospf.rb +763 -0
- data/tests/test_interface_svi.rb +267 -0
- data/tests/test_interface_switchport.rb +722 -0
- data/tests/test_node.rb +108 -0
- data/tests/test_node_ext.rb +450 -0
- data/tests/test_platform.rb +188 -0
- data/tests/test_router_ospf.rb +164 -0
- data/tests/test_router_ospf_vrf.rb +753 -0
- data/tests/test_snmpcommunity.rb +344 -0
- data/tests/test_snmpgroup.rb +71 -0
- data/tests/test_snmpserver.rb +443 -0
- data/tests/test_snmpuser.rb +803 -0
- data/tests/test_tacacs_server.rb +388 -0
- data/tests/test_tacacs_server_host.rb +391 -0
- data/tests/test_vlan.rb +264 -0
- data/tests/test_vtp.rb +319 -0
- data/tests/test_yum.rb +106 -0
- metadata +188 -0
@@ -0,0 +1,344 @@
|
|
1
|
+
# Copyright (c) 2013-2015 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 File.expand_path("../ciscotest", __FILE__)
|
16
|
+
require File.expand_path("../../lib/cisco_node_utils/snmpcommunity", __FILE__)
|
17
|
+
|
18
|
+
def cleanup_snmp_communities(snmpcommunities)
|
19
|
+
snmpcommunities.each { |name, snmpcommunity|
|
20
|
+
snmpcommunity.destroy
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def cleanup_snmpcommunity(community)
|
25
|
+
community.destroy
|
26
|
+
end
|
27
|
+
|
28
|
+
class TestSnmpCommunity < CiscoTestCase
|
29
|
+
SNMP_COMMUNITY_NAME_STR = 128
|
30
|
+
SNMP_GROUP_NAME_STR = 128
|
31
|
+
DEFAULT_SNMP_COMMUNITY_GROUP = "network-operator"
|
32
|
+
DEFAULT_SNMP_COMMUNITY_ACL = ""
|
33
|
+
|
34
|
+
def test_snmpcommunity_collection_empty
|
35
|
+
# This test requires all the snmp communities removed from device
|
36
|
+
s = @device.cmd("show run snmp all | no-more")
|
37
|
+
cmd_prefix = "snmp-server community"
|
38
|
+
# puts "s : #{s}"
|
39
|
+
pattern = /#{cmd_prefix}\s\S+\sgroup\s\S+/
|
40
|
+
until (md = pattern.match(s)).nil?
|
41
|
+
# puts "md : #{md}"
|
42
|
+
ret = @device.cmd("configure terminal")
|
43
|
+
ret = @device.cmd("no #{md}")
|
44
|
+
ret = @device.cmd("end")
|
45
|
+
node.cache_flush
|
46
|
+
s = md.post_match
|
47
|
+
end
|
48
|
+
snmpcommunities = SnmpCommunity.communities()
|
49
|
+
assert_equal(true, snmpcommunities.empty?(),
|
50
|
+
"SnmpCommunity collection is not empty")
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_snmpcommunity_collection_not_empty
|
54
|
+
# This test require some snmp community exist in device
|
55
|
+
s = @device.cmd("configure terminal")
|
56
|
+
s = @device.cmd("snmp-server community com1 group network-admin")
|
57
|
+
s = @device.cmd("snmp-server community com2")
|
58
|
+
s = @device.cmd("end")
|
59
|
+
node.cache_flush
|
60
|
+
snmpcommunities = SnmpCommunity.communities()
|
61
|
+
assert_equal(false, snmpcommunities.empty?(),
|
62
|
+
"SnmpCommunity collection is empty")
|
63
|
+
cleanup_snmp_communities(snmpcommunities)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_snmpcommunity_collection_valid
|
67
|
+
# This test require some snmp community exist in device
|
68
|
+
s = @device.cmd("configure terminal")
|
69
|
+
s = @device.cmd("snmp-server community com12 group network-operator")
|
70
|
+
s = @device.cmd("snmp-server community com22 group network-admin")
|
71
|
+
s = @device.cmd("end")
|
72
|
+
node.cache_flush
|
73
|
+
# get collection
|
74
|
+
snmpcommunities = SnmpCommunity.communities()
|
75
|
+
s = @device.cmd("show run snmp all | no-more")
|
76
|
+
cmd = "snmp-server community"
|
77
|
+
snmpcommunities.each do |name, snmpcommunity|
|
78
|
+
line = /#{cmd}\s#{name}\sgroup\s#{snmpcommunity.group}/.match(s)
|
79
|
+
# puts "line: #{line}"
|
80
|
+
assert_equal(false, line.nil?)
|
81
|
+
end
|
82
|
+
cleanup_snmp_communities(snmpcommunities)
|
83
|
+
snmpcommunities = nil
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_snmpcommunity_create_name_nil
|
87
|
+
assert_raises(TypeError) do
|
88
|
+
snmpcommunity = SnmpCommunity.new(nil, "network-operator")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_snmpcommunity_create_group_nil
|
93
|
+
assert_raises(TypeError) do
|
94
|
+
snmpcommunity = SnmpCommunity.new("test", nil)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_snmpcommunity_create_name_zero_length
|
99
|
+
assert_raises(Cisco::CliError) do
|
100
|
+
snmpcommunity = SnmpCommunity.new("", "network-operator")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_snmpcommunity_create_group_zero_length
|
105
|
+
assert_raises(Cisco::CliError) do
|
106
|
+
snmpcommunity = SnmpCommunity.new("test", "")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_snmpcommunity_create_name_too_long
|
111
|
+
name = "co"
|
112
|
+
SNMP_COMMUNITY_NAME_STR.times {
|
113
|
+
name += "c"
|
114
|
+
}
|
115
|
+
assert_raises(Cisco::CliError) do
|
116
|
+
snmpcommunity = SnmpCommunity.new(name,
|
117
|
+
"network-operator")
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_snmpcommunity_create_group_too_long
|
122
|
+
group = "gr"
|
123
|
+
SNMP_GROUP_NAME_STR.times {
|
124
|
+
group += "g"
|
125
|
+
}
|
126
|
+
assert_raises(Cisco::CliError) do
|
127
|
+
snmpcommunity = SnmpCommunity.new("test", group)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_snmpcommunity_create_group_invalid
|
132
|
+
name = "ciscotest"
|
133
|
+
group = "network-operator-invalid"
|
134
|
+
assert_raises(Cisco::CliError) do
|
135
|
+
snmpcommunity = SnmpCommunity.new(name,
|
136
|
+
group)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_snmpcommunity_create_valid
|
141
|
+
name = "cisco"
|
142
|
+
group = "network-operator"
|
143
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
144
|
+
s = @device.cmd("show run snmp all | no-more")
|
145
|
+
cmd = "snmp-server community"
|
146
|
+
line = /#{cmd}\s#{name}\sgroup\s#{group}/.match(s)
|
147
|
+
# puts "line: #{line}"
|
148
|
+
assert_equal(false, line.nil?)
|
149
|
+
cleanup_snmpcommunity(snmpcommunity)
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_snmpcommunity_create_with_name_alphanumeric_char
|
153
|
+
name = "cisco128lab"
|
154
|
+
group = "network-operator"
|
155
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
156
|
+
s = @device.cmd("show run snmp all | no-more")
|
157
|
+
cmd = "snmp-server community"
|
158
|
+
line = /#{cmd}\s#{name}\sgroup\s#{group}/.match(s)
|
159
|
+
# puts "line: #{line}"
|
160
|
+
assert_equal(false, line.nil?)
|
161
|
+
cleanup_snmpcommunity(snmpcommunity)
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_snmpcommunity_get_group
|
165
|
+
name = "ciscogetgrp"
|
166
|
+
group = "network-operator"
|
167
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
168
|
+
assert_equal(snmpcommunity.group, group)
|
169
|
+
cleanup_snmpcommunity(snmpcommunity)
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_snmpcommunity_group_set_zero_length
|
173
|
+
name = "ciscogroupsetcom"
|
174
|
+
group = "network-operator"
|
175
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
176
|
+
assert_raises(Cisco::CliError) do
|
177
|
+
snmpcommunity.group=""
|
178
|
+
end
|
179
|
+
cleanup_snmpcommunity(snmpcommunity)
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_snmpcommunity_group_set_too_long
|
183
|
+
name = "ciscogroupsetcom"
|
184
|
+
group = "network-operator"
|
185
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
186
|
+
assert_raises(Cisco::CliError) do
|
187
|
+
snmpcommunity.group="group123456789c123456789c123456789c12345"
|
188
|
+
end
|
189
|
+
cleanup_snmpcommunity(snmpcommunity)
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_snmpcommunity_group_set_invalid
|
193
|
+
name = "ciscogroupsetcom"
|
194
|
+
group = "network-operator"
|
195
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
196
|
+
assert_raises(Cisco::CliError) do
|
197
|
+
snmpcommunity.group="testgroup"
|
198
|
+
end
|
199
|
+
cleanup_snmpcommunity(snmpcommunity)
|
200
|
+
end
|
201
|
+
|
202
|
+
def test_snmpcommunity_group_set_valid
|
203
|
+
name = "ciscogroupsetcom"
|
204
|
+
group = "network-operator"
|
205
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
206
|
+
# new group
|
207
|
+
group = "network-admin"
|
208
|
+
snmpcommunity.group = group
|
209
|
+
s = @device.cmd("show run snmp all | no-more")
|
210
|
+
cmd = "snmp-server community"
|
211
|
+
line = /#{cmd}\s#{name}\sgroup\s#{group}/.match(s)
|
212
|
+
assert_equal(false, line.nil?)
|
213
|
+
cleanup_snmpcommunity(snmpcommunity)
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_snmpcommunity_group_set_default
|
217
|
+
name = "ciscogroupsetcom"
|
218
|
+
group = "network-operator"
|
219
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
220
|
+
# new group identity
|
221
|
+
group = "vdc-admin"
|
222
|
+
snmpcommunity.group = group
|
223
|
+
s = @device.cmd("show run snmp all | no-more")
|
224
|
+
cmd = "snmp-server community"
|
225
|
+
line = /#{cmd}\s#{name}\sgroup\s#{group}/.match(s)
|
226
|
+
# puts line
|
227
|
+
assert_equal(false, line.nil?)
|
228
|
+
|
229
|
+
# Restore group default
|
230
|
+
group = SnmpCommunity.default_group()
|
231
|
+
snmpcommunity.group = group
|
232
|
+
s = @device.cmd("show run snmp all | no-more")
|
233
|
+
cmd = "snmp-server community"
|
234
|
+
line = /#{cmd}\s#{name}\sgroup\s#{group}/.match(s)
|
235
|
+
# puts line
|
236
|
+
assert_equal(false, line.nil?)
|
237
|
+
|
238
|
+
cleanup_snmpcommunity(snmpcommunity)
|
239
|
+
end
|
240
|
+
|
241
|
+
def test_snmpcommunity_destroy_valid
|
242
|
+
name = "ciscotest"
|
243
|
+
group = "network-operator"
|
244
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
245
|
+
snmpcommunity.destroy
|
246
|
+
s = @device.cmd("show run snmp all | no-more")
|
247
|
+
cmd = "snmp-server community"
|
248
|
+
line = /#{cmd}\s#{name}\sgroup\s#{group}/.match(s)
|
249
|
+
assert_equal(true, line.nil?)
|
250
|
+
end
|
251
|
+
|
252
|
+
def test_snmpcommunity_acl_get_no_acl
|
253
|
+
name = "cisconoaclget"
|
254
|
+
group = "network-operator"
|
255
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
256
|
+
assert_equal(snmpcommunity.acl, "")
|
257
|
+
cleanup_snmpcommunity(snmpcommunity)
|
258
|
+
end
|
259
|
+
|
260
|
+
def test_snmpcommunity_acl_get
|
261
|
+
name = "ciscoaclget"
|
262
|
+
group = "network-operator"
|
263
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
264
|
+
snmpcommunity.acl="ciscoacl"
|
265
|
+
s = @device.cmd("show run snmp all | no-more")
|
266
|
+
cmd = "snmp-server community"
|
267
|
+
line = /#{cmd}\s#{name}\suse-acl\s\S+/.match(s)
|
268
|
+
acl = line.to_s.gsub(/#{cmd}\s#{name}\suse-acl\s/, "").strip
|
269
|
+
assert_equal(snmpcommunity.acl, acl)
|
270
|
+
cleanup_snmpcommunity(snmpcommunity)
|
271
|
+
end
|
272
|
+
|
273
|
+
def test_snmpcommunity_acl_set_nil
|
274
|
+
name = "cisco"
|
275
|
+
group = "network-operator"
|
276
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
277
|
+
assert_raises(TypeError) do
|
278
|
+
snmpcommunity.acl=nil
|
279
|
+
end
|
280
|
+
cleanup_snmpcommunity(snmpcommunity)
|
281
|
+
end
|
282
|
+
|
283
|
+
def test_snmpcommunity_acl_set_valid
|
284
|
+
name = "ciscoadmin"
|
285
|
+
group = "network-admin"
|
286
|
+
acl = "ciscoadminacl"
|
287
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
288
|
+
snmpcommunity.acl=acl
|
289
|
+
s = @device.cmd("show run snmp all | no-more")
|
290
|
+
cmd = "snmp-server community"
|
291
|
+
line = /#{cmd}\s#{name}\suse-acl\s#{acl}/.match(s)
|
292
|
+
# puts "line: #{line}"
|
293
|
+
assert_equal(false, line.nil?)
|
294
|
+
cleanup_snmpcommunity(snmpcommunity)
|
295
|
+
end
|
296
|
+
|
297
|
+
def test_snmpcommunity_acl_set_zero_length
|
298
|
+
name = "ciscooper"
|
299
|
+
group = "network-operator"
|
300
|
+
acl = "ciscooperacl"
|
301
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
302
|
+
# puts "set acl #{acl}"
|
303
|
+
snmpcommunity.acl=acl
|
304
|
+
s = @device.cmd("show run snmp all | no-more")
|
305
|
+
cmd = "snmp-server community"
|
306
|
+
line = /#{cmd}\s#{name}\suse-acl\s#{acl}/.match(s)
|
307
|
+
# puts "line: #{line}"
|
308
|
+
assert_equal(false, line.nil?)
|
309
|
+
# remove acl
|
310
|
+
snmpcommunity.acl=""
|
311
|
+
s = @device.cmd("show run snmp all | no-more")
|
312
|
+
line = /#{cmd}\s#{name}\suse-acl\s#{acl}/.match(s)
|
313
|
+
# puts "line: #{line}"
|
314
|
+
assert_equal(true, line.nil?)
|
315
|
+
cleanup_snmpcommunity(snmpcommunity)
|
316
|
+
end
|
317
|
+
|
318
|
+
def test_snmpcommunity_acl_set_default
|
319
|
+
name = "cisco"
|
320
|
+
group = "network-operator"
|
321
|
+
acl = "cisco_test_acl"
|
322
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
323
|
+
snmpcommunity.acl = acl
|
324
|
+
s = @device.cmd("show run snmp all | no-more")
|
325
|
+
cmd = "snmp-server community"
|
326
|
+
line = /#{cmd}\s#{name}\suse-acl\s#{acl}/.match(s)
|
327
|
+
# puts "line: #{line}"
|
328
|
+
assert_equal(false, line.nil?)
|
329
|
+
|
330
|
+
# Check default_acl
|
331
|
+
assert_equal(DEFAULT_SNMP_COMMUNITY_ACL,
|
332
|
+
SnmpCommunity.default_acl(),
|
333
|
+
"Error: Snmp Community, default ACL not correct value")
|
334
|
+
|
335
|
+
# Set acl to default
|
336
|
+
acl = SnmpCommunity.default_acl()
|
337
|
+
snmpcommunity.acl = acl
|
338
|
+
s = @device.cmd("show run snmp all | no-more")
|
339
|
+
line = /#{cmd}\s#{name}\suse-acl\s#{acl}/.match(s)
|
340
|
+
# puts "line: #{line}"
|
341
|
+
assert_equal(true, line.nil?)
|
342
|
+
cleanup_snmpcommunity(snmpcommunity)
|
343
|
+
end
|
344
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Copyright (c) 2013-2015 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 File.expand_path("../ciscotest", __FILE__)
|
16
|
+
require File.expand_path("../../lib/cisco_node_utils/snmpgroup", __FILE__)
|
17
|
+
|
18
|
+
class TestSnmpGroup < CiscoTestCase
|
19
|
+
# NXOS snmp groups will not be empty
|
20
|
+
def test_snmpgroup_collection_not_empty
|
21
|
+
snmpgroups = SnmpGroup.groups
|
22
|
+
assert_equal(false, snmpgroups.empty?(),
|
23
|
+
"SnmpGroup collection is empty")
|
24
|
+
snmpgroups = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_snmpgroup_collection_valid
|
28
|
+
snmpgroups = SnmpGroup.groups
|
29
|
+
s = @device.cmd("show snmp group | include Role | no-more")
|
30
|
+
snmpgroups.each do |name, snmpgroup|
|
31
|
+
line = /Role:\s#{snmpgroup.name}/.match(s)
|
32
|
+
# puts "line: #{line}"
|
33
|
+
assert_equal(false, line.nil?)
|
34
|
+
end
|
35
|
+
snmpgroups = nil
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_snmpgroup_exists_with_name_empty
|
39
|
+
assert_raises(ArgumentError) do
|
40
|
+
SnmpGroup.exists?("")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_snmpgroup_exists_with_name_invalid
|
45
|
+
name = "group-dummy"
|
46
|
+
exist = SnmpGroup.exists?(name)
|
47
|
+
s = @device.cmd("show snmp group | in Role | no-more")
|
48
|
+
line = /Role:\s#{name}/.match(s)
|
49
|
+
assert_equal(exist, !line.nil?)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_snmpgroup_exists_with_name_bad_type
|
53
|
+
assert_raises(TypeError) do
|
54
|
+
SnmpGroup.exists?(:not_a_string)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_snmpgroup_exists_with_name_valid
|
59
|
+
name = "network-admin"
|
60
|
+
exist = SnmpGroup.exists?(name)
|
61
|
+
s = @device.cmd("show snmp group | in Role | no-more")
|
62
|
+
line = /Role:\s#{name}/.match(s)
|
63
|
+
assert_equal(exist, !line.nil?)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_snmpgroup_get_name
|
67
|
+
name = "network-operator"
|
68
|
+
snmpgroup = SnmpGroup.new(name)
|
69
|
+
assert_equal(snmpgroup.name, name)
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,443 @@
|
|
1
|
+
# Copyright (c) 2013-2015 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 File.expand_path("../ciscotest", __FILE__)
|
16
|
+
require File.expand_path("../../lib/cisco_node_utils/snmpserver", __FILE__)
|
17
|
+
|
18
|
+
class TestSnmpServer < CiscoTestCase
|
19
|
+
DEFAULT_SNMP_SERVER_AAA_USER_CACHE_TIMEOUT = 3600
|
20
|
+
DEFAULT_SNMP_SERVER_LOCATION = ""
|
21
|
+
DEFAULT_SNMP_SERVER_CONTACT = ""
|
22
|
+
DEFAULT_SNMP_SERVER_PACKET_SIZE = 1500
|
23
|
+
DEFAULT_SNMP_SERVER_GLOBAL_ENFORCE_PRIVACY = false
|
24
|
+
DEFAULT_SNMP_SERVER_PROTOCOL_ENABLE = true
|
25
|
+
DEFAULT_SNMP_SERVER_TCP_SESSION_AUTH = true
|
26
|
+
|
27
|
+
def test_snmpserver_aaa_user_cache_timeout_set_invalid_upper_range
|
28
|
+
snmpserver = SnmpServer.new
|
29
|
+
assert_raises(Cisco::CliError) do
|
30
|
+
snmpserver.aaa_user_cache_timeout=86401
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_snmpserver_aaa_user_cache_timeout_set_invalid_lower_range
|
35
|
+
snmpserver = SnmpServer.new
|
36
|
+
assert_raises(Cisco::CliError) do
|
37
|
+
snmpserver.aaa_user_cache_timeout=0
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_snmpserver_aaa_user_cache_timeout_set_valid
|
42
|
+
snmpserver = SnmpServer.new
|
43
|
+
newtimeout = 1400
|
44
|
+
snmpserver.aaa_user_cache_timeout=newtimeout
|
45
|
+
s = @device.cmd("show run snmp all | no-more")
|
46
|
+
cmd='snmp-server aaa-user cache-timeout'
|
47
|
+
line = /#{cmd} (\d+)/.match(s)
|
48
|
+
timeout = line.to_s.split(" ").last.to_i
|
49
|
+
assert_equal(timeout, newtimeout)
|
50
|
+
# set to default
|
51
|
+
snmpserver.aaa_user_cache_timeout=
|
52
|
+
snmpserver.default_aaa_user_cache_timeout
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_snmpserver_aaa_user_cache_timeout_set_default_valid
|
56
|
+
snmpserver = SnmpServer.new
|
57
|
+
snmpserver.aaa_user_cache_timeout =
|
58
|
+
snmpserver.default_aaa_user_cache_timeout
|
59
|
+
s = @device.cmd("show run snmp all | no-more")
|
60
|
+
cmd='snmp-server aaa-user cache-timeout'
|
61
|
+
line = /#{cmd} (\d+)/.match(s)
|
62
|
+
timeout = line.to_s.split(" ").last.to_i
|
63
|
+
assert_equal(timeout, snmpserver.aaa_user_cache_timeout)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_snmpserver_aaa_user_cache_timeout_get
|
67
|
+
snmpserver = SnmpServer.new
|
68
|
+
s = @device.cmd("show run snmp all | no-more")
|
69
|
+
cmd='snmp-server aaa-user cache-timeout'
|
70
|
+
line = /#{cmd} (\d+)/.match(s)
|
71
|
+
timeout = line.to_s.split(" ").last.to_i
|
72
|
+
assert_equal(timeout, snmpserver.aaa_user_cache_timeout)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_snmpserver_sys_contact_get
|
76
|
+
snmpserver = SnmpServer.new
|
77
|
+
snmpserver.contact = "test-contact"
|
78
|
+
s = @device.cmd("show snmp | no-more")
|
79
|
+
line = /sys contact: [^\n\r]+/.match(s)
|
80
|
+
contact = ""
|
81
|
+
contact = line.to_s.gsub("sys contact:", "").strip unless line.nil?
|
82
|
+
# puts "contact : #{line}, #{snmpserver.contact}"
|
83
|
+
assert_equal(contact, snmpserver.contact)
|
84
|
+
# set to default
|
85
|
+
snmpserver.contact=snmpserver.default_contact
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_snmpserver_sys_contact_set_invalid
|
89
|
+
snmpserver = SnmpServer.new
|
90
|
+
assert_raises(TypeError) do
|
91
|
+
snmpserver.contact=123
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_snmpserver_sys_contact_set_zero_length
|
96
|
+
snmpserver = SnmpServer.new
|
97
|
+
newcontact = ""
|
98
|
+
snmpserver.contact=newcontact
|
99
|
+
assert_equal(newcontact, snmpserver.contact)
|
100
|
+
# set to default
|
101
|
+
snmpserver.contact=snmpserver.default_contact
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_snmpserver_sys_contact_set_valid
|
105
|
+
snmpserver = SnmpServer.new
|
106
|
+
newcontact = "mvenkata_test# contact"
|
107
|
+
snmpserver.contact=newcontact
|
108
|
+
s = @device.cmd("show snmp | no-more")
|
109
|
+
line = /sys contact: [^\n\r]+/.match(s)
|
110
|
+
# puts "line: #{line}"
|
111
|
+
contact = line.to_s.gsub("sys contact:", "").strip
|
112
|
+
assert_equal(contact, newcontact)
|
113
|
+
# set to default
|
114
|
+
snmpserver.contact=snmpserver.default_contact
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_snmpserver_sys_contact_set_special_chars
|
118
|
+
snmpserver = SnmpServer.new
|
119
|
+
# newcontact = "Test{}(%tuvy@_cisco contact$#!@1234^&*()_+"
|
120
|
+
newcontact = "user@example.com @$%&}test ]|[#_@test contact"
|
121
|
+
snmpserver.contact=newcontact
|
122
|
+
s = @device.cmd("show snmp | no-more")
|
123
|
+
line = /sys contact: [^\n\r]+/.match(s)
|
124
|
+
# puts "line: #{line}"
|
125
|
+
contact = line.to_s.gsub("sys contact:", "").strip
|
126
|
+
assert_equal(contact, newcontact)
|
127
|
+
# set to default
|
128
|
+
snmpserver.contact=snmpserver.default_contact
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_snmpserver_sys_contact_set_default
|
132
|
+
snmpserver = SnmpServer.new
|
133
|
+
snmpserver.contact = snmpserver.default_contact
|
134
|
+
s = @device.cmd("show snmp | no-more")
|
135
|
+
line = /sys contact: [^\n\r]+/.match(s)
|
136
|
+
contact = ""
|
137
|
+
contact = line.to_s.gsub("sys contact:", "").strip unless line.nil?
|
138
|
+
assert_equal(contact, snmpserver.default_contact)
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_snmpserver_sys_location_get
|
142
|
+
snmpserver = SnmpServer.new
|
143
|
+
# set location
|
144
|
+
snmpserver.location = "test-location"
|
145
|
+
s = @device.cmd("show snmp | no-more")
|
146
|
+
line = /sys location: [^\n\r]+/.match(s)
|
147
|
+
location=""
|
148
|
+
location = line.to_s.gsub("sys location:", "").strip unless line.nil?
|
149
|
+
# puts "location : #{location}, #{snmpserver.location}"
|
150
|
+
assert_equal(location, snmpserver.location)
|
151
|
+
# set to default
|
152
|
+
snmpserver.location=snmpserver.default_location
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_snmpserver_sys_location_set_invalid
|
156
|
+
snmpserver = SnmpServer.new
|
157
|
+
assert_raises(TypeError) do
|
158
|
+
snmpserver.location=123
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_snmpserver_sys_location_set_zero_length
|
163
|
+
snmpserver = SnmpServer.new
|
164
|
+
newlocation = ""
|
165
|
+
snmpserver.location=newlocation
|
166
|
+
assert_equal(newlocation, snmpserver.location)
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_snmpserver_sys_location_set_valid
|
170
|
+
snmpserver = SnmpServer.new
|
171
|
+
newlocation = "bxb-300-2-1 test location"
|
172
|
+
snmpserver.location=newlocation
|
173
|
+
s = @device.cmd("show snmp | no-more")
|
174
|
+
line = /sys location: [^\n\r]+/.match(s)
|
175
|
+
location = line.to_s.gsub("sys location:", "").strip
|
176
|
+
assert_equal(location, newlocation)
|
177
|
+
# set to default
|
178
|
+
snmpserver.location=snmpserver.default_location
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_snmpserver_sys_location_set_special_chars
|
182
|
+
snmpserver = SnmpServer.new
|
183
|
+
newlocation = "bxb-300 2nd floor test !$%^33&&*) location"
|
184
|
+
snmpserver.location=newlocation
|
185
|
+
s = @device.cmd("show snmp | no-more")
|
186
|
+
line = /sys location: [^\n\r]+/.match(s)
|
187
|
+
location = line.to_s.gsub("sys location:", "").strip
|
188
|
+
assert_equal(location, newlocation)
|
189
|
+
# set to default
|
190
|
+
snmpserver.location=snmpserver.default_location
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_snmpserver_sys_location_set_default
|
194
|
+
snmpserver = SnmpServer.new
|
195
|
+
# snmpserver.location = snmpserver.default_location
|
196
|
+
snmpserver.location = "FOO"
|
197
|
+
s = @device.cmd("show snmp | no-more")
|
198
|
+
line = /sys location: [^\n\r]+/.match(s)
|
199
|
+
location = ""
|
200
|
+
location = line.to_s.gsub("sys location:", "").strip unless line.nil?
|
201
|
+
assert_equal(location, snmpserver.location)
|
202
|
+
# set to default
|
203
|
+
snmpserver.location=snmpserver.default_location
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_snmpserver_packetsize_get
|
207
|
+
snmpserver = SnmpServer.new
|
208
|
+
snmpserver.packet_size=2000
|
209
|
+
s = @device.cmd("show run snmp all | no-more")
|
210
|
+
cmd='snmp-server packetsize'
|
211
|
+
line = /#{cmd} (\d+)/.match(s)
|
212
|
+
packetsize = 0
|
213
|
+
packetsize = line.to_s.split(" ").last.to_i unless line.nil?
|
214
|
+
assert_equal(packetsize, snmpserver.packet_size)
|
215
|
+
# unset to default
|
216
|
+
snmpserver.packet_size = 0
|
217
|
+
end
|
218
|
+
|
219
|
+
def test_snmpserver_packetsize_set_invalid_upper_range
|
220
|
+
snmpserver = SnmpServer.new
|
221
|
+
newpacketsize = 17383
|
222
|
+
assert_raises(Cisco::CliError) do
|
223
|
+
snmpserver.packet_size=newpacketsize
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def test_snmpserver_packetsize_set_invalid_lower_range
|
228
|
+
snmpserver = SnmpServer.new
|
229
|
+
newpacketsize = 480
|
230
|
+
assert_raises(Cisco::CliError) do
|
231
|
+
snmpserver.packet_size=newpacketsize
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_snmpserver_packetsize_set_valid
|
236
|
+
snmpserver = SnmpServer.new
|
237
|
+
newpacketsize = 1600
|
238
|
+
snmpserver.packet_size=newpacketsize
|
239
|
+
s = @device.cmd("show run snmp all | no-more")
|
240
|
+
cmd='snmp-server packetsize'
|
241
|
+
line = /#{cmd} (\d+)/.match(s)
|
242
|
+
packetsize = line.to_s.split(" ").last.to_i
|
243
|
+
assert_equal(packetsize, newpacketsize)
|
244
|
+
# unset to default
|
245
|
+
snmpserver.packet_size = 0
|
246
|
+
end
|
247
|
+
|
248
|
+
def test_snmpserver_packetsize_set_default
|
249
|
+
snmpserver = SnmpServer.new
|
250
|
+
|
251
|
+
packetsize = DEFAULT_SNMP_SERVER_PACKET_SIZE
|
252
|
+
s = @device.cmd("show run snmp all | no-more")
|
253
|
+
cmd='snmp-server packetsize'
|
254
|
+
line = /#{cmd} (\d+)/.match(s)
|
255
|
+
packetsize = line.to_s.split(" ").last.to_i
|
256
|
+
assert_equal(packetsize, snmpserver.packet_size,
|
257
|
+
"Error: Snmp Server, packet size not default")
|
258
|
+
|
259
|
+
snmpserver.packet_size = 850
|
260
|
+
s = @device.cmd("show run snmp all | no-more")
|
261
|
+
cmd='snmp-server packetsize'
|
262
|
+
line = /#{cmd} (\d+)/.match(s)
|
263
|
+
packetsize = line.to_s.split(" ").last.to_i
|
264
|
+
assert_equal(packetsize, snmpserver.packet_size,
|
265
|
+
"Error: Snmp Server, packet size not default")
|
266
|
+
|
267
|
+
snmpserver.packet_size = snmpserver.default_packet_size
|
268
|
+
s = @device.cmd("show run snmp all | no-more")
|
269
|
+
cmd='snmp-server packetsize'
|
270
|
+
line = /#{cmd} (\d+)/.match(s)
|
271
|
+
packetsize = line.to_s.split(" ").last.to_i
|
272
|
+
assert_equal(packetsize, snmpserver.packet_size,
|
273
|
+
"Error: Snmp Server, packet size not default")
|
274
|
+
# set to default
|
275
|
+
snmpserver.packet_size = 0
|
276
|
+
end
|
277
|
+
|
278
|
+
def test_snmpserver_packetsize_unset
|
279
|
+
snmpserver = SnmpServer.new
|
280
|
+
|
281
|
+
# Get orginal packet size
|
282
|
+
org_packet_size = snmpserver.packet_size
|
283
|
+
snmpserver.packet_size = 0
|
284
|
+
s = @device.cmd("show run snmp all | no-more")
|
285
|
+
cmd='snmp-server packetsize'
|
286
|
+
line = /#{cmd} (\d+)/.match(s)
|
287
|
+
packetsize = line.to_s.split(" ").last.to_i
|
288
|
+
assert_equal(packetsize, snmpserver.packet_size,
|
289
|
+
"Error: Snmp Server, packet size not unset")
|
290
|
+
|
291
|
+
# Restore packet size
|
292
|
+
snmpserver.packet_size = org_packet_size
|
293
|
+
assert_equal(org_packet_size, snmpserver.packet_size,
|
294
|
+
"Error: Snmp Server, packet size not restored")
|
295
|
+
# set to default
|
296
|
+
snmpserver.packet_size = 0
|
297
|
+
end
|
298
|
+
|
299
|
+
def test_snmpserver_global_enforce_priv_get_default
|
300
|
+
snmpserver = SnmpServer.new
|
301
|
+
# default is false
|
302
|
+
snmpserver.global_enforce_priv=false
|
303
|
+
device_enabled = snmpserver.global_enforce_priv?
|
304
|
+
s = @device.cmd("show run snmp all | no-more")
|
305
|
+
cmd='no snmp-server globalEnforcePriv'
|
306
|
+
line = /#{cmd}/.match(s)
|
307
|
+
assert_equal(line.nil?, device_enabled)
|
308
|
+
# set to default
|
309
|
+
snmpserver.global_enforce_priv=snmpserver.default_global_enforce_priv
|
310
|
+
end
|
311
|
+
|
312
|
+
def test_snmpserver_global_enforce_priv_get_enabled
|
313
|
+
snmpserver = SnmpServer.new
|
314
|
+
snmpserver.global_enforce_priv=true
|
315
|
+
device_enabled = snmpserver.global_enforce_priv?
|
316
|
+
s = @device.cmd("show run snmp all | no-more")
|
317
|
+
cmd='snmp-server globalEnforcePriv'
|
318
|
+
line = /#{cmd}/.match(s)
|
319
|
+
assert_equal(!line.nil?, device_enabled)
|
320
|
+
# set to default
|
321
|
+
snmpserver.global_enforce_priv=snmpserver.default_global_enforce_priv
|
322
|
+
end
|
323
|
+
|
324
|
+
def test_snmpserver_global_enforce_priv_set_enabled
|
325
|
+
snmpserver = SnmpServer.new
|
326
|
+
snmpserver.global_enforce_priv=true
|
327
|
+
s = @device.cmd("show run snmp all | no-more")
|
328
|
+
cmd='snmp-server globalEnforcePriv'
|
329
|
+
line = /#{cmd}/.match(s)
|
330
|
+
# puts "line : #{line}"
|
331
|
+
assert_equal(!line.nil?, true)
|
332
|
+
# set to default
|
333
|
+
snmpserver.global_enforce_priv=snmpserver.default_global_enforce_priv
|
334
|
+
end
|
335
|
+
|
336
|
+
def test_snmpserver_global_enforce_priv_set_disabled
|
337
|
+
snmpserver = SnmpServer.new
|
338
|
+
snmpserver.global_enforce_priv=false
|
339
|
+
s = @device.cmd("show run snmp all | no-more")
|
340
|
+
cmd='no snmp-server globalEnforcePriv'
|
341
|
+
line = /#{cmd}/.match(s)
|
342
|
+
assert_equal(line.nil?, false)
|
343
|
+
# set to default
|
344
|
+
snmpserver.global_enforce_priv=snmpserver.default_global_enforce_priv
|
345
|
+
end
|
346
|
+
|
347
|
+
def test_snmpserver_protocol_get_default
|
348
|
+
snmpserver = SnmpServer.new
|
349
|
+
# set default
|
350
|
+
snmpserver.protocol=true
|
351
|
+
device_enabled = snmpserver.protocol?
|
352
|
+
cmd='^snmp-server protocol enable'
|
353
|
+
s = @device.cmd("show run snmp all | i '#{cmd}'")
|
354
|
+
assert_match(/#{cmd}/, s)
|
355
|
+
# set to default
|
356
|
+
snmpserver.protocol=snmpserver.default_protocol
|
357
|
+
end
|
358
|
+
|
359
|
+
def test_snmpserver_protocol_get_disabled
|
360
|
+
snmpserver = SnmpServer.new
|
361
|
+
snmpserver.protocol=false
|
362
|
+
device_enabled = snmpserver.protocol?
|
363
|
+
s = @device.cmd("show run snmp all | no-more")
|
364
|
+
cmd='no snmp-server protocol enable'
|
365
|
+
line = /#{cmd}/.match(s)
|
366
|
+
# puts "line #{line}"
|
367
|
+
assert_equal(line.nil?, device_enabled)
|
368
|
+
# set to default
|
369
|
+
snmpserver.protocol=snmpserver.default_protocol
|
370
|
+
end
|
371
|
+
|
372
|
+
def test_snmpserver_protocol_set_enabled
|
373
|
+
snmpserver = SnmpServer.new
|
374
|
+
snmpserver.protocol=true
|
375
|
+
s = @device.cmd("show run snmp all | no-more")
|
376
|
+
cmd='snmp-server protocol enable'
|
377
|
+
line = /#{cmd}/.match(s)
|
378
|
+
# puts "line : #{line}"
|
379
|
+
assert_equal(!line.nil?, true)
|
380
|
+
# set to default
|
381
|
+
snmpserver.protocol=snmpserver.default_protocol
|
382
|
+
end
|
383
|
+
|
384
|
+
def test_snmpserver_protocol_set_disabled
|
385
|
+
snmpserver = SnmpServer.new
|
386
|
+
snmpserver.protocol=false
|
387
|
+
s = @device.cmd("show run snmp all | no-more")
|
388
|
+
cmd='no snmp-server protocol enable'
|
389
|
+
line = /#{cmd}/.match(s)
|
390
|
+
# puts "line : #{line}"
|
391
|
+
assert_equal(line.nil?, false)
|
392
|
+
# set to default
|
393
|
+
snmpserver.protocol=snmpserver.default_protocol
|
394
|
+
end
|
395
|
+
|
396
|
+
def test_snmpserver_tcp_session_auth_get_default
|
397
|
+
snmpserver = SnmpServer.new
|
398
|
+
# default value is false
|
399
|
+
snmpserver.tcp_session_auth=false
|
400
|
+
device_enabled = snmpserver.tcp_session_auth?
|
401
|
+
s = @device.cmd("show run snmp all | no-more")
|
402
|
+
cmd='no snmp-server tcp-session auth'
|
403
|
+
line = /#{cmd}/.match(s)
|
404
|
+
assert_equal(line.nil?, device_enabled)
|
405
|
+
# set to default
|
406
|
+
snmpserver.tcp_session_auth=snmpserver.default_tcp_session_auth
|
407
|
+
end
|
408
|
+
|
409
|
+
def test_snmpserver_tcp_session_auth_get_enabled
|
410
|
+
snmpserver = SnmpServer.new
|
411
|
+
snmpserver.tcp_session_auth=true
|
412
|
+
device_enabled = snmpserver.tcp_session_auth?
|
413
|
+
cmd='^snmp-server tcp-session auth'
|
414
|
+
s = @device.cmd("show run snmp all | i '#{cmd}'")
|
415
|
+
assert_match(/#{cmd}/, s)
|
416
|
+
# set to default
|
417
|
+
snmpserver.tcp_session_auth=snmpserver.default_tcp_session_auth
|
418
|
+
end
|
419
|
+
|
420
|
+
def test_snmpserver_tcp_session_auth_set_enabled
|
421
|
+
snmpserver = SnmpServer.new
|
422
|
+
snmpserver.tcp_session_auth=true
|
423
|
+
s = @device.cmd("show run snmp all | no-more")
|
424
|
+
cmd='snmp-server tcp-session auth'
|
425
|
+
line = /#{cmd}/.match(s)
|
426
|
+
# puts "line : #{line}"
|
427
|
+
assert_equal(!line.nil?, true)
|
428
|
+
# set to default
|
429
|
+
snmpserver.tcp_session_auth=snmpserver.default_tcp_session_auth
|
430
|
+
end
|
431
|
+
|
432
|
+
def test_snmpserver_tcp_session_auth_set_default
|
433
|
+
snmpserver = SnmpServer.new
|
434
|
+
snmpserver.tcp_session_auth=false
|
435
|
+
s = @device.cmd("show run snmp all | no-more")
|
436
|
+
cmd='no snmp-server tcp-session auth'
|
437
|
+
line = /#{cmd}/.match(s)
|
438
|
+
# puts "line : #{line}"
|
439
|
+
assert_equal(line.nil?, false)
|
440
|
+
# set to default
|
441
|
+
snmpserver.tcp_session_auth=snmpserver.default_tcp_session_auth
|
442
|
+
end
|
443
|
+
end
|