hybrid_platforms_conductor 33.0.0 → 33.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (242) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/bin/check-node +0 -1
  4. data/bin/deploy +0 -1
  5. data/bin/get_impacted_nodes +0 -1
  6. data/bin/last_deploys +8 -7
  7. data/bin/nodes_to_deploy +2 -2
  8. data/bin/setup +6 -6
  9. data/bin/topograph +1 -1
  10. data/lib/hybrid_platforms_conductor/action.rb +4 -4
  11. data/lib/hybrid_platforms_conductor/actions_executor.rb +37 -42
  12. data/lib/hybrid_platforms_conductor/bitbucket.rb +5 -4
  13. data/lib/hybrid_platforms_conductor/cmd_runner.rb +13 -12
  14. data/lib/hybrid_platforms_conductor/cmdb.rb +2 -2
  15. data/lib/hybrid_platforms_conductor/common_config_dsl/bitbucket.rb +2 -1
  16. data/lib/hybrid_platforms_conductor/common_config_dsl/confluence.rb +2 -1
  17. data/lib/hybrid_platforms_conductor/common_config_dsl/file_system_tests.rb +5 -4
  18. data/lib/hybrid_platforms_conductor/common_config_dsl/github.rb +4 -3
  19. data/lib/hybrid_platforms_conductor/common_config_dsl/idempotence_tests.rb +2 -2
  20. data/lib/hybrid_platforms_conductor/config.rb +7 -4
  21. data/lib/hybrid_platforms_conductor/confluence.rb +1 -1
  22. data/lib/hybrid_platforms_conductor/connector.rb +5 -2
  23. data/lib/hybrid_platforms_conductor/core_extensions/symbol/zero.rb +24 -0
  24. data/lib/hybrid_platforms_conductor/credentials.rb +39 -36
  25. data/lib/hybrid_platforms_conductor/current_dir_monitor.rb +4 -1
  26. data/lib/hybrid_platforms_conductor/deployer.rb +95 -96
  27. data/lib/hybrid_platforms_conductor/executable.rb +20 -15
  28. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/config.rb +10 -7
  29. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_ip.rb +1 -1
  30. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/host_keys.rb +2 -2
  31. data/lib/hybrid_platforms_conductor/hpc_plugins/cmdb/platform_handlers.rb +4 -4
  32. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/local.rb +2 -0
  33. data/lib/hybrid_platforms_conductor/hpc_plugins/connector/ssh.rb +45 -49
  34. data/lib/hybrid_platforms_conductor/hpc_plugins/log/remote_fs.rb +6 -5
  35. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef.rb +68 -66
  36. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb +13 -0
  37. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/recipes_tree_builder.rb +39 -38
  38. data/lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/yaml_inventory.rb +5 -4
  39. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/docker.rb +43 -45
  40. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/podman.rb +18 -20
  41. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox.rb +118 -117
  42. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/proxmox_waiter.rb +39 -43
  43. data/lib/hybrid_platforms_conductor/hpc_plugins/provisioner/proxmox/reserve_proxmox_container +9 -13
  44. data/lib/hybrid_platforms_conductor/hpc_plugins/report/confluence.rb +2 -2
  45. data/lib/hybrid_platforms_conductor/hpc_plugins/report/mediawiki.rb +28 -21
  46. data/lib/hybrid_platforms_conductor/hpc_plugins/report/stdout.rb +26 -22
  47. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/cli.rb +8 -6
  48. data/lib/hybrid_platforms_conductor/hpc_plugins/secrets_reader/thycotic.rb +7 -4
  49. data/lib/hybrid_platforms_conductor/hpc_plugins/test/bitbucket_conf.rb +3 -3
  50. data/lib/hybrid_platforms_conductor/hpc_plugins/test/check_deploy_and_idempotence.rb +4 -2
  51. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_freshness.rb +0 -1
  52. data/lib/hybrid_platforms_conductor/hpc_plugins/test/deploy_removes_root_access.rb +21 -19
  53. data/lib/hybrid_platforms_conductor/hpc_plugins/test/divergence.rb +2 -2
  54. data/lib/hybrid_platforms_conductor/hpc_plugins/test/executables.rb +2 -2
  55. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system.rb +19 -21
  56. data/lib/hybrid_platforms_conductor/hpc_plugins/test/file_system_hdfs.rb +19 -21
  57. data/lib/hybrid_platforms_conductor/hpc_plugins/test/github_ci.rb +2 -3
  58. data/lib/hybrid_platforms_conductor/hpc_plugins/test/idempotence.rb +2 -2
  59. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ip.rb +1 -1
  60. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_conf.rb +21 -22
  61. data/lib/hybrid_platforms_conductor/hpc_plugins/test/jenkins_ci_masters_ok.rb +10 -12
  62. data/lib/hybrid_platforms_conductor/hpc_plugins/test/linear_strategy.rb +9 -9
  63. data/lib/hybrid_platforms_conductor/hpc_plugins/test/local_users.rb +2 -2
  64. data/lib/hybrid_platforms_conductor/hpc_plugins/test/mounts.rb +2 -2
  65. data/lib/hybrid_platforms_conductor/hpc_plugins/test/orphan_files.rb +10 -9
  66. data/lib/hybrid_platforms_conductor/hpc_plugins/test/ports.rb +2 -2
  67. data/lib/hybrid_platforms_conductor/hpc_plugins/test/private_ips.rb +5 -5
  68. data/lib/hybrid_platforms_conductor/hpc_plugins/test/public_ips.rb +5 -5
  69. data/lib/hybrid_platforms_conductor/hpc_plugins/test/spectre.rb +4 -6
  70. data/lib/hybrid_platforms_conductor/hpc_plugins/test/veids.rb +3 -3
  71. data/lib/hybrid_platforms_conductor/hpc_plugins/test/vulnerabilities.rb +25 -24
  72. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/confluence.rb +2 -2
  73. data/lib/hybrid_platforms_conductor/hpc_plugins/test_report/stdout.rb +8 -6
  74. data/lib/hybrid_platforms_conductor/io_router.rb +14 -13
  75. data/lib/hybrid_platforms_conductor/json_dumper.rb +2 -2
  76. data/lib/hybrid_platforms_conductor/log.rb +2 -2
  77. data/lib/hybrid_platforms_conductor/logger_helpers.rb +19 -16
  78. data/lib/hybrid_platforms_conductor/nodes_handler.rb +89 -71
  79. data/lib/hybrid_platforms_conductor/parallel_threads.rb +7 -11
  80. data/lib/hybrid_platforms_conductor/platform_handler.rb +7 -7
  81. data/lib/hybrid_platforms_conductor/platforms_handler.rb +5 -3
  82. data/lib/hybrid_platforms_conductor/plugin.rb +2 -2
  83. data/lib/hybrid_platforms_conductor/plugins.rb +13 -8
  84. data/lib/hybrid_platforms_conductor/provisioner.rb +4 -4
  85. data/lib/hybrid_platforms_conductor/report.rb +2 -2
  86. data/lib/hybrid_platforms_conductor/reports_handler.rb +3 -2
  87. data/lib/hybrid_platforms_conductor/secrets_reader.rb +2 -2
  88. data/lib/hybrid_platforms_conductor/services_handler.rb +32 -29
  89. data/lib/hybrid_platforms_conductor/test_only_remote_node.rb +1 -1
  90. data/lib/hybrid_platforms_conductor/test_report.rb +15 -18
  91. data/lib/hybrid_platforms_conductor/tests_runner.rb +116 -118
  92. data/lib/hybrid_platforms_conductor/thycotic.rb +28 -19
  93. data/lib/hybrid_platforms_conductor/topographer.rb +200 -190
  94. data/lib/hybrid_platforms_conductor/topographer/plugins/graphviz.rb +8 -8
  95. data/lib/hybrid_platforms_conductor/topographer/plugins/json.rb +4 -4
  96. data/lib/hybrid_platforms_conductor/version.rb +1 -1
  97. data/spec/hybrid_platforms_conductor_test.rb +6 -6
  98. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/bash_spec.rb +16 -11
  99. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/interactive_spec.rb +1 -1
  100. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/remote_bash_spec.rb +23 -18
  101. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/ruby_spec.rb +67 -49
  102. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions/scp_spec.rb +20 -14
  103. data/spec/hybrid_platforms_conductor_test/api/actions_executor/actions_spec.rb +63 -50
  104. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connection_spec.rb +35 -35
  105. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/connectable_nodes_spec.rb +12 -8
  106. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/local/remote_actions_spec.rb +4 -7
  107. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/cli_options_spec.rb +21 -22
  108. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/config_dsl_spec.rb +23 -24
  109. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connectable_nodes_spec.rb +10 -6
  110. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/connections_spec.rb +73 -54
  111. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/global_helpers_spec.rb +145 -126
  112. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/node_helpers_spec.rb +3 -3
  113. data/spec/hybrid_platforms_conductor_test/api/actions_executor/connectors/ssh/remote_actions_spec.rb +29 -25
  114. data/spec/hybrid_platforms_conductor_test/api/actions_executor/logging_spec.rb +106 -91
  115. data/spec/hybrid_platforms_conductor_test/api/actions_executor/parallel_spec.rb +272 -244
  116. data/spec/hybrid_platforms_conductor_test/api/actions_executor/timeout_spec.rb +10 -12
  117. data/spec/hybrid_platforms_conductor_test/api/cmd_runner_spec.rb +36 -36
  118. data/spec/hybrid_platforms_conductor_test/api/config_spec.rb +24 -22
  119. data/spec/hybrid_platforms_conductor_test/api/deployer/check_spec.rb +4 -2
  120. data/spec/hybrid_platforms_conductor_test/api/deployer/config_dsl_spec.rb +7 -11
  121. data/spec/hybrid_platforms_conductor_test/api/deployer/deploy_spec.rb +34 -26
  122. data/spec/hybrid_platforms_conductor_test/api/deployer/log_plugins/remote_fs_spec.rb +21 -21
  123. data/spec/hybrid_platforms_conductor_test/api/deployer/parse_deploy_output_spec.rb +55 -59
  124. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioner_spec.rb +36 -62
  125. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/podman_spec.rb +17 -17
  126. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/config_dsl_spec.rb +4 -4
  127. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/create_spec.rb +44 -51
  128. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/destroy_spec.rb +3 -3
  129. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/ip_spec.rb +12 -16
  130. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/destroy_vm_spec.rb +31 -19
  131. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/expired_containers_spec.rb +324 -266
  132. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/ips_assignment_spec.rb +89 -61
  133. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/other_lxc_containers_resources_spec.rb +117 -93
  134. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/pve_node_resources_spec.rb +71 -54
  135. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/retries_spec.rb +10 -8
  136. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/reserve_proxmox_container/vm_ids_assignment_spec.rb +80 -60
  137. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/start_spec.rb +1 -1
  138. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/state_spec.rb +1 -1
  139. data/spec/hybrid_platforms_conductor_test/api/deployer/provisioners/proxmox/stop_spec.rb +1 -1
  140. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/cli_spec.rb +21 -20
  141. data/spec/hybrid_platforms_conductor_test/api/deployer/secrets_reader_plugins/thycotic_spec.rb +70 -55
  142. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/config_spec.rb +8 -10
  143. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_ip_spec.rb +33 -24
  144. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/host_keys_spec.rb +64 -51
  145. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs/platform_handlers_spec.rb +3 -3
  146. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/cmdbs_plugins_api_spec.rb +50 -51
  147. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/common_spec.rb +91 -81
  148. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/config_dsl_spec.rb +14 -16
  149. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/git_diff_impacts_spec.rb +51 -75
  150. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/nodes_selectors_spec.rb +35 -26
  151. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/platform_handlers_plugins_api_spec.rb +24 -16
  152. data/spec/hybrid_platforms_conductor_test/api/nodes_handler/several_platforms_spec.rb +29 -19
  153. data/spec/hybrid_platforms_conductor_test/api/platform_handler_spec.rb +4 -4
  154. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/config_dsl_spec.rb +2 -2
  155. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/deploy_output_parsing_spec.rb +6 -6
  156. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/diff_impacts_spec.rb +57 -99
  157. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/inventory_spec.rb +4 -4
  158. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/packaging_spec.rb +32 -35
  159. data/spec/hybrid_platforms_conductor_test/api/platform_handlers/serverless_chef/services_deployment_spec.rb +10 -10
  160. data/spec/hybrid_platforms_conductor_test/api/platforms_handler_spec.rb +38 -27
  161. data/spec/hybrid_platforms_conductor_test/api/plugins_spec.rb +46 -52
  162. data/spec/hybrid_platforms_conductor_test/api/reports_handler_spec.rb +2 -2
  163. data/spec/hybrid_platforms_conductor_test/api/services_handler/actions_to_deploy_spec.rb +90 -58
  164. data/spec/hybrid_platforms_conductor_test/api/services_handler/deploy_allowed_spec.rb +38 -34
  165. data/spec/hybrid_platforms_conductor_test/api/services_handler/log_info_spec.rb +11 -9
  166. data/spec/hybrid_platforms_conductor_test/api/services_handler/package_spec.rb +193 -171
  167. data/spec/hybrid_platforms_conductor_test/api/services_handler/parse_deploy_output_spec.rb +66 -54
  168. data/spec/hybrid_platforms_conductor_test/api/services_handler/prepare_for_deploy_spec.rb +147 -133
  169. data/spec/hybrid_platforms_conductor_test/api/tests_runner/common_spec.rb +69 -49
  170. data/spec/hybrid_platforms_conductor_test/api/tests_runner/global_spec.rb +4 -3
  171. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_check_spec.rb +8 -5
  172. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_spec.rb +8 -5
  173. data/spec/hybrid_platforms_conductor_test/api/tests_runner/node_ssh_spec.rb +30 -27
  174. data/spec/hybrid_platforms_conductor_test/api/tests_runner/platform_spec.rb +12 -9
  175. data/spec/hybrid_platforms_conductor_test/api/tests_runner/reports_spec.rb +48 -47
  176. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/bitbucket_conf_spec.rb +5 -5
  177. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_plugins/github_ci_spec.rb +5 -5
  178. data/spec/hybrid_platforms_conductor_test/api/tests_runner/test_reports_plugins/confluence_spec.rb +5 -5
  179. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb.rb +9 -9
  180. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb2.rb → test_cmdb_2.rb} +6 -6
  181. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/test_cmdb_others.rb +3 -3
  182. data/spec/hybrid_platforms_conductor_test/cmdb_plugins/{test_cmdb_others2.rb → test_cmdb_others_2.rb} +2 -2
  183. data/spec/hybrid_platforms_conductor_test/docs_spec.rb +1 -1
  184. data/spec/hybrid_platforms_conductor_test/executables/{check-node_spec.rb → check_node_spec.rb} +4 -6
  185. data/spec/hybrid_platforms_conductor_test/executables/deploy_spec.rb +4 -6
  186. data/spec/hybrid_platforms_conductor_test/executables/get_impacted_nodes_spec.rb +76 -77
  187. data/spec/hybrid_platforms_conductor_test/executables/last_deploys_spec.rb +13 -15
  188. data/spec/hybrid_platforms_conductor_test/executables/nodes_to_deploy_spec.rb +289 -307
  189. data/spec/hybrid_platforms_conductor_test/executables/options/actions_executor_spec.rb +4 -6
  190. data/spec/hybrid_platforms_conductor_test/executables/options/cmd_runner_spec.rb +3 -5
  191. data/spec/hybrid_platforms_conductor_test/executables/options/common_spec.rb +8 -9
  192. data/spec/hybrid_platforms_conductor_test/executables/options/deployer_spec.rb +12 -14
  193. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_handler_spec.rb +9 -10
  194. data/spec/hybrid_platforms_conductor_test/executables/options/nodes_selectors_spec.rb +9 -10
  195. data/spec/hybrid_platforms_conductor_test/executables/options/reports_handler_spec.rb +1 -1
  196. data/spec/hybrid_platforms_conductor_test/executables/options/tests_runner_spec.rb +22 -22
  197. data/spec/hybrid_platforms_conductor_test/executables/report_spec.rb +22 -16
  198. data/spec/hybrid_platforms_conductor_test/executables/run_spec.rb +32 -32
  199. data/spec/hybrid_platforms_conductor_test/executables/ssh_config_spec.rb +7 -9
  200. data/spec/hybrid_platforms_conductor_test/executables/test_spec.rb +3 -5
  201. data/spec/hybrid_platforms_conductor_test/helpers/actions_executor_helpers.rb +2 -2
  202. data/spec/hybrid_platforms_conductor_test/helpers/cmd_runner_helpers.rb +4 -3
  203. data/spec/hybrid_platforms_conductor_test/helpers/cmdb_helpers.rb +2 -2
  204. data/spec/hybrid_platforms_conductor_test/helpers/config_helpers.rb +1 -1
  205. data/spec/hybrid_platforms_conductor_test/helpers/connector_ssh_helpers.rb +12 -13
  206. data/spec/hybrid_platforms_conductor_test/helpers/deployer_helpers.rb +216 -14
  207. data/spec/hybrid_platforms_conductor_test/helpers/executables_helpers.rb +11 -11
  208. data/spec/hybrid_platforms_conductor_test/helpers/nodes_handler_helpers.rb +1 -1
  209. data/spec/hybrid_platforms_conductor_test/helpers/platforms_handler_helpers.rb +39 -28
  210. data/spec/hybrid_platforms_conductor_test/helpers/plugins_helpers.rb +1 -1
  211. data/spec/hybrid_platforms_conductor_test/helpers/provisioner_proxmox_helpers.rb +86 -111
  212. data/spec/hybrid_platforms_conductor_test/helpers/reports_handler_helpers.rb +1 -1
  213. data/spec/hybrid_platforms_conductor_test/helpers/serverless_chef_helpers.rb +3 -3
  214. data/spec/hybrid_platforms_conductor_test/helpers/services_handler_helpers.rb +1 -1
  215. data/spec/hybrid_platforms_conductor_test/helpers/tests_runner_helpers.rb +1 -1
  216. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem/hpc_plugins/test_plugin_type/{test_plugin_id1.rb → test_plugin_id_1.rb} +0 -0
  217. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem/hpc_plugins/test_plugin_type/{test_plugin_id2.rb → test_plugin_id_2.rb} +0 -0
  218. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem2/sub_dir/hpc_plugins/test_plugin_type/{test_plugin_id3.rb → test_plugin_id_3.rb} +0 -0
  219. data/spec/hybrid_platforms_conductor_test/mocked_lib/my_test_gem2/sub_dir/hpc_plugins/{test_plugin_type2/test_plugin_id4.rb → test_plugin_type_2/test_plugin_id_4.rb} +0 -0
  220. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/test.rb +1 -1
  221. data/spec/hybrid_platforms_conductor_test/platform_handler_plugins/{test2.rb → test_2.rb} +0 -0
  222. data/spec/hybrid_platforms_conductor_test/rubocop_spec.rb +31 -0
  223. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/1_node/nodes/node.json +3 -3
  224. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/data_bags/nodes/node.json +3 -3
  225. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/recipes/cookbooks/test_cookbook_2/libraries/default.rb +1 -0
  226. data/spec/hybrid_platforms_conductor_test/serverless_chef_repositories/several_cookbooks/other_cookbooks/test_cookbook_2/libraries/default.rb +1 -0
  227. data/spec/hybrid_platforms_conductor_test/shared_examples/deployer.rb +952 -0
  228. data/spec/hybrid_platforms_conductor_test/test_connector.rb +3 -3
  229. data/spec/hybrid_platforms_conductor_test/test_log_no_read_plugin.rb +3 -1
  230. data/spec/hybrid_platforms_conductor_test/test_log_plugin.rb +3 -1
  231. data/spec/hybrid_platforms_conductor_test/test_plugins/global.rb +1 -0
  232. data/spec/hybrid_platforms_conductor_test/test_plugins/node.rb +1 -0
  233. data/spec/hybrid_platforms_conductor_test/test_plugins/node_check.rb +1 -0
  234. data/spec/hybrid_platforms_conductor_test/test_plugins/platform.rb +1 -0
  235. data/spec/hybrid_platforms_conductor_test/test_plugins/several_checks.rb +2 -2
  236. data/spec/hybrid_platforms_conductor_test/test_secrets_reader_plugin.rb +4 -4
  237. data/spec/hybrid_platforms_conductor_test/tests_report_plugin.rb +5 -6
  238. data/spec/spec_helper.rb +17 -18
  239. data/tools/check_md +16 -20
  240. data/tools/generate_mermaid +1 -1
  241. metadata +43 -13
  242. data/spec/hybrid_platforms_conductor_test/helpers/deployer_test_helpers.rb +0 -1152
