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
@@ -14,6 +14,7 @@
14
14
 
15
15
  require_relative 'ciscotest'
16
16
  require_relative '../lib/cisco_node_utils/snmpuser'
17
+ require 'pry'
17
18
 
18
19
  DEFAULT_SNMP_USER_AUTH_PASSWORD = ''
19
20
  DEFAULT_SNMP_USER_PRIV_PASSWORD = ''
@@ -23,13 +24,13 @@ DEFAULT_SNMP_USER_GROUP_NAME = 'network-operator'
23
24
  class TestSnmpUser < CiscoTestCase
24
25
  @skip_unless_supported = 'snmp_user'
25
26
 
26
- @@existing_users = nil # rubocop:disable Style/ClassVars
27
+ @@current_users = nil # rubocop:disable Style/ClassVars
27
28
 
28
29
  def setup
29
30
  super
30
31
  @test_users = []
31
32
  # Get the list of users that exist on the node when we first begin
32
- @@existing_users ||= SnmpUser.users.keys # rubocop:disable Style/ClassVars
33
+ @@current_users = SnmpUser.users if @@current_users.nil? # rubocop:disable Style/ClassVars
33
34
  end
34
35
 
35
36
  def create_user(name, opts='')
@@ -42,21 +43,40 @@ class TestSnmpUser < CiscoTestCase
42
43
  user.destroy
43
44
  end
44
45
 
45
- def teardown
46
- unless @test_users.empty?
47
- cfg = @test_users.collect { |name| "no snmp-server user #{name}" }
48
- config(*cfg)
46
+ def remove_test_users
47
+ SnmpUser.users.values.each do |obj|
48
+ # Delete users that are in current but also added by these tests.
49
+ if @@current_users.keys.include?(obj.name) && @test_users.include?(obj.name)
50
+ obj.destroy
51
+ # Delete users that are part of test.
52
+ elsif @test_users.include? obj.name
53
+ obj.destroy
54
+ # Do not delete users in current but not in test.
55
+ elsif @@current_users.keys.include? obj.name
56
+ next
57
+ else
58
+ # Delete if not in current or test.
59
+ obj.destroy
60
+ end
49
61
  end
62
+ end
63
+
64
+ def teardown
65
+ # This teardown tries to preserve any non-test snmp-server user entries
66
+ # and only teardown the entries added by this test.
67
+ remove_test_users
50
68
  super
51
- delta = SnmpUser.users.keys - @@existing_users
52
- # User deletion can take some time, for some reason
69
+ delta = SnmpUser.users.keys - @@current_users.keys
53
70
  unless delta.empty?
54
- sleep(5)
55
- node.cache_flush
56
- delta = SnmpUser.users.keys - @@existing_users
71
+ # Some platforms are slow, wait for snmp-server user entries to be deleted
72
+ 15.times do
73
+ sleep(1)
74
+ node.cache_flush
75
+ delta = SnmpUser.users.keys - @@current_users.keys
76
+ break if delta.empty?
77
+ end
57
78
  end
58
- @@existing_users = SnmpUser.users.keys # rubocop:disable Style/ClassVars
59
- assert_empty(delta, 'Users not deleted after test!')
79
+ assert_empty(delta, 'teardown method did not clean up all users')
60
80
  end
61
81
 
62
82
  def user_pat(name, group='network-admin')
@@ -65,13 +85,13 @@ class TestSnmpUser < CiscoTestCase
65
85
 
66
86
  ## test cases starts here
67
87
 
68
- def test_snmpuser_collection_not_empty
88
+ def test_collection_not_empty
69
89
  create_user('tester')
70
90
  refute_empty(SnmpUser.users,
71
91
  'SnmpUser collection is empty')
72
92
  end
73
93
 
