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.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +66 -0
  4. data/Gemfile +1 -0
  5. data/README.md +44 -43
  6. data/bin/.rubocop.yml +18 -0
  7. data/bin/show_running_yang.rb +233 -0
  8. data/cisco_node_utils.gemspec +1 -1
  9. data/docs/README-maintainers.md +1 -0
  10. data/docs/README-utilities.md +14 -0
  11. data/lib/.rubocop.yml +1 -1
  12. data/lib/cisco_node_utils/aaa_authentication_login_service.rb +8 -3
  13. data/lib/cisco_node_utils/aaa_authorization_service.rb +6 -0
  14. data/lib/cisco_node_utils/bfd_global.rb +300 -0
  15. data/lib/cisco_node_utils/bgp.rb +6 -4
  16. data/lib/cisco_node_utils/bgp_af.rb +2 -0
  17. data/lib/cisco_node_utils/bgp_neighbor.rb +14 -0
  18. data/lib/cisco_node_utils/bgp_neighbor_af.rb +4 -1
  19. data/lib/cisco_node_utils/cisco_cmn_utils.rb +126 -0
  20. data/lib/cisco_node_utils/client/client.rb +6 -2
  21. data/lib/cisco_node_utils/client/grpc/client.rb +120 -36
  22. data/lib/cisco_node_utils/client/nxapi/client.rb +6 -2
  23. data/lib/cisco_node_utils/cmd_ref/DEPRECATED.yaml +118 -0
  24. data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +14 -0
  25. data/lib/cisco_node_utils/cmd_ref/bfd_global.yaml +117 -0
  26. data/lib/cisco_node_utils/cmd_ref/bgp.yaml +7 -7
  27. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +7 -0
  28. data/lib/cisco_node_utils/cmd_ref/dhcp_relay_global.yaml +125 -0
  29. data/lib/cisco_node_utils/cmd_ref/feature.yaml +10 -0
  30. data/lib/cisco_node_utils/cmd_ref/interface.yaml +141 -49
  31. data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +44 -0
  32. data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +6 -0
  33. data/lib/cisco_node_utils/cmd_ref/ospf.yaml +6 -0
  34. data/lib/cisco_node_utils/cmd_ref/ospf_area.yaml +91 -0
  35. data/lib/cisco_node_utils/cmd_ref/ospf_area_vlink.yaml +88 -0
  36. data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +0 -3
  37. data/lib/cisco_node_utils/cmd_ref/show_version.yaml +3 -3
  38. data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +39 -15
  39. data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +43 -21
  40. data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +48 -19
  41. data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +0 -0
  42. data/lib/cisco_node_utils/cmd_ref/tacacs_global.yaml +30 -0
  43. data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +18 -6
  44. data/lib/cisco_node_utils/cmd_ref/vdc.yaml +4 -0
  45. data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +1 -0
  46. data/lib/cisco_node_utils/cmd_ref/vlan.yaml +23 -10
  47. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +8 -2
  48. data/lib/cisco_node_utils/cmd_ref/yang.yaml +7 -0
  49. data/lib/cisco_node_utils/cmd_ref/yum.yaml +10 -1
  50. data/lib/cisco_node_utils/constants.rb +8 -1
  51. data/lib/cisco_node_utils/dhcp_relay_global.rb +302 -0
  52. data/lib/cisco_node_utils/exceptions.rb +29 -0
  53. data/lib/cisco_node_utils/feature.rb +28 -0
  54. data/lib/cisco_node_utils/interface.rb +493 -402
  55. data/lib/cisco_node_utils/interface_DEPRECATED.rb +513 -0
  56. data/lib/cisco_node_utils/interface_ospf.rb +126 -0
  57. data/lib/cisco_node_utils/interface_portchannel.rb +16 -0
  58. data/lib/cisco_node_utils/logger.rb +3 -0
  59. data/lib/cisco_node_utils/node.rb +29 -1
  60. data/lib/cisco_node_utils/overlay_global.rb +1 -12
  61. data/lib/cisco_node_utils/pim.rb +1 -0
  62. data/lib/cisco_node_utils/pim_group_list.rb +1 -0
  63. data/lib/cisco_node_utils/pim_rp_address.rb +1 -0
  64. data/lib/cisco_node_utils/platform.rb +9 -2
  65. data/lib/cisco_node_utils/router_ospf.rb +1 -1
  66. data/lib/cisco_node_utils/router_ospf_area.rb +416 -0
  67. data/lib/cisco_node_utils/router_ospf_area_vlink.rb +313 -0
  68. data/lib/cisco_node_utils/router_ospf_vrf.rb +17 -0
  69. data/lib/cisco_node_utils/snmp_notification_receiver.rb +27 -9
  70. data/lib/cisco_node_utils/snmpcommunity.rb +34 -8
  71. data/lib/cisco_node_utils/snmpserver.rb +4 -4
  72. data/lib/cisco_node_utils/snmpuser.rb +0 -0
  73. data/lib/cisco_node_utils/tacacs_global.rb +102 -0
  74. data/lib/cisco_node_utils/tacacs_server.rb +8 -7
  75. data/lib/cisco_node_utils/vdc.rb +25 -7
  76. data/lib/cisco_node_utils/version.rb +1 -1
  77. data/lib/cisco_node_utils/vlan.rb +30 -56
  78. data/lib/cisco_node_utils/vlan_DEPRECATED.rb +108 -0
  79. data/lib/cisco_node_utils/yang.rb +160 -0
  80. data/lib/cisco_node_utils/yum.rb +25 -32
  81. data/tests/.rubocop.yml +3 -0
  82. data/tests/ciscotest.rb +136 -19
  83. data/tests/cmd_config_invalid.yaml +1 -1
  84. data/tests/noop.rb +7 -0
  85. data/tests/tacacs_server.yaml.example +6 -0
  86. data/tests/test_aaa_authentication_login.rb +24 -1
  87. data/tests/test_aaa_authentication_login_service.rb +9 -16
  88. data/tests/test_aaa_authorization_service.rb +111 -84
  89. data/tests/test_bfd_global.rb +278 -0
  90. data/tests/test_bgp_neighbor.rb +20 -0
  91. data/tests/test_bridge_domain_vni.rb +2 -9
  92. data/tests/test_cmn_utils.rb +76 -0
  93. data/tests/test_dhcp_relay_global.rb +284 -0
  94. data/tests/test_dns_domain.rb +4 -4
  95. data/tests/test_domain_name.rb +2 -2
  96. data/tests/test_encapsulation.rb +2 -4
  97. data/tests/test_evpn_vni.rb +14 -7
  98. data/tests/test_fabricpath_global.rb +12 -13
  99. data/tests/test_feature.rb +35 -17
  100. data/tests/test_interface.rb +352 -127
  101. data/tests/test_interface_bdi.rb +2 -2
  102. data/tests/test_interface_channel_group.rb +1 -1
  103. data/tests/test_interface_ospf.rb +153 -23
  104. data/tests/test_interface_portchannel.rb +15 -6
  105. data/tests/test_interface_private_vlan.rb +200 -576
  106. data/tests/test_interface_svi.rb +5 -52
  107. data/tests/test_interface_switchport.rb +80 -240
  108. data/tests/test_itd_device_group.rb +2 -2
  109. data/tests/test_itd_device_group_node.rb +2 -2
  110. data/tests/test_itd_service.rb +1 -1
  111. data/tests/test_name_server.rb +3 -3
  112. data/tests/test_node_ext.rb +15 -17
  113. data/tests/test_ntp_config.rb +1 -1
  114. data/tests/test_ntp_server.rb +3 -3
  115. data/tests/test_nxapi.rb +1 -0
  116. data/tests/test_overlay_global.rb +15 -19
  117. data/tests/test_pim.rb +5 -5
  118. data/tests/test_pim_group_list.rb +1 -37
  119. data/tests/test_pim_rp_address.rb +1 -1
  120. data/tests/test_platform.rb +9 -11
  121. data/tests/test_portchannel_global.rb +43 -3
  122. data/tests/test_radius_server.rb +1 -1
  123. data/tests/test_radius_server_group.rb +1 -1
  124. data/tests/test_router_bgp.rb +17 -30
  125. data/tests/test_router_ospf_area.rb +433 -0
  126. data/tests/test_router_ospf_area_vlink.rb +298 -0
  127. data/tests/test_router_ospf_vrf.rb +17 -0
  128. data/tests/test_snmp_notification_receiver.rb +11 -11
  129. data/tests/test_snmpcommunity.rb +177 -69
  130. data/tests/test_snmpgroup.rb +7 -7
  131. data/tests/test_snmpserver.rb +164 -253
  132. data/tests/test_snmpuser.rb +73 -69
  133. data/tests/test_stp_global.rb +15 -15
  134. data/tests/test_syslog_settings.rb +1 -1
  135. data/tests/test_tacacs_global.rb +80 -0
  136. data/tests/test_tacacs_server.rb +129 -51
  137. data/tests/test_tacacs_server_group.rb +3 -29
  138. data/tests/test_tacacs_server_host.rb +24 -27
  139. data/tests/test_vlan.rb +57 -59
  140. data/tests/test_vlan_private.rb +271 -284
  141. data/tests/test_vpc.rb +10 -4
  142. data/tests/test_vrf.rb +2 -0
  143. data/tests/test_vrf_af.rb +2 -5
  144. data/tests/test_vtp.rb +5 -2
  145. data/tests/test_vxlan_vtep.rb +20 -44
  146. data/tests/test_vxlan_vtep_vni.rb +23 -16
  147. data/tests/test_yang.rb +369 -0
  148. data/tests/test_yum.rb +34 -42
  149. data/tests/yum_package.yaml +35 -0
  150. metadata +31 -4
  151. data/tests/test_vlan_mt_full.rb +0 -85