@@ -2,48 +2,53 @@ require 'savon'
2
2
 
3
3
  describe HybridPlatformsConductor::Deployer do
4
4
 
5
- context 'checking secrets_reader plugins' do
5
+ context 'when checking secrets_reader plugins' do
6
6
 
7
- context 'thycotic' do
7
+ context 'with thycotic' do
8
8
 
9
9
  # Setup a platform for tests
10
10
  #
11
11
  # Parameters::
12
12
  # * *additional_config* (String): Additional config
13
13
  # * *platform_info* (Hash): Platform configuration [default: 1 node having 1 service]
14
- # * Proc: Code called when the platform is setup
15
- def with_test_platform_for_thycotic_test(additional_config = '', platform_info: { nodes: { 'node' => { services: %w[service] } } })
14
+ # * *block* (Proc): Code called when the platform is setup
15
+ def with_test_platform_for_thycotic_test(
16
+ additional_config,
17
+ platform_info: {
18
+ nodes: { 'node' => { services: %w[service] } },
19
+ deployable_services: %w[service]
20
+ },
21
+ &block
22
+ )
16
23
  with_test_platform(
17
24
  platform_info,
18
- false,
19
- "read_secrets_from :thycotic\n" + additional_config
20
- ) do
21
- yield
22
- end
25
+ additional_config: "read_secrets_from :thycotic\n#{additional_config}",
26
+ &block
27
+ )
23
28
  end
