cisco_node_utils_mgx 2.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (357) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +96 -0
  5. data/.travis.yml +17 -0
  6. data/CHANGELOG.md +676 -0
  7. data/CONTRIBUTING.md +43 -0
  8. data/Gemfile +10 -0
  9. data/LICENSE +201 -0
  10. data/README.md +246 -0
  11. data/Rakefile +44 -0
  12. data/SUPPORT.md +3 -0
  13. data/bin/.rubocop.yml +18 -0
  14. data/bin/check_metric_limits.rb +109 -0
  15. data/bin/git/hooks/commit-msg/enforce_style +89 -0
  16. data/bin/git/hooks/hook_lib +115 -0
  17. data/bin/git/hooks/hooks-wrapper +38 -0
  18. data/bin/git/hooks/post-flow-hotfix-start/update-version +24 -0
  19. data/bin/git/hooks/post-flow-release-finish/update-version +29 -0
  20. data/bin/git/hooks/post-flow-release-start/update-version +19 -0
  21. data/bin/git/hooks/post-merge/update-hooks +6 -0
  22. data/bin/git/hooks/post-rewrite/update-hooks +6 -0
  23. data/bin/git/hooks/pre-commit/check_unstaged_changes +18 -0
  24. data/bin/git/hooks/pre-commit/rubocop +25 -0
  25. data/bin/git/hooks/pre-commit/validate-diffs +45 -0
  26. data/bin/git/hooks/pre-commit/validate-yaml +18 -0
  27. data/bin/git/hooks/pre-push/check-changelog +24 -0
  28. data/bin/git/hooks/pre-push/rubocop +7 -0
  29. data/bin/git/update-hooks +123 -0
  30. data/bin/show_running_yang.rb +233 -0
  31. data/cisco_node_utils.gemspec +41 -0
  32. data/docs/README-develop-best-practices.md +521 -0
  33. data/docs/README-develop-node-utils-APIs.md +570 -0
  34. data/docs/README-maintainers.md +77 -0
  35. data/docs/README-test-execution.md +57 -0
  36. data/docs/README-utilities.md +14 -0
  37. data/docs/agent_files.png +0 -0
  38. data/docs/cisco_node_utils.yaml.example +36 -0
  39. data/docs/template-router.rb +123 -0
  40. data/docs/template-test_router.rb +104 -0
  41. data/ext/mkrf_conf.rb +63 -0
  42. data/lib/.rubocop.yml +18 -0
  43. data/lib/cisco_node_utils/aaa_authentication_login.rb +95 -0
  44. data/lib/cisco_node_utils/aaa_authentication_login_service.rb +138 -0
  45. data/lib/cisco_node_utils/aaa_authorization_service.rb +156 -0
  46. data/lib/cisco_node_utils/ace.rb +467 -0
  47. data/lib/cisco_node_utils/acl.rb +101 -0
  48. data/lib/cisco_node_utils/banner.rb +63 -0
  49. data/lib/cisco_node_utils/bfd_global.rb +305 -0
  50. data/lib/cisco_node_utils/bgp.rb +988 -0
  51. data/lib/cisco_node_utils/bgp_af.rb +545 -0
  52. data/lib/cisco_node_utils/bgp_af_aggr_addr.rb +207 -0
  53. data/lib/cisco_node_utils/bgp_neighbor.rb +527 -0
  54. data/lib/cisco_node_utils/bgp_neighbor_af.rb +780 -0
  55. data/lib/cisco_node_utils/bridge_domain.rb +178 -0
  56. data/lib/cisco_node_utils/bridge_domain_vni.rb +206 -0
  57. data/lib/cisco_node_utils/cisco_cmn_utils.rb +444 -0
  58. data/lib/cisco_node_utils/client/client.rb +238 -0
  59. data/lib/cisco_node_utils/client/grpc/client.rb +395 -0
  60. data/lib/cisco_node_utils/client/grpc/ems.proto +148 -0
  61. data/lib/cisco_node_utils/client/grpc/ems.rb +111 -0
  62. data/lib/cisco_node_utils/client/grpc/ems_services.rb +49 -0
  63. data/lib/cisco_node_utils/client/grpc.rb +33 -0
  64. data/lib/cisco_node_utils/client/nxapi/client.rb +368 -0
  65. data/lib/cisco_node_utils/client/nxapi.rb +31 -0
  66. data/lib/cisco_node_utils/client/utils.rb +180 -0
  67. data/lib/cisco_node_utils/client.rb +35 -0
  68. data/lib/cisco_node_utils/cmd_ref/README_YAML.md +590 -0
  69. data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +25 -0
  70. data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +38 -0
  71. data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +40 -0
  72. data/lib/cisco_node_utils/cmd_ref/acl.yaml +48 -0
  73. data/lib/cisco_node_utils/cmd_ref/banner.yaml +11 -0
  74. data/lib/cisco_node_utils/cmd_ref/bfd_global.yaml +117 -0
  75. data/lib/cisco_node_utils/cmd_ref/bgp.yaml +383 -0
  76. data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +223 -0
  77. data/lib/cisco_node_utils/cmd_ref/bgp_af_aa.yaml +38 -0
  78. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +174 -0
  79. data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +236 -0
  80. data/lib/cisco_node_utils/cmd_ref/bridge_domain.yaml +49 -0
  81. data/lib/cisco_node_utils/cmd_ref/bridge_domain_vni.yaml +33 -0
  82. data/lib/cisco_node_utils/cmd_ref/dhcp_relay_global.yaml +128 -0
  83. data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +55 -0
  84. data/lib/cisco_node_utils/cmd_ref/encapsulation.yaml +25 -0
  85. data/lib/cisco_node_utils/cmd_ref/evpn_multicast.yaml +12 -0
  86. data/lib/cisco_node_utils/cmd_ref/evpn_multisite.yaml +18 -0
  87. data/lib/cisco_node_utils/cmd_ref/evpn_stormcontrol.yaml +18 -0
  88. data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +48 -0
  89. data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +183 -0
  90. data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +40 -0
  91. data/lib/cisco_node_utils/cmd_ref/feature.yaml +126 -0
  92. data/lib/cisco_node_utils/cmd_ref/hostname.yaml +8 -0
  93. data/lib/cisco_node_utils/cmd_ref/hsrp_global.yaml +25 -0
  94. data/lib/cisco_node_utils/cmd_ref/images.yaml +8 -0
  95. data/lib/cisco_node_utils/cmd_ref/interface.yaml +781 -0
  96. data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +45 -0
  97. data/lib/cisco_node_utils/cmd_ref/interface_evpn_multisite.yaml +17 -0
  98. data/lib/cisco_node_utils/cmd_ref/interface_hsrp_group.yaml +120 -0
  99. data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +112 -0
  100. data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +87 -0
  101. data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +42 -0
  102. data/lib/cisco_node_utils/cmd_ref/inventory.yaml +45 -0
  103. data/lib/cisco_node_utils/cmd_ref/ip_multicast.yaml +22 -0
  104. data/lib/cisco_node_utils/cmd_ref/itd_device_group.yaml +83 -0
  105. data/lib/cisco_node_utils/cmd_ref/itd_service.yaml +119 -0
  106. data/lib/cisco_node_utils/cmd_ref/memory.yaml +24 -0
  107. data/lib/cisco_node_utils/cmd_ref/ntp_auth_key.yaml +10 -0
  108. data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +27 -0
  109. data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +34 -0
  110. data/lib/cisco_node_utils/cmd_ref/object_group.yaml +32 -0
  111. data/lib/cisco_node_utils/cmd_ref/ospf.yaml +91 -0
  112. data/lib/cisco_node_utils/cmd_ref/ospf_area.yaml +91 -0
  113. data/lib/cisco_node_utils/cmd_ref/ospf_area_vlink.yaml +88 -0
  114. data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +37 -0
  115. data/lib/cisco_node_utils/cmd_ref/pim.yaml +43 -0
  116. data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +86 -0
  117. data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +37 -0
  118. data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +100 -0
  119. data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +19 -0
  120. data/lib/cisco_node_utils/cmd_ref/route_map.yaml +601 -0
  121. data/lib/cisco_node_utils/cmd_ref/show_system.yaml +9 -0
  122. data/lib/cisco_node_utils/cmd_ref/show_version.yaml +84 -0
  123. data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +81 -0
  124. data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +9 -0
  125. data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +74 -0
  126. data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +91 -0
  127. data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +57 -0
  128. data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +23 -0
  129. data/lib/cisco_node_utils/cmd_ref/span_session.yaml +65 -0
  130. data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +235 -0
  131. data/lib/cisco_node_utils/cmd_ref/syslog_facility.yaml +10 -0
  132. data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +34 -0
  133. data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +45 -0
  134. data/lib/cisco_node_utils/cmd_ref/system.yaml +7 -0
  135. data/lib/cisco_node_utils/cmd_ref/tacacs_global.yaml +37 -0
  136. data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +63 -0
  137. data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +45 -0
  138. data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +64 -0
  139. data/lib/cisco_node_utils/cmd_ref/upgrade.yaml +38 -0
  140. data/lib/cisco_node_utils/cmd_ref/vdc.yaml +52 -0
  141. data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +8 -0
  142. data/lib/cisco_node_utils/cmd_ref/vlan.yaml +106 -0
  143. data/lib/cisco_node_utils/cmd_ref/vpc.yaml +233 -0
  144. data/lib/cisco_node_utils/cmd_ref/vrf.yaml +86 -0
  145. data/lib/cisco_node_utils/cmd_ref/vrf_af.yaml +139 -0
  146. data/lib/cisco_node_utils/cmd_ref/vtp.yaml +32 -0
  147. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +114 -0
  148. data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +71 -0
  149. data/lib/cisco_node_utils/cmd_ref/yang.yaml +7 -0
  150. data/lib/cisco_node_utils/cmd_ref/yum.yaml +68 -0
  151. data/lib/cisco_node_utils/command_reference.rb +724 -0
  152. data/lib/cisco_node_utils/configparser_lib.rb +195 -0
  153. data/lib/cisco_node_utils/constants.rb +40 -0
  154. data/lib/cisco_node_utils/dhcp_relay_global.rb +302 -0
  155. data/lib/cisco_node_utils/dns_domain.rb +93 -0
  156. data/lib/cisco_node_utils/domain_name.rb +82 -0
  157. data/lib/cisco_node_utils/encapsulation.rb +112 -0
  158. data/lib/cisco_node_utils/environment.rb +110 -0
  159. data/lib/cisco_node_utils/evpn_multicast.rb +66 -0
  160. data/lib/cisco_node_utils/evpn_multisite.rb +96 -0
  161. data/lib/cisco_node_utils/evpn_stormcontrol.rb +84 -0
  162. data/lib/cisco_node_utils/evpn_vni.rb +159 -0
  163. data/lib/cisco_node_utils/exceptions.rb +140 -0
  164. data/lib/cisco_node_utils/fabricpath_global.rb +405 -0
  165. data/lib/cisco_node_utils/fabricpath_topology.rb +137 -0
  166. data/lib/cisco_node_utils/feature.rb +377 -0
  167. data/lib/cisco_node_utils/hostname.rb +62 -0
  168. data/lib/cisco_node_utils/hsrp_global.rb +97 -0
  169. data/lib/cisco_node_utils/interface.rb +2128 -0
  170. data/lib/cisco_node_utils/interface_channel_group.rb +142 -0
  171. data/lib/cisco_node_utils/interface_evpn_multisite.rb +72 -0
  172. data/lib/cisco_node_utils/interface_hsrp_group.rb +557 -0
  173. data/lib/cisco_node_utils/interface_ospf.rb +378 -0
  174. data/lib/cisco_node_utils/interface_portchannel.rb +180 -0
  175. data/lib/cisco_node_utils/interface_service_vni.rb +132 -0
  176. data/lib/cisco_node_utils/ip_multicast.rb +90 -0
  177. data/lib/cisco_node_utils/itd_device_group.rb +228 -0
  178. data/lib/cisco_node_utils/itd_device_group_node.rb +144 -0
  179. data/lib/cisco_node_utils/itd_service.rb +511 -0
  180. data/lib/cisco_node_utils/logger.rb +78 -0
  181. data/lib/cisco_node_utils/name_server.rb +64 -0
  182. data/lib/cisco_node_utils/node.rb +443 -0
  183. data/lib/cisco_node_utils/node_util.rb +111 -0
  184. data/lib/cisco_node_utils/ntp_auth_key.rb +67 -0
  185. data/lib/cisco_node_utils/ntp_config.rb +83 -0
  186. data/lib/cisco_node_utils/ntp_server.rb +86 -0
  187. data/lib/cisco_node_utils/object_group.rb +75 -0
  188. data/lib/cisco_node_utils/object_group_entry.rb +143 -0
  189. data/lib/cisco_node_utils/overlay_global.rb +142 -0
  190. data/lib/cisco_node_utils/pim.rb +131 -0
  191. data/lib/cisco_node_utils/pim_group_list.rb +109 -0
  192. data/lib/cisco_node_utils/pim_rp_address.rb +103 -0
  193. data/lib/cisco_node_utils/platform.rb +217 -0
  194. data/lib/cisco_node_utils/portchannel_global.rb +347 -0
  195. data/lib/cisco_node_utils/radius_global.rb +165 -0
  196. data/lib/cisco_node_utils/radius_server.rb +421 -0
  197. data/lib/cisco_node_utils/radius_server_group.rb +117 -0
  198. data/lib/cisco_node_utils/route_map.rb +2540 -0
  199. data/lib/cisco_node_utils/router_ospf.rb +77 -0
  200. data/lib/cisco_node_utils/router_ospf_area.rb +416 -0
  201. data/lib/cisco_node_utils/router_ospf_area_vlink.rb +313 -0
  202. data/lib/cisco_node_utils/router_ospf_vrf.rb +342 -0
  203. data/lib/cisco_node_utils/snmp_notification_receiver.rb +176 -0
  204. data/lib/cisco_node_utils/snmpcommunity.rb +109 -0
  205. data/lib/cisco_node_utils/snmpgroup.rb +54 -0
  206. data/lib/cisco_node_utils/snmpnotification.rb +57 -0
  207. data/lib/cisco_node_utils/snmpserver.rb +132 -0
  208. data/lib/cisco_node_utils/snmpuser.rb +403 -0
  209. data/lib/cisco_node_utils/span_session.rb +149 -0
  210. data/lib/cisco_node_utils/stp_global.rb +676 -0
  211. data/lib/cisco_node_utils/syslog_facility.rb +64 -0
  212. data/lib/cisco_node_utils/syslog_server.rb +146 -0
  213. data/lib/cisco_node_utils/syslog_settings.rb +174 -0
  214. data/lib/cisco_node_utils/tacacs_global.rb +137 -0
  215. data/lib/cisco_node_utils/tacacs_server.rb +173 -0
  216. data/lib/cisco_node_utils/tacacs_server_group.rb +149 -0
  217. data/lib/cisco_node_utils/tacacs_server_host.rb +216 -0
  218. data/lib/cisco_node_utils/upgrade.rb +122 -0
  219. data/lib/cisco_node_utils/vdc.rb +118 -0
  220. data/lib/cisco_node_utils/version.rb +21 -0
  221. data/lib/cisco_node_utils/vlan.rb +301 -0
  222. data/lib/cisco_node_utils/vpc.rb +466 -0
  223. data/lib/cisco_node_utils/vrf.rb +192 -0
  224. data/lib/cisco_node_utils/vrf_af.rb +327 -0
  225. data/lib/cisco_node_utils/vtp.rb +125 -0
  226. data/lib/cisco_node_utils/vxlan_vtep.rb +286 -0
  227. data/lib/cisco_node_utils/vxlan_vtep_vni.rb +331 -0
  228. data/lib/cisco_node_utils/yang.rb +160 -0
  229. data/lib/cisco_node_utils/yum.rb +213 -0
  230. data/lib/cisco_node_utils.rb +21 -0
  231. data/lib/minitest/environment_plugin.rb +31 -0
  232. data/lib/minitest/log_level_plugin.rb +41 -0
  233. data/spec/client_spec.rb +7 -0
  234. data/spec/environment_spec.rb +384 -0
  235. data/spec/grpc_client_spec.rb +23 -0
  236. data/spec/isolate/all_clients_spec.rb +9 -0
  237. data/spec/isolate/grpc_only_spec.rb +16 -0
  238. data/spec/isolate/no_clients_spec.rb +26 -0
  239. data/spec/isolate/nxapi_only_spec.rb +16 -0
  240. data/spec/nxapi_client_spec.rb +42 -0
  241. data/spec/schema.yaml +82 -0
  242. data/spec/shared_examples_for_clients.rb +14 -0
  243. data/spec/spec_helper.rb +91 -0
  244. data/spec/whitespace_spec.rb +10 -0
  245. data/spec/yaml_spec.rb +42 -0
  246. data/tests/.rubocop.yml +18 -0
  247. data/tests/CSCuxdublin-1.0.0-7.0.3.I3.1.lib32_n9000.rpm +0 -0
  248. data/tests/basetest.rb +243 -0
  249. data/tests/ciscotest.rb +577 -0
  250. data/tests/cmd_config.yaml +75 -0
  251. data/tests/cmd_config_invalid.yaml +16 -0
  252. data/tests/n9000_sample-1.0.0-7.0.3.x86_64.rpm +0 -0
  253. data/tests/noop.rb +7 -0
  254. data/tests/platform_info.rb +63 -0
  255. data/tests/tacacs_server.yaml.example +6 -0
  256. data/tests/test_aaa_authentication_login.rb +243 -0
  257. data/tests/test_aaa_authentication_login_service.rb +761 -0
  258. data/tests/test_aaa_authorization_service.rb +874 -0
  259. data/tests/test_ace.rb +304 -0
  260. data/tests/test_acl.rb +185 -0
  261. data/tests/test_banner.rb +85 -0
  262. data/tests/test_bfd_global.rb +272 -0
  263. data/tests/test_bgp_af.rb +875 -0
  264. data/tests/test_bgp_af_aa.rb +108 -0
  265. data/tests/test_bgp_neighbor.rb +596 -0
  266. data/tests/test_bgp_neighbor_af.rb +781 -0
  267. data/tests/test_bridge_domain.rb +198 -0
  268. data/tests/test_bridge_domain_vni.rb +109 -0
  269. data/tests/test_client_utils.rb +111 -0
  270. data/tests/test_cmn_utils.rb +76 -0
  271. data/tests/test_command_config.rb +206 -0
  272. data/tests/test_command_reference.rb +669 -0
  273. data/tests/test_dhcp_relay_global.rb +286 -0
  274. data/tests/test_dns_domain.rb +123 -0
  275. data/tests/test_domain_name.rb +96 -0
  276. data/tests/test_encapsulation.rb +75 -0
  277. data/tests/test_evpn_multicast.rb +65 -0
  278. data/tests/test_evpn_multisite.rb +70 -0
  279. data/tests/test_evpn_stormcontrol.rb +56 -0
  280. data/tests/test_evpn_vni.rb +131 -0
  281. data/tests/test_fabricpath_global.rb +246 -0
  282. data/tests/test_fabricpath_topology.rb +77 -0
  283. data/tests/test_feature.rb +272 -0
  284. data/tests/test_grpc.rb +166 -0
  285. data/tests/test_hostname.rb +64 -0
  286. data/tests/test_hsrp_global.rb +79 -0
  287. data/tests/test_interface.rb +1958 -0
  288. data/tests/test_interface_bdi.rb +80 -0
  289. data/tests/test_interface_channel_group.rb +131 -0
  290. data/tests/test_interface_evpn_multisite.rb +94 -0
  291. data/tests/test_interface_hsrp.rb +134 -0
  292. data/tests/test_interface_hsrp_group.rb +570 -0
  293. data/tests/test_interface_ospf.rb +820 -0
  294. data/tests/test_interface_portchannel.rb +135 -0
  295. data/tests/test_interface_private_vlan.rb +365 -0
  296. data/tests/test_interface_service_vni.rb +203 -0
  297. data/tests/test_interface_svi.rb +210 -0
  298. data/tests/test_interface_switchport.rb +468 -0
  299. data/tests/test_ip_multicast.rb +80 -0
  300. data/tests/test_itd_device_group.rb +145 -0
  301. data/tests/test_itd_device_group_node.rb +199 -0
  302. data/tests/test_itd_service.rb +314 -0
  303. data/tests/test_logger.rb +43 -0
  304. data/tests/test_name_server.rb +94 -0
  305. data/tests/test_node.rb +50 -0
  306. data/tests/test_node_ext.rb +406 -0
  307. data/tests/test_node_util.rb +119 -0
  308. data/tests/test_ntp_auth_key.rb +77 -0
  309. data/tests/test_ntp_config.rb +100 -0
  310. data/tests/test_ntp_server.rb +146 -0
  311. data/tests/test_nxapi.rb +236 -0
  312. data/tests/test_object_group.rb +122 -0
  313. data/tests/test_overlay_global.rb +108 -0
  314. data/tests/test_pim.rb +203 -0
  315. data/tests/test_pim_group_list.rb +147 -0
  316. data/tests/test_pim_rp_address.rb +155 -0
  317. data/tests/test_platform.rb +254 -0
  318. data/tests/test_portchannel_global.rb +322 -0
  319. data/tests/test_radius_global.rb +108 -0
  320. data/tests/test_radius_server.rb +377 -0
  321. data/tests/test_radius_server_group.rb +151 -0
  322. data/tests/test_route_map.rb +1479 -0
  323. data/tests/test_router_bgp.rb +1325 -0
  324. data/tests/test_router_ospf.rb +56 -0
  325. data/tests/test_router_ospf_area.rb +433 -0
  326. data/tests/test_router_ospf_area_vlink.rb +298 -0
  327. data/tests/test_router_ospf_vrf.rb +690 -0
  328. data/tests/test_snmp_notification_receiver.rb +169 -0
  329. data/tests/test_snmpcommunity.rb +422 -0
  330. data/tests/test_snmpgroup.rb +71 -0
  331. data/tests/test_snmpnotification.rb +91 -0
  332. data/tests/test_snmpserver.rb +251 -0
  333. data/tests/test_snmpuser.rb +666 -0
  334. data/tests/test_span_session.rb +155 -0
  335. data/tests/test_stp_global.rb +575 -0
  336. data/tests/test_syslog_facility.rb +80 -0
  337. data/tests/test_syslog_server.rb +119 -0
  338. data/tests/test_syslog_settings.rb +123 -0
  339. data/tests/test_tacacs_global.rb +109 -0
  340. data/tests/test_tacacs_server.rb +436 -0
  341. data/tests/test_tacacs_server_group.rb +434 -0
  342. data/tests/test_tacacs_server_host.rb +427 -0
  343. data/tests/test_upgrade.rb +105 -0
  344. data/tests/test_vdc.rb +64 -0
  345. data/tests/test_vlan.rb +386 -0
  346. data/tests/test_vlan_private.rb +656 -0
  347. data/tests/test_vpc.rb +548 -0
  348. data/tests/test_vrf.rb +248 -0
  349. data/tests/test_vrf_af.rb +288 -0
  350. data/tests/test_vtp.rb +278 -0
  351. data/tests/test_vxlan_vtep.rb +327 -0
  352. data/tests/test_vxlan_vtep_vni.rb +326 -0
  353. data/tests/test_yang.rb +369 -0
  354. data/tests/test_yum.rb +109 -0
  355. data/tests/upgrade_info.yaml.example +3 -0
  356. data/tests/yum_package.yaml +94 -0
  357. metadata +534 -0