@@ -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 test_snmpgroup_collection_not_empty
23
+ def test_collection_not_empty
24
24
  snmpgroups = SnmpGroup.groups
25
25
  refute_empty(snmpgroups)
26
26
  end
27
27
 
28
- def test_snmpgroup_collection_valid
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 test_snmpgroup_exists_with_name_empty
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 test_snmpgroup_exists_with_name_invalid
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 test_snmpgroup_exists_with_name_bad_type
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 test_snmpgroup_exists_with_name_valid
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 test_snmpgroup_get_name
66
+ def test_get_name
67
67
  name = 'network-operator'
68
68
  snmpgroup = SnmpGroup.new(name)
69
69
  assert_equal(snmpgroup.name, name)
@@ -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
- s.aaa_user_cache_timeout = s.default_aaa_user_cache_timeout
36
- s.contact = s.default_contact
37
- s.global_enforce_priv = s.default_global_enforce_priv
38
- s.location = s.default_location
39
- s.packet_size = 0
40
- s.protocol = s.default_protocol
41
- s.tcp_session_auth = s.default_tcp_session_auth
42
- end
43
-
44
- def test_snmpserver_aaa_user_cache_timeout_set_invalid_upper_range
45
- snmpserver = SnmpServer.new
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 test_snmpserver_aaa_user_cache_timeout_set_invalid_lower_range
52
- snmpserver = SnmpServer.new
53
- assert_raises(Cisco::CliError) do
54
- snmpserver.aaa_user_cache_timeout = 0
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
- def test_snmpserver_aaa_user_cache_timeout_set_valid
59
- snmpserver = SnmpServer.new
60
- newtimeout = 1400
61
- snmpserver.aaa_user_cache_timeout = newtimeout
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
- def test_snmpserver_aaa_user_cache_timeout_set_default_valid
72
- snmpserver = SnmpServer.new
73
- snmpserver.aaa_user_cache_timeout =
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
- def test_snmpserver_aaa_user_cache_timeout_get
82
- snmpserver = SnmpServer.new
83
- line = assert_show_match(
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
- def test_snmpserver_sys_contact_get
90
- snmpserver = SnmpServer.new
91
- snmpserver.contact = 'test-contact'
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 test_snmpserver_sys_contact_set_invalid
103
- snmpserver = SnmpServer.new
104
- assert_raises(TypeError) do
105
- snmpserver.contact = 123
106
- end
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
- def test_snmpserver_sys_contact_set_zero_length
110
- snmpserver = SnmpServer.new
111
- newcontact = ''
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
- def test_snmpserver_sys_contact_set_valid
119
- snmpserver = SnmpServer.new
120
- newcontact = 'mvenkata_test# contact'
121
- snmpserver.contact = newcontact
122
- line = assert_show_match(command: 'show snmp | no-more',
123
- pattern: /sys contact: [^\n\r]+/)
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
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 test_snmpserver_sys_contact_set_special_chars
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
- line = assert_show_match(command: 'show snmp | no-more',
137
- pattern: /sys contact: [^\n\r]+/)
138
- # puts "line: #{line}"
139
- contact = line.to_s.gsub('sys contact:', '').strip
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 test_snmpserver_sys_contact_set_default
146
- snmpserver = SnmpServer.new
147
- snmpserver.contact = snmpserver.default_contact
148
- line = assert_show_match(command: 'show snmp | no-more',
149
- pattern: /sys contact: [^\n\r]*/)
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
- def test_snmpserver_sys_location_get
156
- snmpserver = SnmpServer.new
157
- # set location
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
- def test_snmpserver_sys_location_set_invalid
170
- snmpserver = SnmpServer.new
171
- assert_raises(TypeError) do
172
- snmpserver.location = 123
173
- end
174
- end
127
+ # default
128
+ s.location = default
129
+ assert_equal(default, s.location)
175
130
 
176
- def test_snmpserver_sys_location_set_zero_length
177
- snmpserver = SnmpServer.new
178
- newlocation = ''
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
- def test_snmpserver_sys_location_set_valid
184
- snmpserver = SnmpServer.new
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 test_snmpserver_sys_location_set_special_chars
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
- line = assert_show_match(command: 'show snmp | no-more',
200
- pattern: /sys location: [^\n\r]+/)
201
- location = line.to_s.gsub('sys location:', '').strip
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 test_snmpserver_sys_location_set_default
208
- snmpserver = SnmpServer.new
209
- # snmpserver.location = snmpserver.default_location
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
- def test_snmpserver_packetsize_set_invalid_upper_range
232
- snmpserver = SnmpServer.new
233
- newpacketsize = 17_383
234
- assert_raises(Cisco::CliError) do
235
- snmpserver.packet_size = newpacketsize
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 test_snmpserver_packetsize_set_invalid_lower_range
240
- snmpserver = SnmpServer.new
241
- newpacketsize = 480
242
- assert_raises(Cisco::CliError) do
243
- snmpserver.packet_size = newpacketsize
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
- def test_snmpserver_packetsize_set_valid
248
- snmpserver = SnmpServer.new
249
- newpacketsize = 1600
250
- snmpserver.packet_size = newpacketsize
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
- def test_snmpserver_packetsize_set_default
259
- snmpserver = SnmpServer.new
260
- refute_show_match(pattern: /snmp-server packetsize (\d+)/)
261
- assert_equal(0, snmpserver.packet_size,
262
- 'Error: Snmp Server, packet size not default')
263
-
264
- snmpserver.packet_size = 850
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 test_snmpserver_packetsize_unset
281
- snmpserver = SnmpServer.new
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
- # Get orginal packet size
284
- org_packet_size = snmpserver.packet_size
285
- snmpserver.packet_size = 0
286
- refute_show_match(pattern: /snmp-server packetsize (\d+)/)
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
- def test_snmpserver_global_enforce_priv
299
- snmpserver = SnmpServer.new
300
- default = snmpserver.default_global_enforce_priv
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
- snmpserver.global_enforce_priv = true
314
- assert_show_match(pattern: /^snmp-server globalEnforcePriv/)
315
- assert(snmpserver.global_enforce_priv?)
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 test_snmpserver_protocol_get_set
322
- snmpserver = SnmpServer.new
323
- snmpserver.protocol = false
324
- assert_equal(false, snmpserver.protocol?)
325
- snmpserver.protocol =
326
- snmpserver.default_protocol
327
- assert_equal(snmpserver.default_protocol,
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
- def test_snmpserver_tcp_session_auth_get_set
332
- snmpserver = SnmpServer.new
333
- snmpserver.tcp_session_auth = false
334
- assert_equal(false, snmpserver.tcp_session_auth?)
335
- snmpserver.tcp_session_auth =
336
- snmpserver.default_tcp_session_auth
337
- assert_equal(snmpserver.default_tcp_session_auth,
338
- snmpserver.tcp_session_auth?)
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