24
29
 
25
30
  # Mock calls being made to a Thycotic SOAP API using Savon
26
31
  #
27
32
  # Parameters::
28
- # * *url* (String): Mocked URL
33
+ # * *thycotic_url* (String): Mocked URL
29
34
  # * *secret_id* (String): The mocked secret ID
30
35
  # * *mocked_secrets_file* (String or nil): The mocked secrets file stored in Thycotic, or nil to mock a missing secret
31
36
  # * *user* (String or nil): The user to be expected, or nil if it should be read from netrc [default: nil]
32
37
  # * *password* (String or nil): The password to be expected, or nil if it should be read from netrc [default: nil]
33
- def mock_thycotic_file_download_on(url, secret_id, mocked_secrets_file, user: nil, password: nil)
38
+ def mock_thycotic_file_download_on(thycotic_url, secret_id, mocked_secrets_file, user: nil, password: nil)
34
39
  if user.nil?
35
40
  user = 'thycotic_user_from_netrc'
36
41
  password = 'thycotic_password_from_netrc'
37
42
  expect(HybridPlatformsConductor::Credentials).to receive(:with_credentials_for) do |id, _logger, _logger_stderr, url: nil, &client_code|
38
43
  expect(id).to eq :thycotic
39
- expect(url).to eq url
44
+ expect(url).to eq thycotic_url
40
45
  client_code.call user, password