@@ -0,0 +1,406 @@
1
+ # Copyright (c) 2013-2017 Cisco and/or its affiliates.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative 'ciscotest'
16
+
17
+ # TestNodeExt - Minitest for abstracted Node APIs
18
+ class TestNodeExt < CiscoTestCase
19
+ def setup
20
+ super
21
+ @chassis = (platform == :nexus) ? 'Chassis' : 'Rack 0'
22
+ @domain = (platform == :nexus) ? 'ip domain-name' : 'domain name'
23
+ end
24
+
25
+ def assert_output_check(command: nil, pattern: nil, msg: nil, check: nil)
26
+ command += ' | no-more' if platform == :nexus
27
+ md = assert_show_match(command: command, pattern: pattern, msg: msg)
28
+ assert_equal(md[1], check, msg)
29
+ end
30
+
31
+ def test_config_get
32
+ result = node.config_get('show_version', 'system_image')
33
+ assert_equal(result, node.system)
34
+ end
35
+
36
+ def test_config_get_regexp_tokens
37
+ node.client.set(context: ['interface loopback0'], values: ['shutdown'])
38
+ node.client.set(values: ['interface loopback1', 'no shutdown'])
39
+
40
+ result = node.config_get('interface', 'shutdown',
41
+ name: 'loopback1', show_name: 'loopback1')
42
+ refute(result)
43
+ end
44
+
45
+ def test_config_get_invalid
46
+ assert_raises IndexError do # no entry
47
+ node.config_get('foobar', 'name')
48
+ end
49
+ assert_raises IndexError do # entry but no config_get
50
+ node.config_get('show_system', 'resources')
51
+ end
52
+ end
53
+
54
+ def test_config_get_default
55
+ result = node.config_get_default('bgp', 'graceful_restart_timers_restart')
56
+ assert_equal(120, result)
57
+ end
58
+
59
+ def test_config_get_default_invalid
60
+ assert_raises IndexError do # no name entry
61
+ node.config_get_default('show_version', 'foobar')
62
+ end
63
+ assert_raises IndexError do # no feature entry
64
+ node.config_get_default('foobar', 'name')
65
+ end
66
+ assert_raises IndexError do # no default_value defined
67
+ node.config_get_default('show_version', 'version')
68
+ end
69
+ end
70
+
71
+ def test_config_set
72
+ node.config_set('interface', 'create', name: 'loopback122')
73
+ run = node.client.get(command: 'show run | inc interface')
74
+ val = Client.filter_cli(cli_output: run, value: /interface loopback122/i)
75
+ assert_match(/interface loopback122/i, val[0])
76
+
77
+ node.config_set('interface', 'destroy', name: 'loopback122')
78
+ run = node.client.get(command: 'show run | inc interface')
79
+ val = Client.filter_cli(cli_output: run, value: /interface loopback122/i)
80
+ assert_nil(val)
81
+ end
82
+
83
+ def test_config_set_invalid
84
+ assert_raises IndexError do
85
+ node.config_set('foobar', 'name')
86
+ end
87
+ assert_raises(IndexError, Cisco::UnsupportedError) do
88
+ # feature exists but no config_set
89
+ node.config_set('show_version', 'system_image')
90
+ end
91
+ # TODO: none of the supported classes on IOS XR use printf-style args
92
+ if platform == :nexus # rubocop:disable Style/GuardClause
93
+ assert_raises ArgumentError do # not enough args
94
+ node.config_set('vtp', 'domain')
95
+ end
96
+ assert_raises ArgumentError do # too many args
97
+ node.config_set('vtp', 'domain', 'example.com', 'baz')
98
+ end
99
+ end
100
+ end
101
+
102
+ def test_cli_caching
103
+ # don't use config() here because we are testing caching and flushing
104
+ @device.cmd('conf t')
105
+ @device.cmd("#{@domain} minitest")
106
+ @device.cmd('commit') if platform == :ios_xr
107
+ @device.cmd('end')
108
+ dom1 = node.domain_name
109
+ @device.cmd('conf t')
110
+ @device.cmd("no #{@domain} minitest")
111
+ @device.cmd('commit') if platform == :ios_xr
112
+ @device.cmd('end')
113
+ dom2 = node.domain_name
114
+ assert_equal(dom1, dom2) # cached output was used for dom2
115
+
116
+ node.cache_flush
117
+ dom3 = node.domain_name
118
+ refute_equal(dom1, dom3)
119
+ end
120
+
121
+ def test_get_product_description
122
+ product_description = node.product_description
123
+
124
+ command = node.cmd_ref.lookup('show_version', 'description').get_command
125
+
126
+ # Hardware
127
+ # cisco Nexus9000 C9396PX Chassis
128
+ #
129
+ # Other variants for the line of interest:
130
+ # cisco Nexus9000 C9504 (4 Slot) Chassis ("Supervisor Module")
131
+ # ^-module_id-ignore!-^
132
+ # cisco Nexus3000 C3132Q Chassis
133
+ # cisco N3K-C3048TP-1GE
134
+ pattern = /Hardware\n cisco (([^(\n]+|\(\d+ Slot\))+\w+)/ if
135
+ platform[/nexus/]
136
+ pattern = /DESCR: "(.*)"/ if platform[/ios_xr/]
137
+
138
+ assert_output_check(command: command,
139
+ pattern: pattern,
140
+ check: product_description,
141
+ msg: 'Error, Product description does not match')
142
+ end
143
+
144
+ def test_get_product_id
145
+ # N3|9K Fretta product_id gets a '-F' appended so remove it for this check
146
+ if product_tag[/n(3|9)k-f/]
147
+ node.client.cache_flush
148
+ chassis = node.product_id.sub('-F', '')
149
+ else
150
+ node.client.cache_flush
151
+ chassis = node.product_id
152
+ end
153
+ assert_output_check(command: 'show inventory',
154
+ pattern: /NAME: \"#{@chassis}\".*\nPID: (\S+)/,
155
+ check: chassis,
156
+ msg: 'Error, Product id does not match')
157
+ end
158
+
159
+ def test_get_product_version_id
160
+ assert_output_check(command: 'show inventory',
161
+ pattern: /NAME: \"#{@chassis}\".*\n.*VID: (\w+)/,
162
+ check: node.product_version_id,
163
+ msg: 'Error, Version id does not match')
164
+ end
165
+
166
+ def test_get_product_serial_number
167
+ assert_output_check(command: 'show inventory',
168
+ pattern: /NAME: \"#{@chassis}\".*\n.*SN: ([-\w]+)/,
169
+ check: node.product_serial_number,
170
+ msg: 'Error, Serial number does not match')
171
+ end
172
+
173
+ def test_get_os
174
+ assert_output_check(command: 'show version',
175
+ pattern: /\n(Cisco.*Software)/,
176
+ check: node.os,
177
+ msg: 'Error, OS version does not match')
178
+ end
179
+
180
+ def test_get_os_version
181
+ # /N(5|6|7)/
182
+ # system: version 7.3(0)D1(1) [build 7.3(0)D1(1)]
183
+ # /N(3|8|9)/
184
+ # NXOS: version 7.0(3)I3(1) [build 7.0(3)I3(1)]
185
+
186
+ pattern = /(?:system|NXOS):\s+version (.*)\n/ if platform[/nexus/]
187
+ pattern = /IOS XR.*Version (.*)$/ if platform[/ios_xr/]
188
+
189
+ assert_output_check(command: 'show version',
190
+ pattern: pattern,
191
+ check: node.os_version,
192
+ msg: 'Error, OS version does not match')
193
+ end
194
+
195
+ def test_get_host_name_when_not_set
196
+ if platform == :nexus
197
+ s = @device.cmd('show running-config all | no-more')
198
+ else
199
+ s = @device.cmd('show running-config all')
200
+ end
201
+ pattern = /.*\nhostname (\S+)/
202
+ md = pattern.match(s)
203
+ if md
204
+ configured_name = md[1]
205
+ switchname = false
206
+ else
207
+ # No hostname configured. Lets check if we have switchname instead.
208
+ pattern = /.*\nswitchname (\S+)/
209
+ md = pattern.match(s)
210
+ if md
211
+ configured_name = md[1]
212
+ switchname = true
213
+ else
214
+ configured_name = nil
215
+ end
216
+ end
217
+
218
+ switchname ? config('no switchname') : config('no hostname')
219
+
220
+ name = node.host_name
221
+ if platform == :nexus
222
+ assert_equal('switch', name)
223
+ else
224
+ assert_equal('ios', name)
225
+ end
226
+
227
+ return unless configured_name
228
+ config("hostname #{configured_name}") if switchname == false
229
+ config("switchname #{configured_name}") if switchname == true
230
+ end
231
+
232
+ def test_get_host_name_when_set
233
+ if platform == :nexus
234
+ s = @device.cmd('show running-config all | no-more')
235
+ else
236
+ s = @device.cmd('show running-config all')
237
+ end
238
+ pattern = /.*\nhostname (\S+)/
239
+ md = pattern.match(s)
240
+ if md
241
+ configured_name = md[1]
242
+ switchname = false
243
+ else
244
+ # No hostname configured. Lets check if we have switchname instead.
245
+ pattern = /.*\nswitchname (\S+)/
246
+ md = pattern.match(s)
247
+ if md
248
+ configured_name = md[1]
249
+ switchname = true
250
+ else
251
+ configured_name = nil
252
+ switchname = false
253
+ end
254
+ end
255
+
256
+ switchname ? config('switchname xyz') : config('hostname xyz')
257
+
258
+ host_name = node.host_name
259
+ assert_equal('xyz', host_name)
260
+
261
+ if configured_name
262
+ config("hostname #{configured_name}") if switchname == false
263
+ config("switchname #{configured_name}") if switchname == true
264
+ else
265
+ switchname ? config('no switchname') : config('no hostname')
266
+ end
267
+ end
268
+
269
+ def test_get_domain_name_when_not_set
270
+ # Test with default vrf only
271
+ s = @device.cmd("show running-config | incl '^#{@domain}'")
272
+ pattern = /^#{@domain} (\S+)/
273
+ md = pattern.match(s)
274
+ if md
275
+ configured_domain_name = md[1]
276
+ else
277
+ configured_domain_name = nil
278
+ end
279
+
280
+ config("no #{@domain} #{configured_domain_name}") unless
281
+ configured_domain_name.nil?
282
+
283
+ domain_name = node.domain_name
284
+ assert_equal('', domain_name)
285
+
286
+ if configured_domain_name
287
+ config("#{@domain} #{configured_domain_name}")
288
+ else
289
+ config("no #{@domain} abc.com")
290
+ end
291
+ end
292
+
293
+ def test_get_domain_name_when_set
294
+ s = @device.cmd('show running-config | no-more')
295
+ pattern = /.*\n#{@domain} (\S+)/
296
+ md = pattern.match(s)
297
+ if md
298
+ configured_domain_name = md[1]
299
+ else
300
+ configured_domain_name = nil
301
+ end
302
+
303
+ config("#{@domain} abc.com")
304
+
305
+ domain_name = node.domain_name
306
+ assert_equal('abc.com', domain_name)
307
+
308
+ if configured_domain_name
309
+ config("#{@domain} #{configured_domain_name}")
310
+ else
311
+ config("no #{@domain} abc.com")
312
+ end
313
+ end
314
+
315
+ def test_get_system_uptime
316
+ node.cache_flush
317
+
318
+ cmd = node.cmd_ref.lookup('show_system', 'uptime').get_command
319
+ pattern = node.cmd_ref.lookup('show_system', 'uptime').get_value
320
+
321
+ md = assert_show_match(command: cmd, pattern: pattern)
322
+ node_uptime = node.system_uptime
323
+
324
+ observed_system_uptime = (
325
+ (md[1].to_i * 86_400) +
326
+ (md[2].to_i * 3600) +
327
+ (md[3].to_i * 60) +
328
+ (md[4].to_i)
329
+ )
330
+ delta = node_uptime - observed_system_uptime
331
+ assert(delta < 10,
332
+ "Error, System uptime delta is (#{delta}), expected (delta < 10)")
333
+ end
334
+
335
+ def test_get_last_reset_time
336
+ if validate_property_excluded?('show_version', 'last_reset_time')
337
+ assert_nil(node.last_reset_time)
338
+ else
339
+ refute_nil(node.last_reset_time) unless virtual_platform?
340
+ end
341
+ end
342
+
343
+ def test_get_last_reset_reason
344
+ if validate_property_excluded?('show_version', 'last_reset_reason')
345
+ assert_nil(node.last_reset_reason)
346
+ return
347
+ end
348
+ assert_output_check(command: 'show version',
349
+ pattern: /.*\nLast reset.*\n\n? Reason: (.*)\n/,
350
+ check: node.last_reset_reason,
351
+ msg: 'Error, Last reset reason does not match') unless
352
+ virtual_platform?
353
+ end
354
+
355
+ def test_get_system_cpu_utilization
356
+ if validate_property_excluded?('system', 'resources')
357
+ assert_nil(node.system_cpu_utilization)
358
+ else
359
+ refute_nil(node.system_cpu_utilization)
360
+ end
361
+ end
362
+
363
+ def test_get_boot
364
+ if validate_property_excluded?('show_version', 'boot_image')
365
+ assert_nil(node.boot)
366
+ return
367
+ end
368
+
369
+ # /N(5|6|7)/
370
+ # kickstart image file is: bootflash:///n7000-s2-kickstart.7.3.0.D1.1.bin
371
+ # /N(3|8|9)/
372
+ # NXOS image file is: bootflash:///nxos.7.0.3.I3.1.bin
373
+
374
+ pattern = /(?:kickstart|NXOS) image file is:\s+(.*)$/
375
+ assert_output_check(command: 'show version',
376
+ pattern: pattern,
377
+ check: node.boot,
378
+ msg: 'Error, Kickstart Image does not match')
379
+ end
380
+
381
+ def test_get_system
382
+ if validate_property_excluded?('show_version', 'system_image')
383
+ assert_nil(node.system)
384
+ return
385
+ end
386
+
387
+ # /N(5|6|7)/
388
+ # system image file is: bootflash:///n7000-s2-kickstart.7.3.0.D1.1.bin
389
+ # /N(3|8|9)/
390
+ # NXOS image file is: bootflash:///nxos.7.0.3.I3.1.bin
391
+ # /ios_xr/
392
+ # xrv9k-xr-6.1.1.19I version=6.1.1.19I [Boot image]
393
+
394
+ if platform[/ios_xr/]
395
+ cmd = 'show install active'
396
+ pattern = /^\s*(\S*)\s*version.*\[Boot image\]$/
397
+ else
398
+ cmd = 'show version'
399
+ pattern = /(?:system|NXOS) image file is:\s+(.*)$/
400
+ end
401
+ assert_output_check(command: cmd,
402
+ pattern: pattern,
403
+ check: node.system,
404
+ msg: 'Error, System Image does not match')
405
+ end
406
+ end
@@ -0,0 +1,119 @@
1
+ # Copyright (c) 2016 Cisco and/or its affiliates.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative 'ciscotest'
16
+ require_relative '../lib/cisco_node_utils/node_util'
17
+
18
+ # TestNodeUtil - Minitest for NodeUtil class
19
+ class TestNodeUtil < CiscoTestCase
20
+ attr_reader :nu
21
+ def setup
22
+ @nu = NodeUtil.new
23
+ end
24
+
25
+ def test_node
26
+ assert_equal(node, nu.node)
27
+ assert_equal(node, NodeUtil.node)
28
+ end
29
+
30
+ def test_client
31
+ assert_equal(node.client, nu.client)
32
+ assert_equal(node.client, NodeUtil.client)
33
+ end
34
+
35
+ def test_config_get
36
+ result = node.config_get('show_version', 'system_image')
37
+ result2 = nu.config_get('show_version', 'system_image')
38
+ result3 = NodeUtil.config_get('show_version', 'system_image')
39
+ assert_equal(node.system, result)
40
+ assert_equal(result, result2)
41
+ assert_equal(result, result3)
42
+ end
43
+
44
+ def test_config_get_default
45
+ result = node.config_get_default('bgp', 'graceful_restart_timers_restart')
46
+ result2 = nu.config_get_default('bgp', 'graceful_restart_timers_restart')
47
+ result3 = NodeUtil.config_get_default('bgp',
48
+ 'graceful_restart_timers_restart')
49
+ assert_equal(120, result)
50
+ assert_equal(result, result2)
51
+ assert_equal(result, result3)
52
+ end
53
+
54
+ def test_config_set_error_handling
55
+ # The Node error has no context information
56
+ e = assert_raises(Cisco::CliError) do
57
+ node.config_set('interface', 'shutdown',
58
+ name: interfaces[0], state: 'foobar')
59
+ end
60
+ assert_match(/^The command '.*shutdown' was rejected with error:/,
61
+ e.message)
62
+ rejected_input = e.rejected_input
63
+ clierror = e.clierror
64
+
65
+ # The NodeUtil class error just provides the class name by default...
66
+ e = assert_raises(Cisco::CliError) do
67
+ NodeUtil.config_set('interface', 'shutdown',
68
+ name: interfaces[0], state: 'foobar')
69
+ end
70
+ assert_match(
71
+ /^\[Cisco::NodeUtil\] The command '.*shutdown' was rejected with error:/,
72
+ e.message)
73
+ # Make sure error context from the Node was preserved
74
+ assert_equal(rejected_input, e.rejected_input)
75
+ assert_equal(clierror, e.clierror)
76
+
77
+ # ...but uses self.to_s if implemented
78
+ def NodeUtil.to_s
79
+ 'Hello world'
80
+ end
81
+ e = assert_raises(Cisco::CliError) do
82
+ NodeUtil.config_set('interface', 'shutdown',
83
+ name: interfaces[0], state: 'foobar')
84
+ end
85
+ assert_match(
86
+ /^\[Hello world\] The command '.*shutdown' was rejected with error:/,
87
+ e.message)
88
+ # Make sure error context from the Node was preserved
89
+ assert_equal(rejected_input, e.rejected_input)
90
+ assert_equal(clierror, e.clierror)
91
+
92
+ # Similarly, the nu instance error provides the instance by default...
93
+ e = assert_raises(Cisco::CliError) do
94
+ nu.config_set('interface', 'shutdown',
95
+ name: interfaces[0], state: 'foobar')
96
+ end
97
+ assert_match(
98
+ /^\[#<Cisco::NodeUtil:0x.*>\] The command '.*shutdown' was rejected/,
99
+ e.message)
100
+ # Make sure error context from the Node was preserved
101
+ assert_equal(rejected_input, e.rejected_input)
102
+ assert_equal(clierror, e.clierror)
103
+
104
+ # ...but is happy to use the instance to_s
105
+ def nu.to_s
106
+ 'NodeUtil #1'
107
+ end
108
+ e = assert_raises(Cisco::CliError) do
109
+ nu.config_set('interface', 'shutdown',
110
+ name: interfaces[0], state: 'foobar')
111
+ end
112
+ assert_match(
113
+ /^\[NodeUtil #1\] The command '.*shutdown' was rejected with error:/,
114
+ e.message)
115
+ # Make sure error context from the Node was preserved
116
+ assert_equal(rejected_input, e.rejected_input)
117
+ assert_equal(clierror, e.clierror)
118
+ end
119
+ end
@@ -0,0 +1,77 @@
1
+ #
2
+ # Minitest for NtpAuthKey class
3
+ #
4
+ # Copyright (c) 2014-2017 Cisco and/or its affiliates.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ require_relative 'ciscotest'
19
+ require_relative '../lib/cisco_node_utils/ntp_auth_key'
20
+
21
+ # TestNtpAuthKey - Minitest for NtpAuthKey node utility.
22
+ class TestNtpAuthKey < CiscoTestCase
23
+ def setup
24
+ # setup runs at the beginning of each test
25
+ super
26
+ no_ntpkey
27
+ end
28
+
29
+ def teardown
30
+ # teardown runs at the end of each test
31
+ no_ntpkey
32
+ super
33
+ end
34
+
35
+ def no_ntpkey
36
+ # Turn the feature off for a clean test.
37
+ config('no ntp authentication-key 111 md5 test 7',
38
+ 'no ntp authentication-key 999 md5 test 7')
39
+ end
40
+
41
+ # TESTS
42
+
43
+ def test_create_defaults
44
+ id = '111'
45
+ options = { 'name' => id, 'password' => 'test' }
46
+ refute_includes(Cisco::NtpAuthKey.ntpkeys, id)
47
+
48
+ key = Cisco::NtpAuthKey.new(options, true)
49
+ assert_includes(Cisco::NtpAuthKey.ntpkeys, id)
50
+ assert_equal(key, Cisco::NtpAuthKey.ntpkeys[id])
51
+
52
+ assert_equal(id, Cisco::NtpAuthKey.ntpkeys[id].name)
53
+ assert_equal('md5', Cisco::NtpAuthKey.ntpkeys[id].algorithm)
54
+ assert_equal('7', Cisco::NtpAuthKey.ntpkeys[id].mode)
55
+
56
+ key.destroy
57
+ refute_includes(Cisco::NtpAuthKey.ntpkeys, id)
58
+ end
59
+
60
+ def test_create_options
61
+ id = '999'
62
+ options = { 'name' => id, 'password' => 'test', 'algorithm' => 'md5',
63
+ 'mode' => '7' }
64
+ refute_includes(Cisco::NtpAuthKey.ntpkeys, id)
65
+
66
+ key = Cisco::NtpAuthKey.new(options, true)
67
+ assert_includes(Cisco::NtpAuthKey.ntpkeys, id)
68
+ assert_equal(key, Cisco::NtpAuthKey.ntpkeys[id])
69
+
70
+ assert_equal(id, Cisco::NtpAuthKey.ntpkeys[id].name)
71
+ assert_equal('md5', Cisco::NtpAuthKey.ntpkeys[id].algorithm)
72
+ assert_equal('7', Cisco::NtpAuthKey.ntpkeys[id].mode)
73
+
74
+ key.destroy
75
+ refute_includes(Cisco::NtpAuthKey.ntpkeys, id)
76
+ end
77
+ end
@@ -0,0 +1,100 @@
1
+ #
2
+ # Minitest for NtpConfig class
3
+ #
4
+ # Copyright (c) 2015-2017 Cisco and/or its affiliates.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ require_relative 'ciscotest'
19
+ require_relative '../lib/cisco_node_utils/ntp_config'
20
+
21
+ # TestNtpConfig - Minitest for NtpConfig node utility.
22
+ class TestNtpConfig < CiscoTestCase
23
+ def setup
24
+ # setup runs at the beginning of each test
25
+ super
26
+ no_ntpconfig
27
+ end
28
+
29
+ def teardown
30
+ # teardown runs at the end of each test
31
+ no_ntpconfig
32
+ super
33
+ end
34
+
35
+ def no_ntpconfig
36
+ # Turn the feature off for a clean test.
37
+ if platform == :ios_xr
38
+ config("no ntp source #{interfaces[1]}")
39
+ else
40
+ config("no ntp source-interface #{interfaces[1]}",
41
+ 'no ntp authentication-key 111 md5 test 7',
42
+ 'no ntp authentication-key 999 md5 test 7',
43
+ 'no ntp trusted-key 111',
44
+ 'no ntp trusted-key 999',
45
+ 'no ntp authenticate')
46
+ end
47
+ end
48
+
49
+ # TESTS
50
+
51
+ def test_source_interface
52
+ id = 'default'
53
+
54
+ ntp = Cisco::NtpConfig.new(id)
55
+ assert_includes(Cisco::NtpConfig.ntpconfigs, id)
56
+ assert_equal(Cisco::NtpConfig.ntpconfigs[id], ntp)
57
+
58
+ assert_nil(Cisco::NtpConfig.ntpconfigs[id].source_interface)
59
+ assert_nil(ntp.source_interface)
60
+
61
+ ntp.source_interface = interfaces[1]
62
+ assert_equal(Cisco::NtpConfig.ntpconfigs[id].source_interface,
63
+ interfaces[1].downcase)
64
+ assert_equal(Cisco::NtpConfig.ntpconfigs[id].source_interface,
65
+ ntp.source_interface)
66
+
67
+ ntp.source_interface = nil
68
+ assert_nil(Cisco::NtpConfig.ntpconfigs[id].source_interface)
69
+ assert_nil(ntp.source_interface)
70
+ end
71
+
72
+ def test_authenticate
73
+ id = 'default'
74
+
75
+ ntp = Cisco::NtpConfig.new(id)
76
+ assert_includes(Cisco::NtpConfig.ntpconfigs, id)
77
+ assert_equal(Cisco::NtpConfig.ntpconfigs[id], ntp)
78
+
79
+ assert_equal(false, Cisco::NtpConfig.ntpconfigs[id].authenticate)
80
+
81
+ ntp.authenticate = true
82
+ assert_equal(true, Cisco::NtpConfig.ntpconfigs[id].authenticate)
83
+ end
84
+
85
+ def test_trusted_key
86
+ id = 'default'
87
+
88
+ ntp = Cisco::NtpConfig.new(id)
89
+ assert_includes(Cisco::NtpConfig.ntpconfigs, id)
90
+ assert_equal(Cisco::NtpConfig.ntpconfigs[id], ntp)
91
+
92
+ assert_nil(Cisco::NtpConfig.ntpconfigs[id].trusted_key)
93
+
94
+ config('ntp authentication-key 111 md5 test 7',
95
+ 'ntp authentication-key 999 md5 test 7')
96
+ ntp.trusted_key_set(true, 111)
97
+ ntp.trusted_key_set(true, 999)
98
+ assert_equal(%w(111 999), Cisco::NtpConfig.ntpconfigs[id].trusted_key)
99
+ end
100
+ end