74
- def test_snmpuser_create_invalid_args
94
+ def test_create_invalid_args
75
95
  args_list = [
76
96
  ['Empty name',
77
97
  ['', ['network-admin'],
@@ -91,17 +111,13 @@ class TestSnmpUser < CiscoTestCase
91
111
  end
92
112
  end
93
113
 
94
- def test_snmpuser_create_invalid_cli
114
+ def test_create_invalid_cli
95
115
  args_list = [
96
116
  ['Cleartext password with localized key',
97
117
  ['userv3testauthsha1', ['network-admin'],
98
118
  :sha, 'test123456', :none, '', true, # localized key
99
119
  ''],
100
120
  ],
101
- ['NX-OS Password must be at least 8 characters',
102
- ['userv3testauthsha2', ['network-admin'],
103
- :sha, 'test', :none, '', false, ''],
104
- ],
105
121
  ['Invalid group name',
106
122
  ['userv3test', ['network-admin123'],
107
123
  :none, '', :none, '', false, ''],
@@ -135,7 +151,7 @@ class TestSnmpUser < CiscoTestCase
135
151
  assert(found_tester2)
136
152
  end
137
153
 
138
- def test_snmpuser_create_with_single_group_noauth_nopriv
154
+ def test_noauth_nopriv
139
155
  name = 'userv3test2'
140
156
  groups = ['network-admin']
141
157
  snmpuser = SnmpUser.new(name,
@@ -149,7 +165,7 @@ class TestSnmpUser < CiscoTestCase
149
165
  snmpuser.destroy
150
166
  end
151
167
 
152
- def test_snmpuser_create_with_multi_group_noauth_nopriv
168
+ def test_noauth_nopriv_multi
153
169
  name = 'userv3test3'
154
170
  groups = ['network-admin', 'vdc-admin']
155
171
  snmpuser = SnmpUser.new(name,
@@ -165,7 +181,7 @@ class TestSnmpUser < CiscoTestCase
165
181
  snmpuser.destroy
166
182
  end
167
183
 
168
- def test_snmpuser_destroy
184
+ def test_destroy
169
185
  name = 'userv3testdestroy'
170
186
  group = 'network-operator'
171
187
  create_user(name, group)
@@ -184,7 +200,7 @@ class TestSnmpUser < CiscoTestCase
184
200
  assert_nil(SnmpUser.users[name])
185
201
  end
186
202
 
187
- def test_snmpuser_auth_password_equal_invalid_param
203
+ def test_auth_pw_equal_invalid_param
188
204
  name = 'testV3PwEqualInvalid2'
189
205
  auth_pw = 'TeSt297534'
190
206
  create_user(name, "network-admin auth md5 #{auth_pw}")
@@ -193,7 +209,7 @@ class TestSnmpUser < CiscoTestCase
193
209
  refute(SnmpUser.users[name].auth_password_equal?('', false))
194
210
  end
195
211
 
196
- def test_snmpuser_auth_priv_password_equal_invalid_param
212
+ def test_auth_priv_pw_equal_invalid_param
197
213
  name = 'testV3PwEqualInvalid'
198
214
  auth_pw = 'XXWWPass0wrf'
199
215
  create_user(name, "network-admin auth md5 #{auth_pw} priv #{auth_pw}")
@@ -204,7 +220,7 @@ class TestSnmpUser < CiscoTestCase
204
220
  refute(snmpuser.priv_password_equal?('', false))
205
221
  end
206
222
 
207
- def test_snmpuser_auth_password_equal_priv_invalid_param
223
+ def test_auth_pw_equal_priv_invalid_param
208
224
  name = 'testV3PwEqualInvalid'
209
225
  auth_pw = 'XXWWPass0wrf'
210
226
  create_user(name, "network-operator auth md5 #{auth_pw} priv #{auth_pw}")
@@ -215,7 +231,7 @@ class TestSnmpUser < CiscoTestCase
215
231
  refute(snmpuser.priv_password_equal?('', false))
216
232
  end
217
233
 
218
- def test_snmpuser_auth_password_not_equal
234
+ def test_auth_pw_not_equal
219
235
  name = 'testV3PwEqual'
220
236
  auth_pw = 'xxwwpass0r!f'
221
237
  create_user(name, "network-admin auth md5 #{auth_pw}")
@@ -225,7 +241,7 @@ class TestSnmpUser < CiscoTestCase
225
241
  refute(snmpuser.auth_password_equal?('xxwwpass0r!', false))
226
242
  end
227
243
 
228
- def test_snmpuser_auth_password_equal
244
+ def test_auth_pw_equal
229
245
  name = 'testV3PwEqual'
230
246
  auth_pw = 'XXWWPass0wrf'
231
247
  create_user(name, "network-admin auth md5 #{auth_pw}")
@@ -234,7 +250,7 @@ class TestSnmpUser < CiscoTestCase
234
250
  assert(SnmpUser.users[name].auth_password_equal?(auth_pw, false))
235
251
  end
236
252
 
237
- def test_snmpuser_auth_priv_password_equal_empty
253
+ def test_auth_priv_pw_equal_empty
238
254
  name = 'testV3PwEmpty'
239
255
  create_user(name, 'network-admin')
240
256
  # nil and "" are treated interchangeably
@@ -244,7 +260,7 @@ class TestSnmpUser < CiscoTestCase
244
260
  assert(SnmpUser.users[name].priv_password_equal?(nil, false))
245
261
  end
246
262
 
247
- def test_snmpuser_auth_password_equal_localizedkey
263
+ def test_auth_pw_equal_localizedkey
248
264
  name = 'testV3PwEqual'
249
265
  auth_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
250
266
  create_user(name, "network-admin auth md5 #{auth_pw} localizedkey")
@@ -256,7 +272,7 @@ class TestSnmpUser < CiscoTestCase
256
272
  refute(snmpuser.auth_password_equal?('0xFe6c', true))
257
273
  end
258
274
 
259
- def test_snmpuser_auth_priv_password_equal_localizedkey
275
+ def test_auth_priv_pw_equal_localizedkey
260
276
  name = 'testV3PwEqual'
261
277
  auth_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
262
278
  priv_pw = '0x29916eac22d90362598abef1b9045018'
@@ -270,7 +286,7 @@ class TestSnmpUser < CiscoTestCase
270
286
  refute(snmpuser.priv_password_equal?('0x2291', true))
271
287
  end
272
288
 
273
- def test_snmpuser_auth_priv_des_password_equal
289
+ def test_auth_priv_des_pw_equal
274
290
  name = 'testV3PwEqual'
275
291
  auth_pw = 'XXWWPass0wrf'
276
292
  priv_pw = 'WWXXPaas0wrf'
@@ -282,7 +298,7 @@ class TestSnmpUser < CiscoTestCase
282
298
  assert(snmpuser.priv_password_equal?(priv_pw, false))
283
299
  end
284
300
 
285
- def test_snmpuser_create_with_single_group_auth_md5_nopriv
301
+ def test_auth_md5_nopriv
286
302
  name = 'userv3test5'
287
303
  groups = ['network-admin']
288
304
  auth_pw = 'XXWWPass0wrf'
@@ -298,7 +314,7 @@ class TestSnmpUser < CiscoTestCase
298
314
  snmpuser.destroy
299
315
  end
300
316
 
301
- def test_snmpuser_create_with_single_group_auth_md5_nopriv_pw_localized
317
+ def test_auth_md5_nopriv_pw_localized
302
318
  name = 'userv3testauth'
303
319
  groups = ['network-admin']
304
320
  auth_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
@@ -316,7 +332,7 @@ class TestSnmpUser < CiscoTestCase
316
332
  snmpuser.destroy
317
333
  end
318
334
 
319
- def test_snmpuser_create_with_single_group_auth_sha_nopriv
335
+ def test_auth_sha_nopriv
320
336
  name = 'userv3testsha'
321
337
  groups = ['network-admin']
322
338
  auth_pw = 'XXWWPass0wrf'
@@ -334,7 +350,7 @@ class TestSnmpUser < CiscoTestCase
334
350
 
335
351
  # If the auth pw is in hex and localized key param in constructor is false,
336
352
  # then the pw got localized by the device again.
337
- def test_create_1_group_auth_sha_nopriv_pw_localized_localizedkey_false
353
+ def test_auth_sha_nopriv_pw_localized_false
338
354
  name = 'userv3testauthsha3'
339
355
  groups = ['network-admin']
340
356
  auth_pw = '0xFe6cf9aea159c2c38e0a79ec23ed3cbb'
@@ -351,7 +367,7 @@ class TestSnmpUser < CiscoTestCase
351
367
  snmpuser.destroy
352
368
  end
353
369
 
354
- def test_snmpuser_create_with_single_group_auth_sha_nopriv_pw_localized
370
+ def test_auth_sha_nopriv_pw_localized
355
371
  name = 'userv3testauthsha4'
356
372
  groups = ['network-admin']
357
373
  auth_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
@@ -367,7 +383,7 @@ class TestSnmpUser < CiscoTestCase
367
383
  snmpuser.destroy
368
384
  end
369
385
 
370
- def test_snmpuser_create_with_single_group_auth_md5_priv_des
386
+ def test_auth_md5_priv_des
371
387
  name = 'userv3test6'
372
388
  groups = ['network-admin']
373
389
  auth_pw = 'XXWWPass0wrf'
@@ -384,7 +400,7 @@ class TestSnmpUser < CiscoTestCase
384
400
  snmpuser.destroy
385
401
  end
386
402
 
387
- def test_snmpuser_create_with_single_group_auth_md5_priv_des_pw_localized
403
+ def test_auth_md5_priv_des_pw_localized
388
404
  name = 'userv3testauth'
389
405
  groups = ['network-admin']
390
406
  auth_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
@@ -395,15 +411,13 @@ class TestSnmpUser < CiscoTestCase
395
411
  :des, priv_pw,
396
412
  true, # localized
397
413
  '')
398
- # rubocop:disable Metrics/LineLength
399
414
  assert_show_match(
400
415
  pattern: /#{user_pat(name)} auth md5 #{auth_pw} priv #{priv_pw} localizedkey/,
401
416
  command: "show run snmp all | in #{name} | no-more")
402
- # rubocop:enable Metrics/LineLength
403
417
  snmpuser.destroy
404
418
  end
405
419
 
406
- def test_snmpuser_create_with_single_group_auth_md5_priv_aes128
420
+ def test_auth_md5_priv_aes128
407
421
  name = 'userv3test7'
408
422
  groups = ['network-admin']
409
423
  auth_pw = 'XXWWPass0wrf'
@@ -420,7 +434,7 @@ class TestSnmpUser < CiscoTestCase
420
434
  snmpuser.destroy
421
435
  end
422
436
 
423
- def test_snmpuser_create_with_single_group_auth_md5_priv_aes128_pw_localized
437
+ def test_auth_md5_priv_aes128_pw_localized
424
438
  name = 'userv3testauth'
425
439
  groups = ['network-admin']
426
440
  auth_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
@@ -431,15 +445,13 @@ class TestSnmpUser < CiscoTestCase
431
445
  :aes128, priv_pw,
432
446
  true, # localized
433
447
  '')
434
- # rubocop:disable Metrics/LineLength
435
448
  assert_show_match(
436
449
  pattern: /#{user_pat(name)} auth md5 #{auth_pw} priv aes-128 #{priv_pw} localizedkey/,
437
450
  command: "show run snmp all | in #{name} | no-more")
438
- # rubocop:enable Metrics/LineLength
439
451
  snmpuser.destroy
440
452
  end
441
453
 
442
- def test_snmpuser_create_with_single_group_auth_sha_priv_des
454
+ def test_auth_sha_priv_des
443
455
  name = 'userv3test8'
444
456
  groups = ['network-admin']
445
457
  auth_pw = 'XXWWPass0wrf'
@@ -456,7 +468,7 @@ class TestSnmpUser < CiscoTestCase
456
468
  snmpuser.destroy
457
469
  end
458
470
 
459
- def test_snmpuser_create_with_single_group_auth_md5_priv_sha_pw_localized
471
+ def test_auth_md5_priv_sha_pw_localized
460
472
  name = 'userv3testauth'
461
473
  groups = ['network-admin']
462
474
  auth_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
@@ -467,15 +479,13 @@ class TestSnmpUser < CiscoTestCase
467
479
  :des, priv_pw,
468
480
  true, # localized
469
481
  '')
470
- # rubocop:disable Metrics/LineLength
471
482
  assert_show_match(
472
483
  pattern: /#{user_pat(name)} auth sha #{auth_pw} priv #{priv_pw} localizedkey/,
473
484
  command: "show run snmp all | in #{name} | no-more")
474
- # rubocop:enable Metrics/LineLength
475
485
  snmpuser.destroy
476
486
  end
477
487
 
478
- def test_snmpuser_create_with_single_group_auth_sha_priv_aes128
488
+ def test_auth_sha_priv_aes128
479
489
  name = 'userv3test9'
480
490
  groups = ['network-admin']
481
491
  auth_pw = 'XXWWPass0wrf'
@@ -492,7 +502,7 @@ class TestSnmpUser < CiscoTestCase
492
502
  snmpuser.destroy
493
503
  end
494
504
 
495
- def test_snmpuser_create_with_single_group_auth_sha_priv_aes128_pw_localized
505
+ def test_auth_sha_priv_aes128_pw_localized
496
506
  name = 'userv3testauth'
497
507
  groups = ['network-admin']
498
508
  auth_pw = '0xfe6cf9aea159c2c38e0a79ec23ed3cbb'
@@ -503,26 +513,22 @@ class TestSnmpUser < CiscoTestCase
503
513
  :aes128, priv_pw,
504
514
  true, # localized
505
515
  '')
506
- # rubocop:disable Metrics/LineLength
507
516
  assert_show_match(
508
517
  pattern: /#{user_pat(name)} auth sha #{auth_pw} priv aes-128 #{priv_pw} localizedkey/,
509
518
  command: "show run snmp all | in #{name} | no-more")
510
- # rubocop:enable Metrics/LineLength
511
519
  snmpuser.destroy
512
520
  end
513
521
 
514
- def test_snmpuser_create_destroy_with_engine_id
522
+ def test_create_destroy_with_engine_id
515
523
  name = 'test_with_engine_id'
516
524
  auth_pw = 'XXWWPass0wrf'
517
525
  priv_pw = 'XXWWPass0wrf'
518
526
  engine_id = '128:12:12:12:12'
519
527
  snmpuser = SnmpUser.new(name, [''], :md5, auth_pw, :des, priv_pw,
520
528
  false, engine_id)
521
- # rubocop:disable Metrics/LineLength
522
529
  assert_show_match(
523
530
  pattern: /snmp-server user #{name} auth \S+ \S+ priv .*\S+ localizedkey engineID #{engine_id}/,
524
531
  command: "show run snmp all | in #{name} | no-more")
525
- # rubocop:enable Metrics/LineLength
526
532
  user = SnmpUser.users["#{name} #{engine_id}"]
527
533
  refute_nil(user)
528
534
  assert_equal(snmpuser.name, user.name)
@@ -530,15 +536,13 @@ class TestSnmpUser < CiscoTestCase
530
536
  assert_equal(snmpuser.engine_id, engine_id)
531
537
  assert_equal(snmpuser.engine_id, user.engine_id)
532
538
  snmpuser.destroy
533
- # rubocop:disable Metrics/LineLength
534
539
  refute_show_match(
535
540
  pattern: /snmp-server user #{name} auth \S+ \S+ priv .*\S+ localizedkey engineID #{engine_id}/,
536
541
  command: "show run snmp all | in #{name} | no-more")
537
- # rubocop:enable Metrics/LineLength
538
542
  assert_nil(SnmpUser.users["#{name} #{engine_id}"])
539
543
  end
540
544
 
541
- def test_snmpuser_authpassword
545
+ def test_authpassword
542
546
  name = 'test_authpassword'
543
547
  auth_pw = '0x123456'
544
548
  snmpuser = SnmpUser.new(name, [''], :md5, auth_pw, :none, '', true, '')
@@ -548,7 +552,7 @@ class TestSnmpUser < CiscoTestCase
548
552
  snmpuser.destroy
549
553
  end
550
554
 
551
- def test_snmpuser_authpassword_with_engineid
555
+ def test_authpassword_with_engineid
552
556
  name = 'test_authpassword'
553
557
  auth_pw = '0x123456'
554
558
  engine_id = '128:12:12:12:12'
@@ -560,7 +564,7 @@ class TestSnmpUser < CiscoTestCase
560
564
  snmpuser.destroy
561
565
  end
562
566
 
563
- def test_snmpuser_privpassword
567
+ def test_privpassword
564
568
  name = 'test_privpassword'
565
569
  priv_password = '0x123456'
566
570
  snmpuser = SnmpUser.new(name, [''], :md5, priv_password,
@@ -577,7 +581,7 @@ class TestSnmpUser < CiscoTestCase
577
581
  snmpuser.destroy
578
582
  end
579
583
 
580
- def test_snmpuser_privpassword_with_engineid
584
+ def test_privpassword_with_engineid
581
585
  name = 'test_privpassword2'
582
586
  priv_password = '0x123456'
583
587
  engine_id = '128:12:12:12:12'
@@ -594,7 +598,7 @@ class TestSnmpUser < CiscoTestCase
594
598
  snmpuser.destroy
595
599
  end
596
600
 
597
- def test_snmpuser_auth_password_equal_with_engineid
601
+ def test_auth_password_equal_with_engineid
598
602
  name = 'test_authpass_equal'
599
603
  auth_pass = 'XXWWPass0wrf'
600
604
  engine_id = '128:12:12:12:12'
@@ -608,7 +612,7 @@ class TestSnmpUser < CiscoTestCase
608
612
  snmpuser.destroy
609
613
  end
610
614
 
611
- def test_snmpuser_priv_password_equal_with_engineid
615
+ def test_priv_password_equal_with_engineid
612
616
  name = 'test_privpass_equal'
613
617
  priv_pass = 'XXWWPass0wrf'
614
618
  engine_id = '128:12:12:12:12'
@@ -626,31 +630,31 @@ class TestSnmpUser < CiscoTestCase
626
630
  snmpuser.destroy
627
631
  end
628
632
 
629
- def test_snmpuser_default_groups
633
+ def test_default_groups
630
634
  groups = [DEFAULT_SNMP_USER_GROUP_NAME]
631
635
  assert_equal(groups, SnmpUser.default_groups,
632
636
  'Error: Wrong default groups')
633
637
  end
634
638
 
635
- def test_snmpuser_default_auth_protocol
639
+ def test_default_auth_protocol
636
640
  assert_equal(:md5,
637
641
  SnmpUser.default_auth_protocol,
638
642
  'Error: Wrong default auth protocol')
639
643
  end
640
644
 
641
- def test_snmpuser_default_auth_password
645
+ def test_default_auth_password
642
646
  assert_equal(DEFAULT_SNMP_USER_AUTH_PASSWORD,
643
647
  SnmpUser.default_auth_password,
644
648
  'Error: Wrong default auth password')
645
649
  end
646
650
 
647
- def test_snmpuser_default_priv_protocol
651
+ def test_default_priv_protocol
648
652
  assert_equal(:des,
649
653
  SnmpUser.default_priv_protocol,
650
654
  'Error: Wrong default priv protocol')
651
655
  end
652
656
 
653
- def test_snmpuser_default_priv_password
657
+ def test_default_priv_password
654
658
  assert_equal(DEFAULT_SNMP_USER_PRIV_PASSWORD,
655
659
  SnmpUser.default_priv_password,
656
660
  'Error: Wrong default priv password')