41
46
  end
42
47
  end
43
48
  # Mock the Savon calls
44
- mocked_savon_client = double 'Mocked Savon client'
49
+ mocked_savon_client = instance_double Savon::Client
45
50
  expect(Savon).to receive(:client) do |params|
46
- expect(params[:wsdl]).to eq "#{url}/webservices/SSWebservice.asmx?wsdl"
51
+ expect(params[:wsdl]).to eq "#{thycotic_url}/webservices/SSWebservice.asmx?wsdl"
47
52
  expect(params[:ssl_verify_mode]).to eq :none
48
53
  mocked_savon_client
49
54
  end
@@ -54,9 +59,7 @@ describe HybridPlatformsConductor::Deployer do
54
59
  password: password,
55
60
  domain: 'thycotic_auth_domain'
56
61
  }
57
- ) do
58
- { authenticate_response: { authenticate_result: { token: 'soap_token' } } }
59
- end
62
+ ).and_return(authenticate_response: { authenticate_result: { token: 'soap_token' } })
60
63
  expect(mocked_savon_client).to receive(:call).with(
61
64
  :get_secret,
62
65
  message: {
@@ -70,7 +73,7 @@ describe HybridPlatformsConductor::Deployer do
70
73
  if mocked_secrets_file
71
74
  { secret: { items: { secret_item: { id: '4242' } } } }
72
75
  else
73
- { errors: { string: 'Access Denied'}, secret_error: { error_code: 'LOAD', error_message: 'Access Denied', allows_response: false } }
76
+ { errors: { string: 'Access Denied' }, secret_error: { error_code: 'LOAD', error_message: 'Access Denied', allows_response: false } }
74
77
  end
75
78
  }
76
79
  }
@@ -98,49 +101,55 @@ describe HybridPlatformsConductor::Deployer do
98
101
 
99
102
  it 'gets secrets from a Thycotic Secret Server' do
100
103
  with_test_platform_for_thycotic_test(
101
- <<~EOS
104
+ <<~EO_CONFIG
102
105
  secrets_from_thycotic(
103
106
  thycotic_url: 'https://my_thycotic.domain.com/SecretServer',
104
107
  secret_id: 1107
105
108
  )
106
- EOS
109
+ EO_CONFIG
107
110
  ) do
108
111
  mock_thycotic_file_download_on('https://my_thycotic.domain.com/SecretServer', 1107, '{ "secret_name": "secret_value" }')
