cisco_node_utils 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/tests/test_snmpgroup.rb
CHANGED
@@ -20,12 +20,12 @@ class TestSnmpGroup < CiscoTestCase
|
|
20
20
|
@skip_unless_supported = 'snmp_group'
|
21
21
|
|
22
22
|
# NXOS snmp groups will not be empty
|
23
|
-
def
|
23
|
+
def test_collection_not_empty
|
24
24
|
snmpgroups = SnmpGroup.groups
|
25
25
|
refute_empty(snmpgroups)
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def test_collection_valid
|
29
29
|
snmpgroups = SnmpGroup.groups
|
30
30
|
s = @device.cmd('show snmp group | include Role | no-more')
|
31
31
|
snmpgroups.each_value do |snmpgroup|
|
@@ -35,13 +35,13 @@ class TestSnmpGroup < CiscoTestCase
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
38
|
+
def test_exists_with_name_empty
|
39
39
|
assert_raises(ArgumentError) do
|
40
40
|
SnmpGroup.exists?('')
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
44
|
+
def test_exists_with_name_invalid
|
45
45
|
name = 'group-dummy'
|
46
46
|
exist = SnmpGroup.exists?(name)
|
47
47
|
s = @device.cmd('show snmp group | in Role | no-more')
|
@@ -49,13 +49,13 @@ class TestSnmpGroup < CiscoTestCase
|
|
49
49
|
assert_equal(exist, !line.nil?)
|
50
50
|
end
|
51
51
|
|
52
|
-
def
|
52
|
+
def test_exists_with_name_bad_type
|
53
53
|
assert_raises(TypeError) do
|
54
54
|
SnmpGroup.exists?(:not_a_string)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
58
|
+
def test_exists_with_name_valid
|
59
59
|
name = 'network-admin'
|
60
60
|
exist = SnmpGroup.exists?(name)
|
61
61
|
s = @device.cmd('show snmp group | in Role | no-more')
|
@@ -63,7 +63,7 @@ class TestSnmpGroup < CiscoTestCase
|
|
63
63
|
assert_equal(exist, !line.nil?)
|
64
64
|
end
|
65
65
|
|
66
|
-
def
|
66
|
+
def test_get_name
|
67
67
|
name = 'network-operator'
|
68
68
|
snmpgroup = SnmpGroup.new(name)
|
69
69
|
assert_equal(snmpgroup.name, name)
|
data/tests/test_snmpserver.rb
CHANGED
@@ -32,309 +32,220 @@ class TestSnmpServer < CiscoTestCase
|
|
32
32
|
@default_show_command = 'show run snmp all | no-more'
|
33
33
|
# set all commands to defaults
|
34
34
|
s = SnmpServer.new
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
assert_raises(Cisco::CliError) do
|
47
|
-
snmpserver.aaa_user_cache_timeout = 86_401
|
35
|
+
if platform == :nexus
|
36
|
+
s.aaa_user_cache_timeout = s.default_aaa_user_cache_timeout
|
37
|
+
s.contact = s.default_contact
|
38
|
+
s.global_enforce_priv = s.default_global_enforce_priv
|
39
|
+
s.location = s.default_location
|
40
|
+
s.packet_size = 0
|
41
|
+
s.protocol = s.default_protocol
|
42
|
+
s.tcp_session_auth = s.default_tcp_session_auth
|
43
|
+
else
|
44
|
+
s.contact = s.default_contact
|
45
|
+
s.location = s.default_location
|
48
46
|
end
|
49
47
|
end
|
50
48
|
|
51
|
-
def
|
52
|
-
|
53
|
-
|
54
|
-
|
49
|
+
def test_aaa_user_cache_timeout
|
50
|
+
if validate_property_excluded?('snmp_server', 'aaa_user_cache_timeout')
|
51
|
+
assert_raises(Cisco::UnsupportedError) do
|
52
|
+
SnmpServer.new.aaa_user_cache_timeout = 1400
|
53
|
+
end
|
54
|
+
return
|
55
55
|
end
|
56
|
-
end
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
line = assert_show_match(
|
63
|
-
pattern: /snmp-server aaa-user cache-timeout (\d+)/)
|
64
|
-
timeout = line.to_s.split(' ').last.to_i
|
65
|
-
assert_equal(timeout, newtimeout)
|
66
|
-
# set to default
|
67
|
-
snmpserver.aaa_user_cache_timeout =
|
68
|
-
snmpserver.default_aaa_user_cache_timeout
|
69
|
-
end
|
57
|
+
s = SnmpServer.new
|
58
|
+
# initial
|
59
|
+
default = s.default_aaa_user_cache_timeout
|
60
|
+
assert_equal(default, s.aaa_user_cache_timeout)
|
70
61
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
snmpserver.default_aaa_user_cache_timeout
|
75
|
-
line = assert_show_match(
|
76
|
-
pattern: /snmp-server aaa-user cache-timeout (\d+)/)
|
77
|
-
timeout = line.to_s.split(' ').last.to_i
|
78
|
-
assert_equal(timeout, snmpserver.aaa_user_cache_timeout)
|
79
|
-
end
|
62
|
+
# non-default
|
63
|
+
s.aaa_user_cache_timeout = 1400
|
64
|
+
assert_equal(1400, s.aaa_user_cache_timeout)
|
80
65
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
pattern: /snmp-server aaa-user cache-timeout (\d+)/)
|
85
|
-
timeout = line.to_s.split(' ').last.to_i
|
86
|
-
assert_equal(timeout, snmpserver.aaa_user_cache_timeout)
|
87
|
-
end
|
66
|
+
# default
|
67
|
+
s.aaa_user_cache_timeout = default
|
68
|
+
assert_equal(default, s.aaa_user_cache_timeout)
|
88
69
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
line = assert_show_match(command: 'show snmp | no-more',
|
93
|
-
pattern: /sys contact: [^\n\r]+/)
|
94
|
-
contact = ''
|
95
|
-
contact = line.to_s.gsub('sys contact:', '').strip unless line.nil?
|
96
|
-
# puts "contact : #{line}, #{snmpserver.contact}"
|
97
|
-
assert_equal(contact, snmpserver.contact)
|
98
|
-
# set to default
|
99
|
-
snmpserver.contact = snmpserver.default_contact
|
70
|
+
# negative tests
|
71
|
+
assert_raises(Cisco::CliError) { s.aaa_user_cache_timeout = 86_401 }
|
72
|
+
assert_raises(Cisco::CliError) { s.aaa_user_cache_timeout = 0 }
|
100
73
|
end
|
101
74
|
|
102
|
-
def
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
end
|
75
|
+
def test_contact
|
76
|
+
s = SnmpServer.new
|
77
|
+
# initial
|
78
|
+
default = s.default_contact
|
79
|
+
assert_equal(default, s.contact)
|
108
80
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
snmpserver.contact = newcontact
|
113
|
-
assert_equal(newcontact, snmpserver.contact)
|
114
|
-
# set to default
|
115
|
-
snmpserver.contact = snmpserver.default_contact
|
116
|
-
end
|
81
|
+
# non-default
|
82
|
+
s.contact = 'minitest'
|
83
|
+
assert_equal('minitest', s.contact)
|
117
84
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
snmpserver.contact = snmpserver.default_contact
|
85
|
+
# default
|
86
|
+
s.contact = default
|
87
|
+
assert_equal(default, s.contact)
|
88
|
+
|
89
|
+
# empty
|
90
|
+
s.contact = ''
|
91
|
+
assert_equal('', s.contact)
|
92
|
+
|
93
|
+
# negative test
|
94
|
+
assert_raises(TypeError) { s.contact = 123 }
|
129
95
|
end
|
130
96
|
|
131
|
-
def
|
97
|
+
def test_contact_special_chars
|
132
98
|
snmpserver = SnmpServer.new
|
133
|
-
# newcontact = "Test{}(%tuvy@_cisco contact$#!@1234^&*()_+"
|
134
99
|
newcontact = 'user@example.com @$%&}test ]|[#_@test contact'
|
135
100
|
snmpserver.contact = newcontact
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
101
|
+
if platform == :nexus
|
102
|
+
line = assert_show_match(command: 'show snmp | no-more',
|
103
|
+
pattern: /sys contact: [^\n\r]+/)
|
104
|
+
# puts "line: #{line}"
|
105
|
+
contact = line.to_s.gsub('sys contact:', '').strip
|
106
|
+
else
|
107
|
+
line = assert_show_match(command: 'show running-config snmp-server',
|
108
|
+
pattern: /snmp-server contact [^\n\r]+/)
|
109
|
+
contact = ''
|
110
|
+
contact = line.to_s.gsub('snmp-server contact', '').strip unless line.nil?
|
111
|
+
end
|
140
112
|
assert_equal(contact, newcontact)
|
141
113
|
# set to default
|
142
114
|
snmpserver.contact = snmpserver.default_contact
|
143
115
|
end
|
144
116
|
|
145
|
-
def
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
contact = ''
|
151
|
-
contact = line.to_s.gsub('sys contact:', '').strip unless line.nil?
|
152
|
-
assert_equal(contact, snmpserver.default_contact)
|
153
|
-
end
|
117
|
+
def test_location
|
118
|
+
s = SnmpServer.new
|
119
|
+
# initial
|
120
|
+
default = s.default_location
|
121
|
+
assert_equal(default, s.location)
|
154
122
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
snmpserver.location = 'test-location'
|
159
|
-
line = assert_show_match(command: 'show snmp | no-more',
|
160
|
-
pattern: /sys location: [^\n\r]+/)
|
161
|
-
location = ''
|
162
|
-
location = line.to_s.gsub('sys location:', '').strip unless line.nil?
|
163
|
-
# puts "location : #{location}, #{snmpserver.location}"
|
164
|
-
assert_equal(location, snmpserver.location)
|
165
|
-
# set to default
|
166
|
-
snmpserver.location = snmpserver.default_location
|
167
|
-
end
|
123
|
+
# non-default
|
124
|
+
s.location = 'minitest'
|
125
|
+
assert_equal('minitest', s.location)
|
168
126
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
snmpserver.location = 123
|
173
|
-
end
|
174
|
-
end
|
127
|
+
# default
|
128
|
+
s.location = default
|
129
|
+
assert_equal(default, s.location)
|
175
130
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
snmpserver.location = newlocation
|
180
|
-
assert_equal(newlocation, snmpserver.location)
|
181
|
-
end
|
131
|
+
# empty
|
132
|
+
s.location = ''
|
133
|
+
assert_equal('', s.location)
|
182
134
|
|
183
|
-
|
184
|
-
|
185
|
-
newlocation = 'bxb-300-2-1 test location'
|
186
|
-
snmpserver.location = newlocation
|
187
|
-
line = assert_show_match(command: 'show snmp | no-more',
|
188
|
-
pattern: /sys location: [^\n\r]+/)
|
189
|
-
location = line.to_s.gsub('sys location:', '').strip
|
190
|
-
assert_equal(location, newlocation)
|
191
|
-
# set to default
|
192
|
-
snmpserver.location = snmpserver.default_location
|
135
|
+
# negative test
|
136
|
+
assert_raises(TypeError) { s.location = 123 }
|
193
137
|
end
|
194
138
|
|
195
|
-
def
|
139
|
+
def test_location_special_chars
|
196
140
|
snmpserver = SnmpServer.new
|
197
141
|
newlocation = 'bxb-300 2nd floor test !$%^33&&*) location'
|
198
142
|
snmpserver.location = newlocation
|
199
|
-
|
200
|
-
|
201
|
-
|
143
|
+
if platform == :nexus
|
144
|
+
line = assert_show_match(command: 'show snmp | no-more',
|
145
|
+
pattern: /sys location: [^\n\r]+/)
|
146
|
+
location = line.to_s.gsub('sys location:', '').strip
|
147
|
+
else
|
148
|
+
line = assert_show_match(command: 'show running-config snmp-server',
|
149
|
+
pattern: /snmp-server location [^\n\r]+/)
|
150
|
+
location = line.to_s.gsub('snmp-server location', '').strip
|
151
|
+
end
|
202
152
|
assert_equal(location, newlocation)
|
203
153
|
# set to default
|
204
154
|
snmpserver.location = snmpserver.default_location
|
205
155
|
end
|
206
156
|
|
207
|
-
def
|
208
|
-
|
209
|
-
|
210
|
-
snmpserver.location = 'FOO'
|
211
|
-
line = assert_show_match(command: 'show snmp | no-more',
|
212
|
-
pattern: /sys location: [^\n\r]+/)
|
213
|
-
location = ''
|
214
|
-
location = line.to_s.gsub('sys location:', '').strip unless line.nil?
|
215
|
-
assert_equal(location, snmpserver.location)
|
216
|
-
# set to default
|
217
|
-
snmpserver.location = snmpserver.default_location
|
218
|
-
end
|
219
|
-
|
220
|
-
def test_snmpserver_packetsize_get
|
221
|
-
snmpserver = SnmpServer.new
|
222
|
-
snmpserver.packet_size = 2000
|
223
|
-
line = assert_show_match(pattern: /snmp-server packetsize (\d+)/)
|
224
|
-
packetsize = 0
|
225
|
-
packetsize = line.to_s.split(' ').last.to_i unless line.nil?
|
226
|
-
assert_equal(packetsize, snmpserver.packet_size)
|
227
|
-
# unset to default
|
228
|
-
snmpserver.packet_size = 0
|
229
|
-
end
|
157
|
+
def test_packet_size
|
158
|
+
skip_legacy_defect?('7.0.3.I2.2e|7.0.3.I3.1',
|
159
|
+
'CSCuz14217: CLI shows default snmp packet-size incorrectly as 0')
|
230
160
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
161
|
+
if validate_property_excluded?('snmp_server', 'packet_size')
|
162
|
+
assert_raises(Cisco::UnsupportedError) do
|
163
|
+
SnmpServer.new.packet_size = 2000
|
164
|
+
end
|
165
|
+
return
|
236
166
|
end
|
167
|
+
|
168
|
+
s = SnmpServer.new
|
169
|
+
# initial
|
170
|
+
default = s.default_packet_size
|
171
|
+
assert_equal(default, s.packet_size)
|
172
|
+
|
173
|
+
# non-default
|
174
|
+
s.packet_size = 1400
|
175
|
+
assert_equal(1400, s.packet_size)
|
176
|
+
|
177
|
+
# default
|
178
|
+
s.packet_size = default
|
179
|
+
assert_equal(default, s.packet_size)
|
180
|
+
|
181
|
+
# negative tests
|
182
|
+
assert_raises(Cisco::CliError) { s.packet_size = 17_383 } # upper bound
|
183
|
+
assert_raises(Cisco::CliError) { s.packet_size = 480 } # lower bound
|
237
184
|
end
|
238
185
|
|
239
|
-
def
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
186
|
+
def test_global_enforce_priv
|
187
|
+
if validate_property_excluded?('snmp_server', 'global_enforce_priv')
|
188
|
+
assert_raises(Cisco::UnsupportedError) do
|
189
|
+
SnmpServer.new.global_enforce_priv = true
|
190
|
+
end
|
191
|
+
return
|
244
192
|
end
|
245
|
-
end
|
246
193
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
line = assert_show_match(pattern: /snmp-server packetsize (\d+)/)
|
252
|
-
packetsize = line.to_s.split(' ').last.to_i
|
253
|
-
assert_equal(packetsize, newpacketsize)
|
254
|
-
# unset to default
|
255
|
-
snmpserver.packet_size = 0
|
256
|
-
end
|
194
|
+
s = SnmpServer.new
|
195
|
+
# initial
|
196
|
+
default = s.default_global_enforce_priv
|
197
|
+
assert_equal(default, s.global_enforce_priv?)
|
257
198
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
line = assert_show_match(pattern: /snmp-server packetsize (\d+)/)
|
266
|
-
packetsize = line.to_s.split(' ').last.to_i
|
267
|
-
assert_equal(packetsize, snmpserver.packet_size,
|
268
|
-
'Error: Snmp Server, packet size not default')
|
269
|
-
|
270
|
-
snmpserver.packet_size = snmpserver.default_packet_size
|
271
|
-
# TODO: this seems weird, why is default_packet_size not 0 as above?
|
272
|
-
line = assert_show_match(pattern: /snmp-server packetsize (\d+)/)
|
273
|
-
packetsize = line.to_s.split(' ').last.to_i
|
274
|
-
assert_equal(packetsize, snmpserver.packet_size,
|
275
|
-
'Error: Snmp Server, packet size not default')
|
276
|
-
# set to default
|
277
|
-
snmpserver.packet_size = 0
|
199
|
+
# non-default
|
200
|
+
s.global_enforce_priv = !default
|
201
|
+
assert_equal(!default, s.global_enforce_priv?)
|
202
|
+
|
203
|
+
# default
|
204
|
+
s.global_enforce_priv = default
|
205
|
+
assert_equal(default, s.global_enforce_priv?)
|
278
206
|
end
|
279
207
|
|
280
|
-
def
|
281
|
-
|
208
|
+
def test_protocol
|
209
|
+
if validate_property_excluded?('snmp_server', 'protocol')
|
210
|
+
assert_raises(Cisco::UnsupportedError) do
|
211
|
+
SnmpServer.new.protocol = true
|
212
|
+
end
|
213
|
+
return
|
214
|
+
end
|
282
215
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
assert_equal(0, snmpserver.packet_size,
|
288
|
-
'Error: Snmp Server, packet size not unset')
|
289
|
-
|
290
|
-
# Restore packet size
|
291
|
-
snmpserver.packet_size = org_packet_size
|
292
|
-
assert_equal(org_packet_size, snmpserver.packet_size,
|
293
|
-
'Error: Snmp Server, packet size not restored')
|
294
|
-
# set to default
|
295
|
-
snmpserver.packet_size = 0
|
296
|
-
end
|
216
|
+
s = SnmpServer.new
|
217
|
+
# initial
|
218
|
+
default = s.default_protocol
|
219
|
+
assert_equal(default, s.protocol?)
|
297
220
|
|
298
|
-
|
299
|
-
|
300
|
-
default
|
301
|
-
snmpserver.global_enforce_priv = default
|
302
|
-
if default == true
|
303
|
-
assert_show_match(pattern: /^snmp-server globalEnforcePriv/)
|
304
|
-
assert(snmpserver.global_enforce_priv?)
|
305
|
-
|
306
|
-
snmpserver.global_enforce_priv = false
|
307
|
-
assert_show_match(pattern: /^no snmp-server globalEnforcePriv/)
|
308
|
-
refute(snmpserver.global_enforce_priv?)
|
309
|
-
else
|
310
|
-
assert_show_match(pattern: /^no snmp-server globalEnforcePriv/)
|
311
|
-
refute(snmpserver.global_enforce_priv?)
|
221
|
+
# non-default
|
222
|
+
s.protocol = !default
|
223
|
+
assert_equal(!default, s.protocol?)
|
312
224
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
end
|
317
|
-
# Cleanup
|
318
|
-
snmpserver.global_enforce_priv = snmpserver.default_global_enforce_priv
|
225
|
+
# default
|
226
|
+
s.protocol = default
|
227
|
+
assert_equal(default, s.protocol?)
|
319
228
|
end
|
320
229
|
|
321
|
-
def
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
snmpserver.protocol?)
|
329
|
-
end
|
230
|
+
def test_tcp_session_auth
|
231
|
+
if validate_property_excluded?('snmp_server', 'tcp_session_auth')
|
232
|
+
assert_raises(Cisco::UnsupportedError) do
|
233
|
+
SnmpServer.new.tcp_session_auth = true
|
234
|
+
end
|
235
|
+
return
|
236
|
+
end
|
330
237
|
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
assert_equal(
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
238
|
+
s = SnmpServer.new
|
239
|
+
# initial
|
240
|
+
default = s.default_tcp_session_auth
|
241
|
+
assert_equal(default, s.tcp_session_auth?)
|
242
|
+
|
243
|
+
# non-default
|
244
|
+
s.tcp_session_auth = !default
|
245
|
+
assert_equal(!default, s.tcp_session_auth?)
|
246
|
+
|
247
|
+
# default
|
248
|
+
s.tcp_session_auth = default
|
249
|
+
assert_equal(default, s.tcp_session_auth?)
|
339
250
|
end
|
340
251
|
end
|