109
- expect(test_services_handler).to receive(:deploy_allowed?).with(
112
+ expect(test_services_handler).to receive(:package).with(
110
113
  services: { 'node' => %w[service] },
111
114
  secrets: { 'secret_name' => 'secret_value' },
112
115
  local_environment: false
113
- ) { 'Abort as testing secrets is enough' }
114
- expect { test_deployer.deploy_on(%w[node]) }.to raise_error 'Deployment not allowed: Abort as testing secrets is enough'
116
+ ) { raise 'Abort as testing secrets is enough' }
117
+ expect { test_deployer.deploy_on(%w[node]) }.to raise_error 'Abort as testing secrets is enough'
115
118
  end
116
119
  end
117
120
 
118
121
  it 'gets secrets from a Thycotic Secret Server for several nodes' do
119
- additional_config = <<~EOS
122
+ additional_config = <<~EO_CONFIG
120
123
  secrets_from_thycotic(
121
124
  thycotic_url: 'https://my_thycotic.domain.com/SecretServer',
122
125
  secret_id: 1107
123
126
  )
124
- EOS
125
- with_test_platform_for_thycotic_test(additional_config, platform_info: { nodes: { 'node1' => { services: %w[service1] }, 'node2' => { services: %w[service2] } } }) do
127
+ EO_CONFIG
128
+ with_test_platform_for_thycotic_test(
129
+ additional_config,
130
+ platform_info: {
131
+ nodes: { 'node1' => { services: %w[service1] }, 'node2' => { services: %w[service2] } },
132
+ deployable_services: %w[service1 service2]
133
+ }
134
+ ) do
126
135
  mock_thycotic_file_download_on('https://my_thycotic.domain.com/SecretServer', 1107, '{ "secret_name": "secret_value" }')
127
- expect(test_services_handler).to receive(:deploy_allowed?).with(
136
+ expect(test_services_handler).to receive(:package).with(
128
137
  services: { 'node1' => %w[service1], 'node2' => %w[service2] },
129
138
  secrets: { 'secret_name' => 'secret_value' },
130
139
  local_environment: false
131
- ) { 'Abort as testing secrets is enough' }
132
- expect { test_deployer.deploy_on(%w[node1 node2]) }.to raise_error 'Deployment not allowed: Abort as testing secrets is enough'
140
+ ) { raise 'Abort as testing secrets is enough' }
141
+ expect { test_deployer.deploy_on(%w[node1 node2]) }.to raise_error 'Abort as testing secrets is enough'
133
142
  end
134
143
  end
135
144
 
136
145
  it 'gets secrets from a Thycotic Secret Server using env variables' do
137
146
  with_test_platform_for_thycotic_test(
138
- <<~EOS
147
+ <<~EO_CONFIG
139
148
  secrets_from_thycotic(
140
149
  thycotic_url: 'https://my_thycotic.domain.com/SecretServer',
141
150
  secret_id: 1107
142
151
  )
143
- EOS
152
+ EO_CONFIG
144
153
  ) do
145
154
  mock_thycotic_file_download_on(
146
155
  'https://my_thycotic.domain.com/SecretServer',
@@ -151,17 +160,17 @@ describe HybridPlatformsConductor::Deployer do
151
160
  )
152
161
  ENV['hpc_user_for_thycotic'] = 'thycotic_user_from_env'
153
162
  ENV['hpc_password_for_thycotic'] = 'thycotic_password_from_env'
154
- expect(test_services_handler).to receive(:deploy_allowed?).with(
163
+ expect(test_services_handler).to receive(:package).with(
155
164
  services: { 'node' => %w[service] },
156
165
  secrets: { 'secret_name' => 'secret_value' },
157
166
  local_environment: false
158
- ) { 'Abort as testing secrets is enough' }
159
- expect { test_deployer.deploy_on(%w[node]) }.to raise_error 'Deployment not allowed: Abort as testing secrets is enough'
167
+ ) { raise 'Abort as testing secrets is enough' }
168
+ expect { test_deployer.deploy_on(%w[node]) }.to raise_error 'Abort as testing secrets is enough'
160
169
  end
161
170
  end
162
171
 
163
172
  it 'gets secrets from several Thycotic Secret Servers' do
164
- additional_config = <<~EOS
173
+ additional_config = <<~EO_CONFIG
165
174
  secrets_from_thycotic(
166
175
  thycotic_url: 'https://my_thycotic1.domain.com/SecretServer',
167
176
  secret_id: 110701
@@ -172,22 +181,28 @@ describe HybridPlatformsConductor::Deployer do
172
181
  secret_id: 110702
173
182
  )
174
183
  end
175
- EOS
176
- with_test_platform_for_thycotic_test(additional_config, platform_info: { nodes: { 'node1' => { services: %w[service1] }, 'node2' => { services: %w[service2] } } }) do
177
- mock_thycotic_file_download_on('https://my_thycotic1.domain.com/SecretServer', 110701, '{ "secret1": "value1" }')
178
- mock_thycotic_file_download_on('https://my_thycotic2.domain.com/SecretServer', 110702, '{ "secret2": "value2" }')
179
- expect(test_services_handler).to receive(:deploy_allowed?).with(
184
+ EO_CONFIG
185
+ with_test_platform_for_thycotic_test(
186
+ additional_config,
187
+ platform_info: {
188
+ nodes: { 'node1' => { services: %w[service1] }, 'node2' => { services: %w[service2] } },
189
+ deployable_services: %w[service1 service2]
190
+ }
191
+ ) do
192
+ mock_thycotic_file_download_on('https://my_thycotic1.domain.com/SecretServer', 110_701, '{ "secret1": "value1" }')
193
+ mock_thycotic_file_download_on('https://my_thycotic2.domain.com/SecretServer', 110_702, '{ "secret2": "value2" }')
194
+ expect(test_services_handler).to receive(:package).with(
180
195
  services: { 'node1' => %w[service1], 'node2' => %w[service2] },
181
196
  secrets: { 'secret1' => 'value1', 'secret2' => 'value2' },
182
197
  local_environment: false
183
- ) { 'Abort as testing secrets is enough' }
184
- expect { test_deployer.deploy_on(%w[node1 node2]) }.to raise_error 'Deployment not allowed: Abort as testing secrets is enough'
198
+ ) { raise 'Abort as testing secrets is enough' }
199
+ expect { test_deployer.deploy_on(%w[node1 node2]) }.to raise_error 'Abort as testing secrets is enough'
185
200
  end
186
201
  end
187
202
 
188
203
  it 'merges secrets from several Thycotic Secret Servers' do
189
204
  with_test_platform_for_thycotic_test(
190
- <<~EOS
205
+ <<~EO_CONFIG
191
206
  secrets_from_thycotic(
192
207
  thycotic_url: 'https://my_thycotic1.domain.com/SecretServer',
193
208
  secret_id: 110701
@@ -198,22 +213,22 @@ describe HybridPlatformsConductor::Deployer do
198
213
  secret_id: 110702
199
214
  )
200
215
  end
201
- EOS
216
+ EO_CONFIG
202
217
  ) do
203
- mock_thycotic_file_download_on('https://my_thycotic1.domain.com/SecretServer', 110701, '{ "secret1": "value1", "secret2": "value2" }')
204
- mock_thycotic_file_download_on('https://my_thycotic2.domain.com/SecretServer', 110702, '{ "secret2": "value2", "secret3": "value3" }')
205
- expect(test_services_handler).to receive(:deploy_allowed?).with(
218
+ mock_thycotic_file_download_on('https://my_thycotic1.domain.com/SecretServer', 110_701, '{ "secret1": "value1", "secret2": "value2" }')
219
+ mock_thycotic_file_download_on('https://my_thycotic2.domain.com/SecretServer', 110_702, '{ "secret2": "value2", "secret3": "value3" }')
220
+ expect(test_services_handler).to receive(:package).with(
206
221
  services: { 'node' => %w[service] },
207
222
  secrets: { 'secret1' => 'value1', 'secret2' => 'value2', 'secret3' => 'value3' },
208
223
  local_environment: false
209
- ) { 'Abort as testing secrets is enough' }
210
- expect { test_deployer.deploy_on(%w[node]) }.to raise_error 'Deployment not allowed: Abort as testing secrets is enough'
224
+ ) { raise 'Abort as testing secrets is enough' }
225
+ expect { test_deployer.deploy_on(%w[node]) }.to raise_error 'Abort as testing secrets is enough'
211
226
  end
212
227
  end
213
228
 
214
229
  it 'fails in case of secrets conflicts from several Thycotic Secret Servers' do
215
230
  with_test_platform_for_thycotic_test(
216
- <<~EOS
231
+ <<~EO_CONFIG
217
232
  secrets_from_thycotic(
218
233
  thycotic_url: 'https://my_thycotic1.domain.com/SecretServer',
219
234
  secret_id: 110701
@@ -224,22 +239,22 @@ describe HybridPlatformsConductor::Deployer do
224
239
  secret_id: 110702
225
240
  )
226
241
  end
227
- EOS
242
+ EO_CONFIG
228
243
  ) do
229
- mock_thycotic_file_download_on('https://my_thycotic1.domain.com/SecretServer', 110701, '{ "secret1": "value1", "secret2": "value2" }')
230
- mock_thycotic_file_download_on('https://my_thycotic2.domain.com/SecretServer', 110702, '{ "secret2": "other_value", "secret3": "value3" }')
244
+ mock_thycotic_file_download_on('https://my_thycotic1.domain.com/SecretServer', 110_701, '{ "secret1": "value1", "secret2": "value2" }')
245
+ mock_thycotic_file_download_on('https://my_thycotic2.domain.com/SecretServer', 110_702, '{ "secret2": "other_value", "secret3": "value3" }')
231
246
  expect { test_deployer.deploy_on(%w[node]) }.to raise_error 'Thycotic secret secret2 served by https://my_thycotic2.domain.com/SecretServer from secret ID 110702 has conflicting values between different secrets.'
232
247
  end
233
248
  end
234
249
 
235
250
  it 'fails to get secrets from a missing Thycotic Secret Server' do
236
251
  with_test_platform_for_thycotic_test(
237
- <<~EOS
252
+ <<~EO_CONFIG
238
253
  secrets_from_thycotic(
239
254
  thycotic_url: 'https://my_thycotic.domain.com/SecretServer',
240
255
  secret_id: 1107
241
256
  )
242
- EOS
257
+ EO_CONFIG
243
258
  ) do
244
259
  mock_thycotic_file_download_on('https://my_thycotic.domain.com/SecretServer', 1107, nil)
245
260
  expect { test_deployer.deploy_on(%w[node]) }.to raise_error 'Unable to fetch secret file ID 1107 from https://my_thycotic.domain.com/SecretServer'
@@ -1,12 +1,11 @@
1
1
  describe HybridPlatformsConductor::NodesHandler do
2
2
 
3
- context 'checking CMDB plugin Config' do
3
+ context 'when checking CMDB plugin Config' do
4
4
 
5
5
  it 'sets global metadata' do
6
6
  with_test_platform(
7
7
  { nodes: { 'node1' => {} } },
8
- false,
9
- 'set_metadata(my_property: \'my_value\')'
8
+ additional_config: 'set_metadata(my_property: \'my_value\')'
10
9
  ) do
11
10
  expect(cmdb(:config).get_others(['node1'], {})).to eq('node1' => { my_property: 'my_value' })
12
11
  end
@@ -15,15 +14,14 @@ describe HybridPlatformsConductor::NodesHandler do
15
14
  it 'sets different metadata for different nodes' do
16
15
  with_test_platform(
17
16
  { nodes: { 'node1' => {}, 'node2' => {} } },
18
- false,
19
- '
20
- for_nodes(\'node1\') { set_metadata(my_property1: \'my_value1\', my_property2: \'my_value2\') }
21
- for_nodes(\'node2\') { set_metadata(my_property2: \'my_value3\', my_property3: \'my_value4\') }
22
- '
17
+ additional_config: <<~'EO_CONFIG'
18
+ for_nodes('node1') { set_metadata(my_property_1: 'my_value1', my_property_2: 'my_value2') }
19
+ for_nodes('node2') { set_metadata(my_property_2: 'my_value3', my_property_3: 'my_value4') }
20
+ EO_CONFIG
23
21
  ) do
24
22
  expect(cmdb(:config).get_others(%w[node1 node2], {})).to eq(
25
- 'node1' => { my_property1: 'my_value1', my_property2: 'my_value2' },
26
- 'node2' => { my_property2: 'my_value3', my_property3: 'my_value4' }
23
+ 'node1' => { my_property_1: 'my_value1', my_property_2: 'my_value2' },
24
+ 'node2' => { my_property_2: 'my_value3', my_property_3: 'my_value4' }
27
25
  )
28
26
  end
29
27
  end
@@ -1,57 +1,66 @@
1
1
  describe HybridPlatformsConductor::NodesHandler do
2
2
 
3
- context 'checking CMDB plugin HostIp' do
3
+ context 'when checking CMDB plugin HostIp' do
4
4
 
5
5
  it 'makes sure to have hostname set to compute host_ip' do
6
- with_test_platform do
6
+ with_test_platform({}) do
7
7
  expect(cmdb(:host_ip).property_dependencies[:host_ip]).to eq :hostname
8
8
  end
9
9
  end
10
10
 
11
11
  it 'does not return a host IP when hostname is not set' do
12
- with_test_platform(nodes: { 'test_node' => {} }) do
12
+ with_test_platform({ nodes: { 'test_node' => {} } }) do
13
13
  expect(cmdb(:host_ip).get_host_ip(['test_node'], { 'test_node' => { property: 'value' } })).to eq({})
14
14
  end
15
15
  end
16
16
 
17
17
  it 'returns a host IP when hostname is set' do
18
- with_test_platform(nodes: { 'test_node' => {} }) do
19
- with_cmd_runner_mocked([
18
+ with_test_platform({ nodes: { 'test_node' => {} } }) do
19
+ with_cmd_runner_mocked [
20
20
  ['getent hosts my_domain.my_host', proc { [0, '192.168.42.42 my_domain.my_host', ''] }]
21
- ]) do
21
+ ] do
22
22
  expect(cmdb(:host_ip).get_host_ip(['test_node'], { 'test_node' => { hostname: 'my_domain.my_host' } })).to eq('test_node' => '192.168.42.42')
23
23
  end
24
24
  end
25
25
  end
26
26
 
27
27
  it 'does not return a host IP when getent can\'t retrieve it' do
28
- with_test_platform(nodes: { 'test_node' => {} }) do
29
- with_cmd_runner_mocked([
28
+ with_test_platform({ nodes: { 'test_node' => {} } }) do
29
+ with_cmd_runner_mocked [
30
30
  ['getent hosts my_domain.my_host', proc { [0, '', ''] }]
31
- ]) do
31
+ ] do
32
32
  expect(cmdb(:host_ip).get_host_ip(['test_node'], { 'test_node' => { hostname: 'my_domain.my_host' } })).to eq({})
33
33
  end
34
34
  end
35
35
  end
36
36
 
37
37
  it 'returns a host IPs for the maximum hosts it can from the list' do
38
- with_test_platform(nodes: {
39
- 'test_node1' => {},
40
- 'test_node2' => {},
41
- 'test_node3' => {},
42
- 'test_node4' => {}
43
- }) do
44
- with_cmd_runner_mocked([
38
+ with_test_platform(
39
+ {
40
+ nodes: {
41
+ 'test_node1' => {},
42
+ 'test_node2' => {},
43
+ 'test_node3' => {},
44
+ 'test_node4' => {}
45
+ }
46
+ }
47
+ ) do
48
+ with_cmd_runner_mocked [
45
49
  ['getent hosts my_domain.my_host1', proc { [0, '192.168.42.1 my_domain.my_host1', ''] }],
46
50
  ['getent hosts my_domain.my_host2', proc { [0, '', ''] }],
47
- ['getent hosts my_domain.my_host4', proc { [0, '192.168.42.4 my_domain.my_host4', ''] }],
48
- ]) do
49
- expect(cmdb(:host_ip).get_host_ip(['test_node'], {
50
- 'test_node1' => { hostname: 'my_domain.my_host1' },
51
- 'test_node2' => { hostname: 'my_domain.my_host2' },
52
- 'test_node3' => {},
53
- 'test_node4' => { hostname: 'my_domain.my_host4' }
54
- })).to eq(
51
+ ['getent hosts my_domain.my_host4', proc { [0, '192.168.42.4 my_domain.my_host4', ''] }]
52
+ ] do
53
+ expect(
54
+ cmdb(:host_ip).get_host_ip(
55
+ ['test_node'],
56
+ {
57
+ 'test_node1' => { hostname: 'my_domain.my_host1' },
58
+ 'test_node2' => { hostname: 'my_domain.my_host2' },
59
+ 'test_node3' => {},
60
+ 'test_node4' => { hostname: 'my_domain.my_host4' }
61
+ }
62
+ )
63
+ ).to eq(
55
64
  'test_node1' => '192.168.42.1',
56
65
  'test_node4' => '192.168.42.4'
57
66
  )
@@ -1,49 +1,49 @@
1
1
  describe HybridPlatformsConductor::NodesHandler do
2
2
 
3
- context 'checking CMDB plugin HostKeys' do
3
+ context 'when checking CMDB plugin HostKeys' do
4
4
 
5
5
  it 'makes sure to have hostname or host_ip set to compute host_keys' do
6
- with_test_platform do
6
+ with_test_platform({}) do
7
7
  expect(cmdb(:host_keys).property_dependencies[:host_keys].sort).to eq %i[hostname host_ip].sort
8
8
  end
9
9
  end
10
10
 
11
11
  it 'does not return host keys when neither hostname nor host_ip are set' do
12
- with_test_platform(nodes: { 'test_node' => {} }) do
12
+ with_test_platform({ nodes: { 'test_node' => {} } }) do
13
13
  expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { property: 'value' } })).to eq({})
14
14
  end
15
15
  end
16
16
 
17
17
  it 'returns host keys when hostname is set' do
18
- with_test_platform(nodes: { 'test_node' => {} }) do
19
- with_cmd_runner_mocked([
18
+ with_test_platform({ nodes: { 'test_node' => {} } }) do
19
+ with_cmd_runner_mocked [
20
20
  ['ssh-keyscan my_host.my_domain', proc { [0, "my_host.my_domain ssh-rsa fake_host_key\n", ''] }]
21
- ]) do
21
+ ] do
22
22
  expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { hostname: 'my_host.my_domain' } })).to eq('test_node' => ['ssh-rsa fake_host_key'])
23
23
  end
24
24
  end
25
25
  end
26
26
 
27
27
  it 'returns host keys when host_ip is set' do
28
- with_test_platform(nodes: { 'test_node' => {} }) do
29
- with_cmd_runner_mocked([
28
+ with_test_platform({ nodes: { 'test_node' => {} } }) do
29
+ with_cmd_runner_mocked [
30
30
  ['ssh-keyscan 192.168.42.42', proc { [0, "192.168.42.42 ssh-rsa fake_host_key\n", ''] }]
31
- ]) do
31
+ ] do
32
32
  expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { host_ip: '192.168.42.42' } })).to eq('test_node' => ['ssh-rsa fake_host_key'])
33
33
  end
34
34
  end
35
35
  end
36
36
 
37
37
  it 'returns several host keys' do
38
- with_test_platform(nodes: { 'test_node' => {} }) do
39
- with_cmd_runner_mocked([
38
+ with_test_platform({ nodes: { 'test_node' => {} } }) do
39
+ with_cmd_runner_mocked [
40
40
  ['ssh-keyscan 192.168.42.42', proc do
41
- [0, <<~EOS, '']
41
+ [0, <<~EO_STDOUT, '']
42
42
  192.168.42.42 ssh-rsa fake_host_key_rsa
43
43
  192.168.42.42 ssh-ed25519 fake_host_key_ed25519
44
- EOS
44
+ EO_STDOUT
45
45
  end]
46
- ]) do
46
+ ] do
47
47
  expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { host_ip: '192.168.42.42' } })).to eq('test_node' => [
48
48
  'ssh-rsa fake_host_key_rsa',
49
49
  'ssh-ed25519 fake_host_key_ed25519'
@@ -53,74 +53,87 @@ describe HybridPlatformsConductor::NodesHandler do
53
53
  end
54
54
 
55
55
  it 'returns several host keys and ignores comments from ssh-keyscan' do
56
- with_test_platform(nodes: { 'test_node' => {} }) do
57
- with_cmd_runner_mocked([
56
+ with_test_platform({ nodes: { 'test_node' => {} } }) do
57
+ with_cmd_runner_mocked [
58
58
  ['ssh-keyscan 192.168.42.42', proc do
59
- [0, <<~EOS, '']
59
+ [0, <<~EO_STDOUT, '']
60
60
  # That's a comment
61
61
  192.168.42.42 ssh-rsa fake_host_key_rsa
62
62
  # And another one
63
63
  192.168.42.42 ssh-ed25519 fake_host_key_ed25519
64
64
  # Woot third!
65
- EOS
65
+ EO_STDOUT
66
66
  end]
67
- ]) do
68
- expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { host_ip: '192.168.42.42' } })).to eq('test_node' => [
69
- 'ssh-rsa fake_host_key_rsa',
70
- 'ssh-ed25519 fake_host_key_ed25519'
71
- ].sort)
67
+ ] do
68
+ expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { host_ip: '192.168.42.42' } })).to eq(
69
+ 'test_node' => [
70
+ 'ssh-rsa fake_host_key_rsa',
71
+ 'ssh-ed25519 fake_host_key_ed25519'
72
+ ].sort
73
+ )
72
74
  end
73
75
  end
74
76
  end
75
77
 
76
78
  it 'returns host keys sorted' do
77
- with_test_platform(nodes: { 'test_node' => {} }) do
78
- with_cmd_runner_mocked([
79
+ with_test_platform({ nodes: { 'test_node' => {} } }) do
80
+ with_cmd_runner_mocked [
79
81
  ['ssh-keyscan 192.168.42.42', proc do
80
- [0, <<~EOS, '']
82
+ [0, <<~EO_STDOUT, '']
81
83
  192.168.42.42 ssh-dsa fake_host_key_dsa
82
84
  192.168.42.42 ssh-rsa fake_host_key_rsa
83
85
  192.168.42.42 ssh-ed25519 fake_host_key_ed25519
84
- EOS
86
+ EO_STDOUT
85
87
  end]
86
- ]) do
87
- expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { host_ip: '192.168.42.42' } })).to eq('test_node' => [
88
- 'ssh-dsa fake_host_key_dsa',
89
- 'ssh-ed25519 fake_host_key_ed25519',
90
- 'ssh-rsa fake_host_key_rsa'
91
- ])
88
+ ] do
89
+ expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { host_ip: '192.168.42.42' } })).to eq(
90
+ 'test_node' => [
91
+ 'ssh-dsa fake_host_key_dsa',
92
+ 'ssh-ed25519 fake_host_key_ed25519',
93
+ 'ssh-rsa fake_host_key_rsa'
94
+ ]
95
+ )
92
96
  end
93
97
  end
94
98
  end
95
99
 
96
100
  it 'does not return host keys when ssh-keyscan can\'t retrieve them' do
97
- with_test_platform(nodes: { 'test_node' => {} }) do
98
- with_cmd_runner_mocked([
101
+ with_test_platform({ nodes: { 'test_node' => {} } }) do
102
+ with_cmd_runner_mocked [
99
103
  ['ssh-keyscan 192.168.42.42', proc { [0, '', ''] }]
100
- ]) do
104
+ ] do
101
105
  expect(cmdb(:host_keys).get_host_keys(['test_node'], { 'test_node' => { host_ip: '192.168.42.42' } })).to eq({})
102
106
  end
103
107
  end
104
108
  end
105
109
 
106
110
  it 'returns host keys for the maximum hosts it can from the list' do
107
- with_test_platform(nodes: {
108
- 'test_node1' => {},
109
- 'test_node2' => {},
110
- 'test_node3' => {},
111
- 'test_node4' => {}
112
- }) do
113
- with_cmd_runner_mocked([
111
+ with_test_platform(
112
+ {
113
+ nodes: {
114
+ 'test_node1' => {},
115
+ 'test_node2' => {},
116
+ 'test_node3' => {},
117
+ 'test_node4' => {}
118
+ }
119
+ }
120
+ ) do
121
+ with_cmd_runner_mocked [
114
122
  ['ssh-keyscan 192.168.42.1', proc { [0, "192.168.42.1 ssh-rsa fake_host_key_1\n", ''] }],
115
123
  ['ssh-keyscan 192.168.42.2', proc { [0, '', ''] }],
116
- ['ssh-keyscan my_host_4.my_domain', proc { [0, "my_host_4.my_domain ssh-rsa fake_host_key_4\n", ''] }],
117
- ]) do
118
- expect(cmdb(:host_keys).get_host_keys(['test_node'], {
119
- 'test_node1' => { host_ip: '192.168.42.1' },
120
- 'test_node2' => { host_ip: '192.168.42.2' },
121
- 'test_node3' => {},
122
- 'test_node4' => { hostname: 'my_host_4.my_domain' }
123
- })).to eq(
124
+ ['ssh-keyscan my_host_4.my_domain', proc { [0, "my_host_4.my_domain ssh-rsa fake_host_key_4\n", ''] }]
125
+ ] do
126
+ expect(
127
+ cmdb(:host_keys).get_host_keys(
128
+ ['test_node'],
129
+ {
130
+ 'test_node1' => { host_ip: '192.168.42.1' },
131
+ 'test_node2' => { host_ip: '192.168.42.2' },
132
+ 'test_node3' => {},
133
+ 'test_node4' => { hostname: 'my_host_4.my_domain' }
134
+ }
135
+ )
136
+ ).to eq(
124
137
  'test_node1' => ['ssh-rsa fake_host_key_1'],
125
138
  'test_node4' => ['ssh-rsa fake_host_key_4']
126
139
  )