chef 14.15.6 → 18.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1900) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +50 -32
  3. data/README.md +18 -206
  4. data/Rakefile +57 -22
  5. data/chef-universal-mingw-ucrt.gemspec +23 -0
  6. data/chef.gemspec +54 -30
  7. data/lib/chef/action_collection.rb +255 -0
  8. data/lib/chef/api_client/registration.rb +14 -13
  9. data/lib/chef/api_client.rb +11 -11
  10. data/lib/chef/api_client_v1.rb +22 -13
  11. data/lib/chef/application/apply.rb +61 -39
  12. data/lib/chef/application/base.rb +480 -0
  13. data/lib/chef/application/client.rb +43 -424
  14. data/lib/chef/application/exit_code.rb +22 -34
  15. data/lib/chef/application/solo.rb +31 -275
  16. data/lib/chef/application.rb +100 -87
  17. data/lib/chef/applications.rb +3 -4
  18. data/lib/chef/{whitelist.rb → attribute_allowlist.rb} +13 -13
  19. data/lib/chef/{blacklist.rb → attribute_blocklist.rb} +12 -12
  20. data/lib/chef/chef_class.rb +12 -18
  21. data/lib/chef/chef_fs/chef_fs_data_store.rb +80 -72
  22. data/lib/chef/chef_fs/command_line.rb +20 -12
  23. data/lib/chef/chef_fs/config.rb +8 -7
  24. data/lib/chef/chef_fs/data_handler/acl_data_handler.rb +1 -1
  25. data/lib/chef/chef_fs/data_handler/client_data_handler.rb +2 -2
  26. data/lib/chef/chef_fs/data_handler/client_key_data_handler.rb +2 -2
  27. data/lib/chef/chef_fs/data_handler/container_data_handler.rb +2 -2
  28. data/lib/chef/chef_fs/data_handler/cookbook_data_handler.rb +3 -3
  29. data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +5 -5
  30. data/lib/chef/chef_fs/data_handler/data_handler_base.rb +1 -1
  31. data/lib/chef/chef_fs/data_handler/environment_data_handler.rb +2 -2
  32. data/lib/chef/chef_fs/data_handler/group_data_handler.rb +2 -2
  33. data/lib/chef/chef_fs/data_handler/node_data_handler.rb +2 -2
  34. data/lib/chef/chef_fs/data_handler/organization_data_handler.rb +3 -4
  35. data/lib/chef/chef_fs/data_handler/organization_invites_data_handler.rb +1 -1
  36. data/lib/chef/chef_fs/data_handler/organization_members_data_handler.rb +1 -1
  37. data/lib/chef/chef_fs/data_handler/policy_data_handler.rb +3 -3
  38. data/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb +1 -1
  39. data/lib/chef/chef_fs/data_handler/role_data_handler.rb +2 -2
  40. data/lib/chef/chef_fs/data_handler/user_data_handler.rb +1 -1
  41. data/lib/chef/chef_fs/file_pattern.rb +21 -15
  42. data/lib/chef/chef_fs/file_system/base_fs_dir.rb +3 -3
  43. data/lib/chef/chef_fs/file_system/base_fs_object.rb +17 -10
  44. data/lib/chef/chef_fs/file_system/chef_server/acl_dir.rb +4 -4
  45. data/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb +13 -13
  46. data/lib/chef/chef_fs/file_system/chef_server/acls_dir.rb +8 -8
  47. data/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb +26 -26
  48. data/lib/chef/chef_fs/file_system/chef_server/cookbook_artifact_dir.rb +2 -2
  49. data/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb +7 -7
  50. data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +16 -13
  51. data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +6 -6
  52. data/lib/chef/chef_fs/file_system/chef_server/cookbook_subdir.rb +3 -3
  53. data/lib/chef/chef_fs/file_system/chef_server/cookbooks_acl_dir.rb +2 -2
  54. data/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb +26 -13
  55. data/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb +8 -7
  56. data/lib/chef/chef_fs/file_system/chef_server/data_bag_entry.rb +2 -2
  57. data/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb +3 -3
  58. data/lib/chef/chef_fs/file_system/chef_server/environments_dir.rb +8 -6
  59. data/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb +5 -5
  60. data/lib/chef/chef_fs/file_system/chef_server/org_entry.rb +2 -2
  61. data/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb +11 -11
  62. data/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb +11 -11
  63. data/lib/chef/chef_fs/file_system/chef_server/policies_acl_dir.rb +2 -2
  64. data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +6 -5
  65. data/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb +8 -7
  66. data/lib/chef/chef_fs/file_system/chef_server/policy_groups_dir.rb +5 -5
  67. data/lib/chef/chef_fs/file_system/chef_server/policy_revision_entry.rb +2 -2
  68. data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +6 -5
  69. data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +12 -8
  70. data/lib/chef/chef_fs/file_system/chef_server/versioned_cookbook_dir.rb +3 -3
  71. data/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb +7 -7
  72. data/lib/chef/chef_fs/file_system/exceptions.rb +1 -1
  73. data/lib/chef/chef_fs/file_system/memory/memory_dir.rb +3 -3
  74. data/lib/chef/chef_fs/file_system/memory/memory_file.rb +1 -1
  75. data/lib/chef/chef_fs/file_system/memory/memory_root.rb +1 -1
  76. data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +3 -3
  77. data/lib/chef/chef_fs/file_system/nonexistent_fs_object.rb +3 -3
  78. data/lib/chef/chef_fs/file_system/repository/acl.rb +4 -4
  79. data/lib/chef/chef_fs/file_system/repository/acls_dir.rb +6 -6
  80. data/lib/chef/chef_fs/file_system/repository/acls_sub_dir.rb +4 -4
  81. data/lib/chef/chef_fs/file_system/repository/base_file.rb +5 -3
  82. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb +4 -4
  83. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +22 -12
  84. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +16 -13
  85. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +56 -54
  86. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb +5 -4
  87. data/lib/chef/chef_fs/file_system/repository/client.rb +3 -3
  88. data/lib/chef/chef_fs/file_system/repository/client_key.rb +3 -3
  89. data/lib/chef/chef_fs/file_system/repository/client_keys_dir.rb +4 -4
  90. data/lib/chef/chef_fs/file_system/repository/client_keys_sub_dir.rb +4 -4
  91. data/lib/chef/chef_fs/file_system/repository/clients_dir.rb +4 -4
  92. data/lib/chef/chef_fs/file_system/repository/container.rb +3 -3
  93. data/lib/chef/chef_fs/file_system/repository/containers_dir.rb +4 -4
  94. data/lib/chef/chef_fs/file_system/repository/cookbook_artifacts_dir.rb +3 -3
  95. data/lib/chef/chef_fs/file_system/repository/cookbooks_dir.rb +4 -4
  96. data/lib/chef/chef_fs/file_system/repository/data_bag.rb +3 -3
  97. data/lib/chef/chef_fs/file_system/repository/data_bag_item.rb +3 -3
  98. data/lib/chef/chef_fs/file_system/repository/data_bags_dir.rb +3 -3
  99. data/lib/chef/chef_fs/file_system/repository/directory.rb +9 -5
  100. data/lib/chef/chef_fs/file_system/repository/environment.rb +3 -3
  101. data/lib/chef/chef_fs/file_system/repository/environments_dir.rb +4 -4
  102. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +11 -9
  103. data/lib/chef/chef_fs/file_system/repository/group.rb +3 -3
  104. data/lib/chef/chef_fs/file_system/repository/groups_dir.rb +4 -4
  105. data/lib/chef/chef_fs/file_system/repository/node.rb +3 -3
  106. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +6 -6
  107. data/lib/chef/chef_fs/file_system/repository/policies_dir.rb +4 -4
  108. data/lib/chef/chef_fs/file_system/repository/policy.rb +3 -3
  109. data/lib/chef/chef_fs/file_system/repository/policy_group.rb +3 -3
  110. data/lib/chef/chef_fs/file_system/repository/policy_groups_dir.rb +4 -4
  111. data/lib/chef/chef_fs/file_system/repository/role.rb +3 -3
  112. data/lib/chef/chef_fs/file_system/repository/roles_dir.rb +4 -4
  113. data/lib/chef/chef_fs/file_system/repository/user.rb +3 -3
  114. data/lib/chef/chef_fs/file_system/repository/users_dir.rb +4 -4
  115. data/lib/chef/chef_fs/file_system/repository/versioned_cookbooks_dir.rb +3 -3
  116. data/lib/chef/chef_fs/file_system.rb +36 -22
  117. data/lib/chef/chef_fs/file_system_cache.rb +4 -3
  118. data/lib/chef/chef_fs/path_utils.rb +13 -10
  119. data/lib/chef/chef_fs.rb +2 -2
  120. data/lib/chef/client.rb +327 -273
  121. data/lib/chef/compliance/default_attributes.rb +110 -0
  122. data/lib/chef/compliance/fetcher/automate.rb +73 -0
  123. data/lib/chef/compliance/fetcher/chef_server.rb +134 -0
  124. data/lib/chef/compliance/input.rb +115 -0
  125. data/lib/chef/compliance/input_collection.rb +139 -0
  126. data/lib/chef/compliance/profile.rb +122 -0
  127. data/lib/chef/compliance/profile_collection.rb +108 -0
  128. data/lib/chef/compliance/reporter/automate.rb +211 -0
  129. data/lib/chef/compliance/reporter/chef_server_automate.rb +99 -0
  130. data/lib/chef/compliance/reporter/cli.rb +77 -0
  131. data/lib/chef/compliance/reporter/compliance_enforcer.rb +24 -0
  132. data/lib/chef/compliance/reporter/json_file.rb +26 -0
  133. data/lib/chef/compliance/runner.rb +409 -0
  134. data/lib/chef/compliance/waiver.rb +115 -0
  135. data/lib/chef/compliance/waiver_collection.rb +143 -0
  136. data/lib/chef/config.rb +7 -6
  137. data/lib/chef/config_fetcher.rb +4 -4
  138. data/lib/chef/constants.rb +1 -1
  139. data/lib/chef/cookbook/chefignore.rb +19 -15
  140. data/lib/chef/cookbook/cookbook_collection.rb +3 -4
  141. data/lib/chef/cookbook/cookbook_version_loader.rb +91 -71
  142. data/lib/chef/cookbook/file_system_file_vendor.rb +4 -4
  143. data/lib/chef/cookbook/file_vendor.rb +2 -2
  144. data/lib/chef/cookbook/gem_installer.rb +12 -9
  145. data/lib/chef/cookbook/manifest_v0.rb +4 -3
  146. data/lib/chef/cookbook/manifest_v2.rb +3 -3
  147. data/lib/chef/cookbook/metadata.rb +92 -118
  148. data/lib/chef/cookbook/remote_file_vendor.rb +6 -8
  149. data/lib/chef/cookbook/synchronizer.rb +31 -14
  150. data/lib/chef/cookbook/syntax_check.rb +20 -16
  151. data/lib/chef/cookbook_loader.rb +130 -115
  152. data/lib/chef/cookbook_manifest.rb +14 -11
  153. data/lib/chef/cookbook_uploader.rb +16 -15
  154. data/lib/chef/cookbook_version.rb +104 -32
  155. data/lib/chef/daemon.rb +4 -4
  156. data/lib/chef/data_bag.rb +19 -19
  157. data/lib/chef/data_bag_item.rb +31 -19
  158. data/lib/chef/data_collector/config_validation.rb +140 -0
  159. data/lib/chef/data_collector/error_handlers.rb +116 -0
  160. data/lib/chef/data_collector/message_helpers.rb +50 -0
  161. data/lib/chef/data_collector/run_end_message.rb +191 -0
  162. data/lib/chef/data_collector/run_start_message.rb +60 -0
  163. data/lib/chef/data_collector.rb +189 -464
  164. data/lib/chef/decorator/lazy.rb +2 -2
  165. data/lib/chef/decorator/lazy_array.rb +4 -4
  166. data/lib/chef/decorator.rb +5 -6
  167. data/lib/chef/delayed_evaluator.rb +5 -1
  168. data/lib/chef/deprecated.rb +48 -20
  169. data/lib/chef/deprecation/warnings.rb +4 -3
  170. data/lib/chef/digester.rb +8 -7
  171. data/lib/chef/dsl/chef_vault.rb +84 -0
  172. data/lib/chef/dsl/cheffish.rb +1 -1
  173. data/lib/chef/{knife/environment_edit.rb → dsl/compliance.rb} +13 -19
  174. data/lib/chef/dsl/data_query.rb +7 -7
  175. data/lib/chef/dsl/declare_resource.rb +25 -26
  176. data/lib/chef/dsl/include_attribute.rb +2 -2
  177. data/lib/chef/dsl/include_recipe.rb +2 -8
  178. data/lib/chef/dsl/platform_introspection.rb +26 -30
  179. data/lib/chef/dsl/powershell.rb +2 -2
  180. data/lib/chef/{knife/node_from_file.rb → dsl/reader_helpers.rb} +24 -24
  181. data/lib/chef/dsl/reboot_pending.rb +9 -10
  182. data/lib/chef/dsl/recipe.rb +16 -21
  183. data/lib/chef/dsl/registry_helper.rb +1 -1
  184. data/lib/chef/dsl/render_helpers.rb +44 -0
  185. data/lib/chef/dsl/resources.rb +5 -7
  186. data/lib/chef/dsl/rest_resource.rb +77 -0
  187. data/lib/chef/dsl/secret.rb +170 -0
  188. data/lib/chef/dsl/toml.rb +116 -0
  189. data/lib/chef/dsl/universal.rb +19 -16
  190. data/lib/chef/dsl.rb +7 -6
  191. data/lib/chef/encrypted_data_bag_item/assertions.rb +4 -4
  192. data/lib/chef/encrypted_data_bag_item/check_encrypted.rb +3 -2
  193. data/lib/chef/encrypted_data_bag_item/decryption_failure.rb +1 -1
  194. data/lib/chef/encrypted_data_bag_item/decryptor.rb +52 -45
  195. data/lib/chef/encrypted_data_bag_item/encryptor.rb +11 -10
  196. data/lib/chef/encrypted_data_bag_item/unacceptable_encrypted_data_bag_item_format.rb +1 -1
  197. data/lib/chef/encrypted_data_bag_item/unsupported_cipher.rb +1 -1
  198. data/lib/chef/encrypted_data_bag_item/unsupported_encrypted_data_bag_item_format.rb +1 -1
  199. data/lib/chef/encrypted_data_bag_item.rb +13 -10
  200. data/lib/chef/environment.rb +19 -17
  201. data/lib/chef/event_dispatch/base.rb +145 -196
  202. data/lib/chef/event_dispatch/dispatcher.rb +50 -16
  203. data/lib/chef/event_dispatch/dsl.rb +3 -3
  204. data/lib/chef/event_loggers/base.rb +4 -3
  205. data/lib/chef/event_loggers/windows_eventlog.rb +8 -7
  206. data/lib/chef/exceptions.rb +65 -35
  207. data/lib/chef/file_access_control/unix.rb +9 -6
  208. data/lib/chef/file_access_control/windows.rb +32 -22
  209. data/lib/chef/file_access_control.rb +5 -5
  210. data/lib/chef/file_cache.rb +13 -12
  211. data/lib/chef/file_content_management/content_base.rb +1 -1
  212. data/lib/chef/file_content_management/deploy/cp.rb +1 -1
  213. data/lib/chef/file_content_management/deploy/mv_unix.rb +2 -2
  214. data/lib/chef/file_content_management/deploy/mv_windows.rb +4 -4
  215. data/lib/chef/file_content_management/deploy.rb +7 -7
  216. data/lib/chef/file_content_management/tempfile.rb +13 -13
  217. data/lib/chef/formatters/base.rb +11 -12
  218. data/lib/chef/formatters/doc.rb +91 -96
  219. data/lib/chef/formatters/error_description.rb +2 -2
  220. data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +17 -15
  221. data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +4 -4
  222. data/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb +7 -6
  223. data/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb +2 -2
  224. data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +11 -10
  225. data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +24 -23
  226. data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +31 -30
  227. data/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb +11 -10
  228. data/lib/chef/formatters/error_inspectors.rb +7 -7
  229. data/lib/chef/formatters/error_mapper.rb +3 -3
  230. data/lib/chef/formatters/indentable_output_stream.rb +11 -20
  231. data/lib/chef/formatters/minimal.rb +31 -48
  232. data/lib/chef/group.rb +75 -0
  233. data/lib/chef/guard_interpreter/default_guard_interpreter.rb +5 -6
  234. data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +32 -43
  235. data/lib/chef/guard_interpreter.rb +3 -3
  236. data/lib/chef/handler/error_report.rb +3 -3
  237. data/lib/chef/handler/json_file.rb +4 -4
  238. data/lib/chef/handler/slow_report.rb +66 -0
  239. data/lib/chef/handler.rb +52 -13
  240. data/lib/chef/http/api_versions.rb +4 -5
  241. data/lib/chef/http/auth_credentials.rb +8 -3
  242. data/lib/chef/http/authenticator.rb +176 -7
  243. data/lib/chef/http/basic_client.rb +23 -13
  244. data/lib/chef/http/cookie_jar.rb +2 -2
  245. data/lib/chef/http/cookie_manager.rb +2 -2
  246. data/lib/chef/http/decompressor.rb +5 -4
  247. data/lib/chef/http/http_request.rb +13 -9
  248. data/lib/chef/http/json_input.rb +2 -2
  249. data/lib/chef/http/json_output.rb +7 -6
  250. data/lib/chef/http/json_to_model_output.rb +3 -3
  251. data/lib/chef/http/remote_request_id.rb +3 -4
  252. data/lib/chef/http/simple.rb +6 -6
  253. data/lib/chef/http/simple_json.rb +6 -6
  254. data/lib/chef/http/socketless_chef_zero_client.rb +17 -12
  255. data/lib/chef/http/ssl_policies.rb +58 -18
  256. data/lib/chef/http/validate_content_length.rb +5 -5
  257. data/lib/chef/http.rb +72 -56
  258. data/lib/chef/json_compat.rb +8 -13
  259. data/lib/chef/key.rb +15 -13
  260. data/lib/chef/local_mode.rb +8 -10
  261. data/lib/chef/log/syslog.rb +6 -5
  262. data/lib/chef/log/winevt.rb +7 -7
  263. data/lib/chef/log.rb +12 -7
  264. data/lib/chef/mash.rb +21 -232
  265. data/lib/chef/mixin/api_version_request_handling.rb +8 -8
  266. data/lib/chef/mixin/checksum.rb +8 -3
  267. data/lib/chef/{knife/cookbook_create.rb → mixin/chef_utils_wiring.rb} +20 -9
  268. data/lib/chef/mixin/convert_to_class_name.rb +2 -57
  269. data/lib/chef/mixin/create_path.rb +11 -11
  270. data/lib/chef/mixin/deep_merge.rb +41 -24
  271. data/lib/chef/{resource/user/dscl_user.rb → mixin/default_paths.rb} +9 -8
  272. data/lib/chef/mixin/deprecation.rb +1 -1
  273. data/lib/chef/mixin/enforce_ownership_and_permissions.rb +2 -2
  274. data/lib/chef/mixin/file_class.rb +3 -3
  275. data/lib/chef/mixin/from_file.rb +3 -3
  276. data/lib/chef/mixin/get_source_from_package.rb +3 -2
  277. data/lib/chef/mixin/homebrew_user.rb +6 -5
  278. data/lib/chef/mixin/lazy_module_include.rb +1 -1
  279. data/lib/chef/mixin/notifying_block.rb +1 -1
  280. data/lib/chef/mixin/openssl_helper.rb +69 -23
  281. data/lib/chef/mixin/params_validate.rb +26 -18
  282. data/lib/chef/mixin/path_sanity.rb +5 -40
  283. data/lib/chef/mixin/powershell_exec.rb +17 -16
  284. data/lib/chef/mixin/powershell_out.rb +16 -9
  285. data/lib/chef/mixin/powershell_type_coercions.rb +3 -3
  286. data/lib/chef/mixin/properties.rb +75 -18
  287. data/lib/chef/mixin/provides.rb +1 -1
  288. data/lib/chef/mixin/proxified_socket.rb +1 -1
  289. data/lib/chef/mixin/securable.rb +12 -12
  290. data/lib/chef/mixin/shell_out.rb +5 -235
  291. data/lib/chef/mixin/subclass_directive.rb +1 -1
  292. data/lib/chef/mixin/template.rb +8 -6
  293. data/lib/chef/mixin/unformatter.rb +2 -2
  294. data/lib/chef/mixin/uris.rb +5 -3
  295. data/lib/chef/mixin/user_context.rb +4 -4
  296. data/lib/chef/mixin/versioned_api.rb +2 -3
  297. data/lib/chef/mixin/which.rb +13 -26
  298. data/lib/chef/mixin/why_run.rb +9 -3
  299. data/lib/chef/mixin/wide_string.rb +1 -1
  300. data/lib/chef/mixin/windows_architecture_helper.rb +12 -12
  301. data/lib/chef/mixin/windows_env_helper.rb +10 -10
  302. data/lib/chef/mixin/xml_escape.rb +8 -8
  303. data/lib/chef/mixins.rb +13 -12
  304. data/lib/chef/monkey_patches/webrick-utils.rb +16 -14
  305. data/lib/chef/monkey_patches/win32/registry.rb +4 -30
  306. data/lib/chef/monologger.rb +1 -1
  307. data/lib/chef/node/attribute.rb +178 -146
  308. data/lib/chef/node/attribute_collections.rb +25 -56
  309. data/lib/chef/node/common_api.rb +12 -4
  310. data/lib/chef/node/immutable_collections.rb +32 -7
  311. data/lib/chef/node/mixin/deep_merge_cache.rb +22 -18
  312. data/lib/chef/node/mixin/immutablize_array.rb +148 -143
  313. data/lib/chef/node/mixin/immutablize_hash.rb +137 -131
  314. data/lib/chef/node/mixin/mashy_array.rb +68 -0
  315. data/lib/chef/node/mixin/state_tracking.rb +1 -1
  316. data/lib/chef/node.rb +147 -61
  317. data/lib/chef/node_map.rb +66 -50
  318. data/lib/chef/null_logger.rb +9 -17
  319. data/lib/chef/org.rb +10 -9
  320. data/lib/chef/platform/priority_map.rb +6 -6
  321. data/lib/chef/platform/provider_handler_map.rb +3 -3
  322. data/lib/chef/platform/provider_mapping.rb +6 -6
  323. data/lib/chef/platform/provider_priority_map.rb +2 -2
  324. data/lib/chef/platform/query_helpers.rb +16 -39
  325. data/lib/chef/platform/rebooter.rb +7 -7
  326. data/lib/chef/platform/resource_handler_map.rb +3 -3
  327. data/lib/chef/platform/resource_priority_map.rb +2 -2
  328. data/lib/chef/platform/service_helpers.rb +27 -92
  329. data/lib/chef/platform.rb +3 -3
  330. data/lib/chef/policy_builder/dynamic.rb +11 -8
  331. data/lib/chef/policy_builder/expand_node_object.rb +45 -37
  332. data/lib/chef/policy_builder/policyfile.rb +112 -66
  333. data/lib/chef/policy_builder.rb +4 -4
  334. data/lib/chef/powershell.rb +34 -10
  335. data/lib/chef/property.rb +69 -23
  336. data/lib/chef/provider/batch.rb +5 -12
  337. data/lib/chef/provider/cookbook_file/content.rb +3 -3
  338. data/lib/chef/provider/cookbook_file.rb +3 -2
  339. data/lib/chef/provider/cron/aix.rb +11 -4
  340. data/lib/chef/provider/cron/solaris.rb +2 -2
  341. data/lib/chef/provider/cron/unix.rb +4 -5
  342. data/lib/chef/provider/cron.rb +75 -45
  343. data/lib/chef/provider/directory.rb +16 -16
  344. data/lib/chef/provider/dsc_resource.rb +19 -32
  345. data/lib/chef/provider/dsc_script.rb +23 -27
  346. data/lib/chef/provider/execute.rb +11 -15
  347. data/lib/chef/provider/file/content.rb +3 -3
  348. data/lib/chef/provider/file.rb +41 -33
  349. data/lib/chef/provider/git.rb +108 -42
  350. data/lib/chef/provider/group/aix.rb +3 -1
  351. data/lib/chef/provider/group/dscl.rb +10 -7
  352. data/lib/chef/provider/group/gpasswd.rb +2 -2
  353. data/lib/chef/provider/group/groupadd.rb +5 -4
  354. data/lib/chef/provider/group/groupmod.rb +4 -4
  355. data/lib/chef/provider/group/pw.rb +5 -5
  356. data/lib/chef/provider/group/solaris.rb +62 -0
  357. data/lib/chef/provider/group/usermod.rb +5 -10
  358. data/lib/chef/provider/group/windows.rb +16 -5
  359. data/lib/chef/provider/group.rb +28 -18
  360. data/lib/chef/provider/http_request.rb +21 -19
  361. data/lib/chef/provider/ifconfig/aix.rb +3 -2
  362. data/lib/chef/provider/ifconfig/debian.rb +42 -25
  363. data/lib/chef/provider/ifconfig/redhat.rb +56 -20
  364. data/lib/chef/provider/ifconfig.rb +38 -35
  365. data/lib/chef/provider/launchd.rb +57 -81
  366. data/lib/chef/provider/link.rb +17 -26
  367. data/lib/chef/provider/lwrp_base.rb +6 -7
  368. data/lib/chef/provider/mount/aix.rb +12 -12
  369. data/lib/chef/provider/mount/linux.rb +86 -0
  370. data/lib/chef/provider/mount/mount.rb +61 -54
  371. data/lib/chef/provider/mount/solaris.rb +9 -10
  372. data/lib/chef/provider/mount/windows.rb +6 -6
  373. data/lib/chef/provider/mount.rb +37 -16
  374. data/lib/chef/provider/noop.rb +2 -2
  375. data/lib/chef/provider/package/apt.rb +42 -30
  376. data/lib/chef/provider/package/bff.rb +5 -4
  377. data/lib/chef/provider/package/cab.rb +15 -14
  378. data/lib/chef/provider/package/chocolatey.rb +39 -39
  379. data/lib/chef/provider/package/deb.rb +131 -0
  380. data/lib/chef/provider/package/dnf/dnf_helper.py +107 -30
  381. data/lib/chef/provider/package/dnf/python_helper.rb +97 -49
  382. data/lib/chef/provider/package/dnf/version.rb +6 -2
  383. data/lib/chef/provider/package/dnf.rb +109 -26
  384. data/lib/chef/provider/package/dpkg.rb +15 -38
  385. data/lib/chef/provider/package/freebsd/base.rb +10 -7
  386. data/lib/chef/provider/package/freebsd/pkgng.rb +7 -5
  387. data/lib/chef/provider/package/freebsd/port.rb +2 -6
  388. data/lib/chef/provider/package/habitat.rb +168 -0
  389. data/lib/chef/provider/package/homebrew.rb +110 -47
  390. data/lib/chef/provider/package/ips.rb +4 -4
  391. data/lib/chef/provider/package/macports.rb +1 -2
  392. data/lib/chef/provider/package/msu.rb +15 -10
  393. data/lib/chef/provider/package/openbsd.rb +6 -6
  394. data/lib/chef/provider/package/pacman.rb +27 -36
  395. data/lib/chef/provider/package/paludis.rb +4 -3
  396. data/lib/chef/provider/package/portage.rb +11 -10
  397. data/lib/chef/provider/package/powershell.rb +29 -17
  398. data/lib/chef/provider/package/rpm.rb +6 -5
  399. data/lib/chef/provider/package/rubygems.rb +84 -57
  400. data/lib/chef/provider/package/smartos.rb +4 -3
  401. data/lib/chef/provider/package/snap.rb +427 -0
  402. data/lib/chef/provider/package/solaris.rb +6 -6
  403. data/lib/chef/provider/package/windows/exe.rb +7 -7
  404. data/lib/chef/provider/package/windows/msi.rb +14 -13
  405. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +14 -11
  406. data/lib/chef/provider/package/windows.rb +40 -61
  407. data/lib/chef/provider/package/yum/python_helper.rb +126 -46
  408. data/lib/chef/provider/package/yum/rpm_utils.rb +13 -23
  409. data/lib/chef/provider/package/yum/version.rb +5 -1
  410. data/lib/chef/provider/package/yum/yum_cache.rb +5 -5
  411. data/lib/chef/provider/package/yum/yum_helper.py +72 -91
  412. data/lib/chef/provider/package/yum.rb +57 -40
  413. data/lib/chef/provider/package/zypper/version.rb +60 -0
  414. data/lib/chef/provider/package/zypper.rb +147 -75
  415. data/lib/chef/provider/package.rb +141 -159
  416. data/lib/chef/provider/powershell_script.rb +48 -61
  417. data/lib/chef/provider/registry_key.rb +22 -20
  418. data/lib/chef/provider/remote_directory.rb +18 -18
  419. data/lib/chef/provider/remote_file/cache_control_data.rb +6 -6
  420. data/lib/chef/provider/remote_file/content.rb +8 -5
  421. data/lib/chef/provider/remote_file/fetcher.rb +4 -3
  422. data/lib/chef/provider/remote_file/ftp.rb +10 -7
  423. data/lib/chef/provider/remote_file/http.rb +9 -6
  424. data/lib/chef/provider/remote_file/local_file.rb +7 -6
  425. data/lib/chef/provider/remote_file/network_file.rb +4 -4
  426. data/lib/chef/provider/remote_file/sftp.rb +10 -7
  427. data/lib/chef/provider/remote_file.rb +12 -11
  428. data/lib/chef/provider/route.rb +55 -55
  429. data/lib/chef/provider/ruby_block.rb +3 -3
  430. data/lib/chef/provider/script.rb +7 -82
  431. data/lib/chef/provider/service/aix.rb +2 -2
  432. data/lib/chef/provider/service/aixinit.rb +5 -5
  433. data/lib/chef/provider/service/arch.rb +7 -6
  434. data/lib/chef/provider/service/debian.rb +53 -49
  435. data/lib/chef/provider/service/freebsd.rb +19 -25
  436. data/lib/chef/provider/service/gentoo.rb +5 -5
  437. data/lib/chef/provider/service/init.rb +4 -4
  438. data/lib/chef/provider/service/insserv.rb +6 -6
  439. data/lib/chef/provider/service/invokercd.rb +5 -5
  440. data/lib/chef/provider/service/macosx.rb +32 -26
  441. data/lib/chef/provider/service/openbsd.rb +11 -14
  442. data/lib/chef/provider/service/redhat.rb +13 -13
  443. data/lib/chef/provider/service/simple.rb +7 -6
  444. data/lib/chef/provider/service/solaris.rb +3 -3
  445. data/lib/chef/provider/service/systemd.rb +62 -32
  446. data/lib/chef/provider/service/upstart.rb +11 -21
  447. data/lib/chef/provider/service/windows.rb +56 -64
  448. data/lib/chef/provider/service.rb +29 -26
  449. data/lib/chef/provider/subversion.rb +50 -29
  450. data/lib/chef/provider/support/yum_repo.erb +2 -2
  451. data/lib/chef/provider/support/zypper_repo.erb +4 -2
  452. data/lib/chef/provider/systemd_unit.rb +68 -41
  453. data/lib/chef/provider/template/content.rb +7 -10
  454. data/lib/chef/provider/template.rb +5 -4
  455. data/lib/chef/provider/template_finder.rb +3 -11
  456. data/lib/chef/provider/user/aix.rb +13 -5
  457. data/lib/chef/provider/user/dscl.rb +66 -141
  458. data/lib/chef/provider/user/linux.rb +41 -6
  459. data/lib/chef/provider/user/mac.rb +677 -0
  460. data/lib/chef/provider/user/pw.rb +4 -3
  461. data/lib/chef/provider/user/solaris.rb +6 -4
  462. data/lib/chef/provider/user/windows.rb +19 -13
  463. data/lib/chef/provider/user.rb +78 -30
  464. data/lib/chef/provider/whyrun_safe_ruby_block.rb +1 -1
  465. data/lib/chef/provider/windows_script.rb +91 -29
  466. data/lib/chef/provider/yum_repository.rb +46 -51
  467. data/lib/chef/provider/zypper_repository.rb +70 -55
  468. data/lib/chef/provider.rb +121 -47
  469. data/lib/chef/provider_resolver.rb +11 -5
  470. data/lib/chef/providers.rb +111 -120
  471. data/lib/chef/pwsh.rb +72 -0
  472. data/lib/chef/recipe.rb +43 -21
  473. data/lib/chef/request_id.rb +3 -3
  474. data/lib/chef/resource/_rest_resource.rb +389 -0
  475. data/lib/chef/resource/action_class.rb +28 -26
  476. data/lib/chef/resource/alternatives.rb +209 -0
  477. data/lib/chef/resource/apt_package.rb +50 -10
  478. data/lib/chef/resource/apt_preference.rb +109 -14
  479. data/lib/chef/resource/apt_repository.rb +426 -27
  480. data/lib/chef/resource/apt_update.rb +73 -6
  481. data/lib/chef/resource/archive_file.rb +206 -0
  482. data/lib/chef/resource/bash.rb +124 -4
  483. data/lib/chef/resource/batch.rb +8 -5
  484. data/lib/chef/resource/bff_package.rb +33 -4
  485. data/lib/chef/resource/breakpoint.rb +64 -6
  486. data/lib/chef/resource/build_essential.rb +102 -62
  487. data/lib/chef/resource/cab_package.rb +48 -13
  488. data/lib/chef/resource/chef_client_config.rb +341 -0
  489. data/lib/chef/resource/chef_client_cron.rb +234 -0
  490. data/lib/chef/resource/chef_client_launchd.rb +194 -0
  491. data/lib/chef/resource/chef_client_scheduled_task.rb +259 -0
  492. data/lib/chef/resource/chef_client_systemd_timer.rb +186 -0
  493. data/lib/chef/resource/chef_client_trusted_certificate.rb +101 -0
  494. data/lib/chef/resource/chef_gem.rb +69 -34
  495. data/lib/chef/resource/chef_handler.rb +165 -19
  496. data/lib/chef/resource/chef_sleep.rb +70 -0
  497. data/lib/chef/resource/chef_vault_secret.rb +129 -0
  498. data/lib/chef/resource/chocolatey_config.rb +28 -14
  499. data/lib/chef/resource/chocolatey_feature.rb +92 -0
  500. data/lib/chef/resource/chocolatey_package.rb +45 -13
  501. data/lib/chef/resource/chocolatey_source.rb +81 -13
  502. data/lib/chef/resource/conditional.rb +3 -3
  503. data/lib/chef/resource/cookbook_file.rb +12 -10
  504. data/lib/chef/resource/cron/_cron_shared.rb +98 -0
  505. data/lib/chef/resource/cron/cron.rb +119 -0
  506. data/lib/chef/resource/cron/cron_d.rb +201 -0
  507. data/lib/chef/resource/cron_access.rb +44 -15
  508. data/lib/chef/resource/csh.rb +8 -6
  509. data/lib/chef/resource/directory.rb +9 -8
  510. data/lib/chef/resource/dmg_package.rb +71 -43
  511. data/lib/chef/resource/dnf_package.rb +28 -31
  512. data/lib/chef/resource/dpkg_package.rb +18 -5
  513. data/lib/chef/resource/dsc_resource.rb +14 -13
  514. data/lib/chef/resource/dsc_script.rb +23 -10
  515. data/lib/chef/resource/execute.rb +520 -46
  516. data/lib/chef/resource/file/verification/json.rb +50 -0
  517. data/lib/chef/resource/file/verification/systemd_unit.rb +3 -2
  518. data/lib/chef/resource/file/verification/yaml.rb +52 -0
  519. data/lib/chef/resource/file/verification.rb +11 -6
  520. data/lib/chef/resource/file.rb +26 -20
  521. data/lib/chef/resource/freebsd_package.rb +10 -29
  522. data/lib/chef/resource/gem_package.rb +59 -15
  523. data/lib/chef/resource/group.rb +40 -14
  524. data/lib/chef/{knife/recipe_list.rb → resource/habitat/_habitat_shared.rb} +13 -17
  525. data/lib/chef/resource/habitat/habitat_package.rb +128 -0
  526. data/lib/chef/resource/habitat/habitat_sup.rb +328 -0
  527. data/lib/chef/resource/habitat/habitat_sup_systemd.rb +67 -0
  528. data/lib/chef/resource/habitat/habitat_sup_windows.rb +90 -0
  529. data/lib/chef/resource/habitat_config.rb +106 -0
  530. data/lib/chef/resource/habitat_install.rb +246 -0
  531. data/lib/chef/resource/habitat_service.rb +450 -0
  532. data/lib/chef/resource/habitat_user_toml.rb +91 -0
  533. data/lib/chef/resource/helpers/cron_validations.rb +101 -0
  534. data/lib/chef/resource/homebrew_cask.rb +46 -36
  535. data/lib/chef/resource/homebrew_package.rb +39 -7
  536. data/lib/chef/resource/homebrew_tap.rb +27 -31
  537. data/lib/chef/resource/homebrew_update.rb +108 -0
  538. data/lib/chef/resource/hostname.rb +128 -88
  539. data/lib/chef/resource/http_request.rb +5 -5
  540. data/lib/chef/resource/ifconfig.rb +83 -35
  541. data/lib/chef/resource/inspec_input.rb +126 -0
  542. data/lib/chef/resource/inspec_waiver.rb +183 -0
  543. data/lib/chef/resource/inspec_waiver_file_entry.rb +155 -0
  544. data/lib/chef/resource/ips_package.rb +15 -8
  545. data/lib/chef/resource/kernel_module.rb +80 -36
  546. data/lib/chef/resource/ksh.rb +9 -6
  547. data/lib/chef/resource/launchd.rb +114 -110
  548. data/lib/chef/resource/link.rb +18 -40
  549. data/lib/chef/resource/locale.rb +145 -57
  550. data/lib/chef/resource/log.rb +21 -8
  551. data/lib/chef/resource/lwrp_base.rb +31 -16
  552. data/lib/chef/resource/macos_userdefaults.rb +112 -83
  553. data/lib/chef/resource/macosx_service.rb +4 -8
  554. data/lib/chef/resource/macports_package.rb +13 -4
  555. data/lib/chef/resource/mdadm.rb +122 -17
  556. data/lib/chef/resource/mount.rb +37 -28
  557. data/lib/chef/resource/msu_package.rb +28 -12
  558. data/lib/chef/resource/notify_group.rb +72 -0
  559. data/lib/chef/resource/ohai.rb +66 -9
  560. data/lib/chef/resource/ohai_hint.rb +46 -23
  561. data/lib/chef/resource/openbsd_package.rb +31 -8
  562. data/lib/chef/resource/openssl_dhparam.rb +53 -23
  563. data/lib/chef/resource/openssl_ec_private_key.rb +49 -27
  564. data/lib/chef/resource/openssl_ec_public_key.rb +37 -20
  565. data/lib/chef/resource/openssl_rsa_private_key.rb +47 -27
  566. data/lib/chef/resource/openssl_rsa_public_key.rb +38 -19
  567. data/lib/chef/resource/openssl_x509_certificate.rb +139 -98
  568. data/lib/chef/resource/openssl_x509_crl.rb +46 -30
  569. data/lib/chef/resource/openssl_x509_request.rb +84 -52
  570. data/lib/chef/resource/osx_profile.rb +297 -11
  571. data/lib/chef/resource/package.rb +13 -21
  572. data/lib/chef/resource/pacman_package.rb +5 -3
  573. data/lib/chef/resource/paludis_package.rb +16 -8
  574. data/lib/chef/resource/perl.rb +8 -6
  575. data/lib/chef/resource/plist.rb +226 -0
  576. data/lib/chef/resource/portage_package.rb +17 -6
  577. data/lib/chef/resource/powershell_package.rb +11 -14
  578. data/lib/chef/resource/powershell_package_source.rb +246 -83
  579. data/lib/chef/resource/powershell_script.rb +46 -22
  580. data/lib/chef/resource/python.rb +8 -6
  581. data/lib/chef/resource/reboot.rb +84 -10
  582. data/lib/chef/resource/registry_key.rb +128 -47
  583. data/lib/chef/resource/remote_directory.rb +44 -45
  584. data/lib/chef/resource/remote_file.rb +141 -27
  585. data/lib/chef/resource/resource_notification.rb +6 -5
  586. data/lib/chef/resource/rhsm_errata.rb +28 -12
  587. data/lib/chef/resource/rhsm_errata_level.rb +25 -16
  588. data/lib/chef/resource/rhsm_register.rb +122 -41
  589. data/lib/chef/resource/rhsm_repo.rb +25 -14
  590. data/lib/chef/resource/rhsm_subscription.rb +16 -20
  591. data/lib/chef/resource/route.rb +30 -17
  592. data/lib/chef/resource/rpm_package.rb +15 -4
  593. data/lib/chef/resource/ruby.rb +6 -8
  594. data/lib/chef/resource/ruby_block.rb +109 -8
  595. data/lib/chef/resource/scm/_scm.rb +48 -0
  596. data/lib/chef/resource/scm/git.rb +142 -0
  597. data/lib/chef/resource/scm/subversion.rb +71 -0
  598. data/lib/chef/resource/script.rb +13 -9
  599. data/lib/chef/resource/selinux/common_helpers.rb +47 -0
  600. data/lib/chef/resource/selinux/selinux_debian.erb +18 -0
  601. data/lib/chef/resource/selinux/selinux_default.erb +15 -0
  602. data/lib/chef/resource/selinux_boolean.rb +101 -0
  603. data/lib/chef/resource/selinux_fcontext.rb +160 -0
  604. data/lib/chef/resource/selinux_install.rb +107 -0
  605. data/lib/chef/resource/selinux_module.rb +143 -0
  606. data/lib/chef/resource/selinux_permissive.rb +64 -0
  607. data/lib/chef/resource/selinux_port.rb +118 -0
  608. data/lib/chef/resource/selinux_state.rb +166 -0
  609. data/lib/chef/resource/service.rb +64 -162
  610. data/lib/chef/resource/smartos_package.rb +13 -4
  611. data/lib/chef/{knife/data_bag_list.rb → resource/snap_package.rb} +14 -17
  612. data/lib/chef/resource/solaris_package.rb +13 -6
  613. data/lib/chef/resource/ssh_known_hosts_entry.rb +47 -33
  614. data/lib/chef/resource/sudo.rb +92 -60
  615. data/lib/chef/resource/support/HabService.dll.config.erb +19 -0
  616. data/lib/chef/resource/support/client.erb +77 -0
  617. data/lib/chef/resource/support/cron.d.erb +1 -1
  618. data/lib/chef/resource/support/cron_access.erb +1 -1
  619. data/lib/chef/resource/support/sudoer.erb +1 -2
  620. data/lib/chef/resource/support/sup.toml.erb +179 -0
  621. data/lib/chef/resource/support/ulimit.erb +41 -0
  622. data/lib/chef/resource/swap_file.rb +35 -21
  623. data/lib/chef/resource/sysctl.rb +115 -38
  624. data/lib/chef/resource/systemd_unit.rb +60 -17
  625. data/lib/chef/resource/template.rb +15 -14
  626. data/lib/chef/resource/timezone.rb +128 -88
  627. data/lib/chef/resource/user/aix_user.rb +2 -3
  628. data/lib/chef/resource/user/linux_user.rb +2 -3
  629. data/lib/chef/resource/user/mac_user.rb +121 -0
  630. data/lib/chef/resource/user/pw_user.rb +2 -3
  631. data/lib/chef/resource/user/solaris_user.rb +2 -3
  632. data/lib/chef/resource/user/windows_user.rb +9 -5
  633. data/lib/chef/resource/user.rb +55 -127
  634. data/lib/chef/resource/user_ulimit.rb +116 -0
  635. data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
  636. data/lib/chef/resource/windows_ad_join.rb +149 -33
  637. data/lib/chef/resource/windows_audit_policy.rb +230 -0
  638. data/lib/chef/resource/windows_auto_run.rb +26 -18
  639. data/lib/chef/resource/windows_certificate.rb +319 -120
  640. data/lib/chef/resource/windows_defender.rb +162 -0
  641. data/lib/chef/resource/windows_defender_exclusion.rb +124 -0
  642. data/lib/chef/resource/windows_dfs_folder.rb +72 -0
  643. data/lib/chef/resource/windows_dfs_namespace.rb +110 -0
  644. data/lib/chef/resource/windows_dfs_server.rb +77 -0
  645. data/lib/chef/resource/windows_dns_record.rb +90 -0
  646. data/lib/chef/resource/windows_dns_zone.rb +79 -0
  647. data/lib/chef/resource/windows_env.rb +190 -9
  648. data/lib/chef/resource/windows_feature.rb +77 -25
  649. data/lib/chef/resource/windows_feature_dism.rb +57 -53
  650. data/lib/chef/resource/windows_feature_powershell.rb +88 -110
  651. data/lib/chef/resource/windows_firewall_profile.rb +194 -0
  652. data/lib/chef/resource/windows_firewall_rule.rb +193 -62
  653. data/lib/chef/resource/windows_font.rb +24 -17
  654. data/lib/chef/resource/windows_package.rb +129 -18
  655. data/lib/chef/resource/windows_pagefile.rb +147 -75
  656. data/lib/chef/resource/windows_path.rb +59 -6
  657. data/lib/chef/resource/windows_printer.rb +122 -84
  658. data/lib/chef/resource/windows_printer_port.rb +93 -81
  659. data/lib/chef/resource/windows_script.rb +7 -22
  660. data/lib/chef/resource/windows_security_policy.rb +167 -0
  661. data/lib/chef/resource/windows_service.rb +173 -58
  662. data/lib/chef/resource/windows_share.rb +87 -74
  663. data/lib/chef/resource/windows_shortcut.rb +26 -18
  664. data/lib/chef/resource/windows_task.rb +833 -90
  665. data/lib/chef/resource/windows_uac.rb +113 -0
  666. data/lib/chef/resource/windows_update_settings.rb +258 -0
  667. data/lib/chef/resource/windows_user_privilege.rb +232 -0
  668. data/lib/chef/resource/windows_workgroup.rb +42 -26
  669. data/lib/chef/resource/yum_package.rb +120 -37
  670. data/lib/chef/resource/yum_repository.rb +85 -59
  671. data/lib/chef/resource/zypper_package.rb +41 -11
  672. data/lib/chef/resource/zypper_repository.rb +68 -36
  673. data/lib/chef/resource.rb +172 -126
  674. data/lib/chef/resource_builder.rb +21 -6
  675. data/lib/chef/resource_collection/resource_collection_serialization.rb +6 -5
  676. data/lib/chef/resource_collection/resource_list.rb +10 -8
  677. data/lib/chef/resource_collection/resource_set.rb +20 -20
  678. data/lib/chef/resource_collection/stepable_iterator.rb +2 -2
  679. data/lib/chef/resource_collection.rb +12 -10
  680. data/lib/chef/resource_definition.rb +8 -6
  681. data/lib/chef/resource_definition_list.rb +4 -4
  682. data/lib/chef/resource_inspector.rb +95 -77
  683. data/lib/chef/resource_reporter.rb +47 -141
  684. data/lib/chef/resource_resolver.rb +11 -18
  685. data/lib/chef/resources.rb +176 -130
  686. data/lib/chef/role.rb +21 -20
  687. data/lib/chef/run_context/cookbook_compiler.rb +176 -65
  688. data/lib/chef/run_context.rb +127 -36
  689. data/lib/chef/run_list/run_list_expansion.rb +9 -8
  690. data/lib/chef/run_list/run_list_item.rb +6 -6
  691. data/lib/chef/run_list/versioned_recipe_list.rb +4 -4
  692. data/lib/chef/run_list.rb +10 -9
  693. data/lib/chef/run_lock.rb +14 -13
  694. data/lib/chef/run_status.rb +5 -8
  695. data/lib/chef/runner.rb +10 -10
  696. data/lib/chef/scan_access_control.rb +2 -2
  697. data/lib/chef/search/query.rb +15 -17
  698. data/lib/chef/secret_fetcher/akeyless_vault.rb +57 -0
  699. data/lib/chef/secret_fetcher/aws_secrets_manager.rb +65 -0
  700. data/lib/chef/secret_fetcher/azure_key_vault.rb +134 -0
  701. data/lib/chef/secret_fetcher/base.rb +76 -0
  702. data/lib/chef/secret_fetcher/example.rb +46 -0
  703. data/lib/chef/secret_fetcher/hashi_vault.rb +134 -0
  704. data/lib/chef/secret_fetcher.rb +60 -0
  705. data/lib/chef/server_api.rb +11 -15
  706. data/lib/chef/server_api_versions.rb +6 -2
  707. data/lib/chef/shell/ext.rb +29 -30
  708. data/lib/chef/shell/model_wrapper.rb +5 -4
  709. data/lib/chef/shell/shell_session.rb +16 -13
  710. data/lib/chef/shell.rb +105 -47
  711. data/lib/chef/{audit/logger.rb → train_transport.rb} +8 -15
  712. data/lib/chef/user.rb +14 -15
  713. data/lib/chef/user_v1.rb +26 -25
  714. data/lib/chef/util/backup.rb +4 -4
  715. data/lib/chef/util/diff.rb +24 -22
  716. data/lib/chef/util/dsc/configuration_generator.rb +59 -17
  717. data/lib/chef/util/dsc/lcm_output_parser.rb +13 -16
  718. data/lib/chef/util/dsc/local_configuration_manager.rb +23 -20
  719. data/lib/chef/util/dsc/resource_store.rb +7 -13
  720. data/lib/chef/util/editor.rb +1 -1
  721. data/lib/chef/util/file_edit.rb +4 -3
  722. data/lib/chef/util/path_helper.rb +1 -1
  723. data/lib/chef/util/powershell/ps_credential.rb +20 -16
  724. data/lib/chef/util/selinux.rb +5 -5
  725. data/lib/chef/util/threaded_job_queue.rb +2 -4
  726. data/lib/chef/util/windows/logon_session.rb +8 -8
  727. data/lib/chef/util/windows/net_group.rb +2 -2
  728. data/lib/chef/util/windows/net_use.rb +4 -4
  729. data/lib/chef/util/windows/net_user.rb +8 -7
  730. data/lib/chef/util/windows/volume.rb +3 -3
  731. data/lib/chef/version/platform.rb +1 -1
  732. data/lib/chef/version.rb +4 -4
  733. data/lib/chef/version_class.rb +2 -2
  734. data/lib/chef/version_constraint/platform.rb +2 -2
  735. data/lib/chef/version_constraint.rb +4 -4
  736. data/lib/chef/version_string.rb +3 -126
  737. data/lib/chef/win32/api/command_line_helper.rb +89 -0
  738. data/lib/chef/win32/api/crypto.rb +13 -13
  739. data/lib/chef/win32/api/error.rb +9 -7
  740. data/lib/chef/win32/api/file.rb +66 -62
  741. data/lib/chef/win32/api/installer.rb +8 -8
  742. data/lib/chef/win32/api/memory.rb +6 -6
  743. data/lib/chef/win32/api/net.rb +42 -41
  744. data/lib/chef/win32/api/process.rb +4 -4
  745. data/lib/chef/win32/api/psapi.rb +3 -3
  746. data/lib/chef/win32/api/registry.rb +5 -5
  747. data/lib/chef/win32/api/security.rb +95 -89
  748. data/lib/chef/win32/api/synchronization.rb +7 -7
  749. data/lib/chef/win32/api/system.rb +9 -9
  750. data/lib/chef/win32/api/unicode.rb +5 -5
  751. data/lib/chef/win32/api.rb +15 -8
  752. data/lib/chef/win32/crypto.rb +6 -6
  753. data/lib/chef/win32/error.rb +6 -6
  754. data/lib/chef/win32/eventlog.rb +4 -4
  755. data/lib/chef/win32/file/info.rb +3 -2
  756. data/lib/chef/win32/file/version_info.rb +22 -21
  757. data/lib/chef/win32/file.rb +19 -24
  758. data/lib/chef/win32/handle.rb +11 -12
  759. data/lib/chef/win32/memory.rb +4 -4
  760. data/lib/chef/win32/mutex.rb +5 -5
  761. data/lib/chef/win32/net.rb +13 -8
  762. data/lib/chef/win32/process.rb +8 -8
  763. data/lib/chef/win32/registry.rb +24 -15
  764. data/lib/chef/win32/security/ace.rb +5 -5
  765. data/lib/chef/win32/security/acl.rb +6 -5
  766. data/lib/chef/win32/security/securable_object.rb +4 -4
  767. data/lib/chef/win32/security/security_descriptor.rb +8 -6
  768. data/lib/chef/win32/security/sid.rb +20 -19
  769. data/lib/chef/win32/security/token.rb +8 -6
  770. data/lib/chef/win32/security.rb +61 -18
  771. data/lib/chef/win32/system.rb +4 -4
  772. data/lib/chef/win32/unicode.rb +4 -4
  773. data/lib/chef/win32/version.rb +10 -8
  774. data/lib/chef/workstation_config_loader.rb +1 -1
  775. data/lib/chef.rb +15 -15
  776. data/spec/data/archive_file/test_archive.tar.gz +0 -0
  777. data/spec/data/chef_guid +1 -0
  778. data/spec/data/cookbooks/apache2/metadata.json +33 -0
  779. data/spec/data/cookbooks/irssi/files/default/irssi.response +2 -0
  780. data/spec/data/cookbooks/java/metadata.json +33 -0
  781. data/spec/data/cookbooks/openldap/libraries/openldap.rb +1 -1
  782. data/spec/data/cookbooks/starter/chefignore +8 -0
  783. data/spec/data/cookbooks/starter/files/sample.txt +1 -0
  784. data/spec/data/cookbooks/starter/metadata.rb +2 -0
  785. data/spec/data/cookbooks/starter/recipes/default.rb +4 -0
  786. data/spec/data/cookbooks/wget/files/default/wget.response +2 -0
  787. data/spec/data/lwrp/providers/buck_passer.rb +1 -1
  788. data/spec/data/lwrp/providers/buck_passer_2.rb +1 -1
  789. data/spec/data/lwrp/providers/embedded_resource_accesses_providers_scope.rb +1 -1
  790. data/spec/data/lwrp/resources/bar.rb +2 -0
  791. data/spec/data/lwrp/resources/buck_passer.rb +1 -0
  792. data/spec/data/lwrp/resources/buck_passer_2.rb +1 -0
  793. data/spec/data/lwrp/resources/embedded_resource_accesses_providers_scope.rb +1 -0
  794. data/spec/data/lwrp/resources/foo.rb +2 -0
  795. data/spec/data/lwrp/resources/inline_compiler.rb +1 -0
  796. data/spec/data/lwrp/resources/monkey_name_printer.rb +1 -0
  797. data/spec/data/lwrp/resources/paint_drying_watcher.rb +1 -0
  798. data/spec/data/lwrp/resources/thumb_twiddler.rb +1 -0
  799. data/spec/data/lwrp/resources_with_default_attributes/nodeattr.rb +2 -0
  800. data/spec/data/lwrp_const_scoping/resources/conflict.rb +1 -0
  801. data/spec/data/lwrp_override/resources/foo.rb +1 -0
  802. data/spec/data/nodes/mcwfhpowell.json +3 -0
  803. data/spec/data/rubygems.org/latest_specs.4.8.gz +0 -0
  804. data/spec/data/rubygems.org/nonexistent_gem +0 -0
  805. data/spec/data/rubygems.org/nonexistent_gem-info +1 -0
  806. data/spec/data/rubygems.org/sexp_processor +0 -0
  807. data/spec/data/rubygems.org/sexp_processor-4.15.1.gemspec.rz +0 -0
  808. data/spec/data/rubygems.org/sexp_processor-info +50 -0
  809. data/spec/data/run_context/cookbooks/circular-dep1/resources/resource.rb +1 -0
  810. data/spec/data/run_context/cookbooks/circular-dep2/resources/resource.rb +1 -0
  811. data/spec/data/run_context/cookbooks/dependency1/attributes/unparsed_file +1 -0
  812. data/spec/data/run_context/cookbooks/dependency1/definitions/unparsed_file +1 -0
  813. data/spec/data/run_context/cookbooks/dependency1/libraries/unparsed_file +1 -0
  814. data/spec/data/run_context/cookbooks/dependency1/providers/unparsed_file +1 -0
  815. data/spec/data/run_context/cookbooks/dependency1/recipes/unparsed_file +1 -0
  816. data/spec/data/run_context/cookbooks/dependency1/resources/resource.rb +1 -0
  817. data/spec/data/run_context/cookbooks/dependency1/resources/unparsed_file +1 -0
  818. data/spec/data/run_context/cookbooks/dependency2/resources/resource.rb +1 -0
  819. data/spec/data/run_context/cookbooks/no-default-attr/resources/resource.rb +1 -0
  820. data/spec/data/run_context/cookbooks/test/resources/resource.rb +2 -0
  821. data/spec/data/run_context/cookbooks/test-with-circular-deps/resources/resource.rb +2 -0
  822. data/spec/data/run_context/cookbooks/test-with-deps/resources/resource.rb +1 -0
  823. data/spec/data/shef-config.rb +2 -2
  824. data/spec/data/snap_package/async_result_success.json +6 -0
  825. data/spec/data/snap_package/change_id_result.json +175 -0
  826. data/spec/data/snap_package/find_result_failure.json +10 -0
  827. data/spec/data/snap_package/find_result_success.json +70 -0
  828. data/spec/data/snap_package/get_by_name_result_failure.json +10 -0
  829. data/spec/data/snap_package/get_by_name_result_success.json +38 -0
  830. data/spec/data/snap_package/get_conf_success.json +10 -0
  831. data/spec/data/snap_package/result_failure.json +9 -0
  832. data/spec/data/ssl/binary/chef-rspec-der.cert +0 -0
  833. data/spec/data/ssl/binary/chef-rspec-der.key +0 -0
  834. data/spec/data/ssl/chef-rspec.cert +15 -15
  835. data/spec/data/windows_certificates/base64_test.cer +18 -20
  836. data/spec/data/windows_certificates/othertest.cer +0 -0
  837. data/spec/data/windows_certificates/test.cer +0 -0
  838. data/spec/data/windows_certificates/test.p7b +0 -0
  839. data/spec/data/windows_certificates/test.pem +18 -19
  840. data/spec/data/windows_certificates/test.pfx +0 -0
  841. data/spec/functional/application_spec.rb +1 -1
  842. data/spec/functional/assets/inittest +8 -7
  843. data/spec/functional/assets/yumrepo-empty/repodata/01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2 +0 -0
  844. data/spec/functional/assets/yumrepo-empty/repodata/401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz +0 -0
  845. data/spec/functional/assets/yumrepo-empty/repodata/5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2 +0 -0
  846. data/spec/functional/assets/yumrepo-empty/repodata/6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz +0 -0
  847. data/spec/functional/assets/yumrepo-empty/repodata/7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2 +0 -0
  848. data/spec/functional/assets/yumrepo-empty/repodata/dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz +0 -0
  849. data/spec/functional/assets/yumrepo-empty/repodata/repomd.xml +55 -0
  850. data/spec/functional/dsl/reboot_pending_spec.rb +6 -6
  851. data/spec/functional/dsl/registry_helper_spec.rb +3 -3
  852. data/spec/functional/event_loggers/windows_eventlog_spec.rb +9 -8
  853. data/spec/functional/file_content_management/deploy_strategies_spec.rb +4 -4
  854. data/spec/functional/http/simple_spec.rb +1 -1
  855. data/spec/functional/mixin/from_file_spec.rb +13 -2
  856. data/spec/functional/mixin/powershell_out_spec.rb +12 -4
  857. data/spec/functional/mixin/shell_out_spec.rb +1 -31
  858. data/spec/functional/mixin/user_context_spec.rb +3 -3
  859. data/spec/functional/provider/remote_file/cache_control_data_spec.rb +1 -1
  860. data/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +1 -1
  861. data/spec/functional/rebooter_spec.rb +1 -1
  862. data/spec/functional/resource/aix_service_spec.rb +12 -5
  863. data/spec/functional/resource/aixinit_service_spec.rb +17 -18
  864. data/spec/functional/resource/apt_package_spec.rb +6 -9
  865. data/spec/functional/resource/archive_file_spec.rb +88 -0
  866. data/spec/functional/resource/bash_spec.rb +4 -3
  867. data/spec/functional/resource/batch_spec.rb +1 -1
  868. data/spec/functional/resource/bff_spec.rb +4 -4
  869. data/spec/functional/resource/chocolatey_package_spec.rb +68 -4
  870. data/spec/functional/resource/cookbook_file_spec.rb +4 -4
  871. data/spec/functional/resource/cron_spec.rb +35 -36
  872. data/spec/functional/resource/directory_spec.rb +1 -1
  873. data/spec/functional/resource/dnf_package_spec.rb +1305 -362
  874. data/spec/functional/resource/dpkg_package_spec.rb +17 -1
  875. data/spec/functional/resource/dsc_resource_spec.rb +2 -2
  876. data/spec/functional/resource/dsc_script_spec.rb +11 -15
  877. data/spec/functional/resource/execute_spec.rb +2 -2
  878. data/spec/functional/resource/file_spec.rb +1 -1
  879. data/spec/functional/resource/git_spec.rb +208 -136
  880. data/spec/functional/resource/group_spec.rb +44 -57
  881. data/spec/functional/resource/ifconfig_spec.rb +10 -2
  882. data/spec/functional/resource/insserv_spec.rb +10 -10
  883. data/spec/functional/resource/launchd_spec.rb +232 -0
  884. data/spec/functional/resource/link_spec.rb +33 -28
  885. data/spec/functional/resource/locale_spec.rb +108 -0
  886. data/spec/functional/resource/macos_userdefaults_spec.rb +139 -0
  887. data/spec/functional/resource/mount_spec.rb +20 -4
  888. data/spec/functional/resource/msu_package_spec.rb +15 -6
  889. data/spec/functional/resource/ohai_spec.rb +3 -11
  890. data/spec/functional/resource/plist_spec.rb +25 -0
  891. data/spec/functional/resource/powershell_package_source_spec.rb +106 -0
  892. data/spec/functional/resource/powershell_script_spec.rb +84 -96
  893. data/spec/functional/resource/registry_spec.rb +90 -90
  894. data/spec/functional/resource/remote_directory_spec.rb +1 -1
  895. data/spec/functional/resource/remote_file_spec.rb +11 -17
  896. data/spec/functional/resource/rpm_spec.rb +4 -4
  897. data/spec/functional/resource/template_spec.rb +3 -3
  898. data/spec/functional/resource/timezone_spec.rb +3 -1
  899. data/spec/functional/resource/user/linux_user_spec.rb +127 -0
  900. data/spec/functional/resource/user/{dscl_spec.rb → mac_user_spec.rb} +31 -19
  901. data/spec/functional/resource/user/windows_spec.rb +1 -1
  902. data/spec/functional/resource/windows_certificate_spec.rb +266 -382
  903. data/spec/functional/resource/windows_env_spec.rb +4 -4
  904. data/spec/functional/resource/windows_firewall_rule_spec.rb +93 -0
  905. data/spec/functional/resource/windows_font_spec.rb +52 -0
  906. data/spec/functional/resource/windows_hostname_spec.rb +91 -0
  907. data/spec/functional/resource/windows_package_spec.rb +37 -12
  908. data/spec/functional/resource/windows_pagefile_spec.rb +125 -0
  909. data/spec/functional/resource/windows_path_spec.rb +5 -1
  910. data/spec/functional/resource/windows_security_policy_spec.rb +86 -0
  911. data/spec/functional/resource/windows_share_spec.rb +103 -0
  912. data/spec/functional/resource/windows_task_spec.rb +64 -63
  913. data/spec/functional/resource/windows_user_privilege_spec.rb +192 -0
  914. data/spec/functional/resource/yum_package_spec.rb +1212 -432
  915. data/spec/functional/resource/zypper_package_spec.rb +35 -2
  916. data/spec/functional/run_lock_spec.rb +27 -26
  917. data/spec/functional/shell_spec.rb +13 -10
  918. data/spec/functional/tiny_server_spec.rb +1 -1
  919. data/spec/functional/util/path_helper_spec.rb +1 -1
  920. data/spec/functional/version_spec.rb +7 -6
  921. data/spec/functional/win32/crypto_spec.rb +3 -3
  922. data/spec/functional/win32/registry_spec.rb +18 -24
  923. data/spec/functional/win32/security_spec.rb +24 -2
  924. data/spec/functional/win32/sid_spec.rb +2 -2
  925. data/spec/functional/win32/version_info_spec.rb +2 -2
  926. data/spec/functional/win32/versions_spec.rb +3 -3
  927. data/spec/integration/client/client_spec.rb +326 -83
  928. data/spec/integration/client/exit_code_spec.rb +4 -30
  929. data/spec/integration/client/fips_spec.rb +20 -0
  930. data/spec/integration/client/ipv6_spec.rb +4 -3
  931. data/spec/integration/compliance/compliance_spec.rb +143 -0
  932. data/spec/integration/ohai/ohai_spec.rb +62 -0
  933. data/spec/integration/recipes/accumulator_spec.rb +15 -2
  934. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +11 -6
  935. data/spec/integration/recipes/lwrp_spec.rb +5 -2
  936. data/spec/integration/recipes/noop_resource_spec.rb +1 -1
  937. data/spec/integration/recipes/notifies_spec.rb +67 -23
  938. data/spec/integration/recipes/notifying_block_spec.rb +13 -8
  939. data/spec/integration/recipes/provider_choice.rb +4 -2
  940. data/spec/integration/recipes/recipe_dsl_spec.rb +61 -153
  941. data/spec/integration/recipes/remote_directory.rb +2 -2
  942. data/spec/integration/recipes/resource_action_spec.rb +35 -15
  943. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +22 -20
  944. data/spec/integration/recipes/resource_load_spec.rb +137 -14
  945. data/spec/integration/recipes/unified_mode_spec.rb +73 -2
  946. data/spec/integration/recipes/use_partial_spec.rb +116 -0
  947. data/spec/integration/solo/solo_spec.rb +13 -11
  948. data/spec/spec_helper.rb +62 -45
  949. data/spec/stress/win32/file_spec.rb +2 -2
  950. data/spec/stress/win32/memory_spec.rb +1 -1
  951. data/spec/stress/win32/security_spec.rb +1 -1
  952. data/spec/support/chef_helpers.rb +7 -43
  953. data/spec/support/key_helpers.rb +1 -3
  954. data/spec/support/lib/chef/provider/easy.rb +1 -1
  955. data/spec/support/lib/chef/provider/openldap_includer.rb +1 -1
  956. data/spec/support/lib/chef/provider/snakeoil.rb +1 -1
  957. data/spec/support/lib/chef/resource/cat.rb +2 -2
  958. data/spec/support/lib/chef/resource/one_two_three_four.rb +1 -1
  959. data/spec/support/lib/chef/resource/openldap_includer.rb +1 -1
  960. data/spec/support/lib/chef/resource/with_state.rb +1 -2
  961. data/spec/support/lib/chef/resource/zen_follower.rb +3 -2
  962. data/spec/support/lib/chef/resource/zen_master.rb +1 -2
  963. data/spec/support/matchers/leak.rb +8 -10
  964. data/spec/support/mock/platform.rb +25 -17
  965. data/spec/support/platform_helpers.rb +49 -71
  966. data/spec/support/platforms/prof/gc.rb +2 -2
  967. data/spec/support/platforms/prof/win32.rb +1 -1
  968. data/spec/support/platforms/win32/spec_service.rb +28 -26
  969. data/spec/support/recipe_dsl_helper.rb +83 -0
  970. data/spec/support/ruby_installer.rb +51 -0
  971. data/spec/support/shared/context/config.rb +0 -3
  972. data/spec/support/shared/context/win32.rb +1 -1
  973. data/spec/support/shared/functional/directory_resource.rb +2 -2
  974. data/spec/support/shared/functional/execute_resource.rb +3 -3
  975. data/spec/support/shared/functional/file_resource.rb +24 -25
  976. data/spec/support/shared/functional/http.rb +12 -12
  977. data/spec/support/shared/functional/knife.rb +1 -1
  978. data/spec/support/shared/functional/securable_resource.rb +111 -31
  979. data/spec/support/shared/functional/securable_resource_with_reporting.rb +0 -1
  980. data/spec/support/shared/functional/windows_script.rb +11 -24
  981. data/spec/support/shared/integration/integration_helper.rb +23 -56
  982. data/spec/support/shared/integration/knife_support.rb +12 -16
  983. data/spec/support/shared/unit/api_error_inspector.rb +1 -1
  984. data/spec/support/shared/unit/api_versioning.rb +1 -1
  985. data/spec/support/shared/unit/application_dot_d.rb +6 -5
  986. data/spec/support/shared/unit/execute_resource.rb +2 -4
  987. data/spec/support/shared/unit/file_system_support.rb +1 -1
  988. data/spec/support/shared/unit/knife_shared.rb +2 -2
  989. data/spec/support/shared/unit/mock_shellout.rb +1 -1
  990. data/spec/support/shared/unit/platform_introspector.rb +1 -1
  991. data/spec/support/shared/unit/provider/file.rb +46 -23
  992. data/spec/support/shared/unit/provider/package/package_shared.rb +95 -0
  993. data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +22 -14
  994. data/spec/support/shared/unit/resource/static_provider_resolution.rb +1 -1
  995. data/spec/support/shared/unit/script_resource.rb +14 -30
  996. data/spec/support/shared/unit/user_and_client_shared.rb +2 -2
  997. data/spec/support/shared/unit/windows_script_resource.rb +17 -32
  998. data/spec/tiny_server.rb +1 -2
  999. data/spec/unit/{log_spec.rb → action_collection_spec.rb} +3 -8
  1000. data/spec/unit/api_client/registration_spec.rb +1 -1
  1001. data/spec/unit/api_client_spec.rb +1 -1
  1002. data/spec/unit/api_client_v1_spec.rb +1 -1
  1003. data/spec/unit/application/apply_spec.rb +3 -0
  1004. data/spec/unit/application/base_spec.rb +40 -0
  1005. data/spec/unit/application/client_spec.rb +122 -93
  1006. data/spec/unit/application/exit_code_spec.rb +12 -12
  1007. data/spec/unit/application/solo_spec.rb +9 -16
  1008. data/spec/unit/application_spec.rb +115 -14
  1009. data/spec/unit/chef_class_spec.rb +1 -1
  1010. data/spec/unit/chef_fs/config_spec.rb +4 -4
  1011. data/spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb +2 -2
  1012. data/spec/unit/chef_fs/data_handler/data_handler_base_spec.rb +1 -1
  1013. data/spec/unit/chef_fs/data_handler/group_handler_spec.rb +1 -1
  1014. data/spec/unit/chef_fs/diff_spec.rb +10 -10
  1015. data/spec/unit/chef_fs/file_pattern_spec.rb +3 -3
  1016. data/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb +1 -1
  1017. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +3 -5
  1018. data/spec/unit/chef_fs/file_system/repository/base_file_spec.rb +1 -1
  1019. data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +2 -2
  1020. data/spec/unit/chef_fs/file_system_spec.rb +4 -2
  1021. data/spec/unit/chef_fs/path_util_spec.rb +4 -4
  1022. data/spec/unit/chef_spec.rb +1 -1
  1023. data/spec/unit/client_spec.rb +349 -71
  1024. data/spec/unit/compliance/fetcher/automate_spec.rb +126 -0
  1025. data/spec/unit/compliance/fetcher/chef_server_spec.rb +93 -0
  1026. data/spec/unit/compliance/input_spec.rb +104 -0
  1027. data/spec/unit/compliance/profile_spec.rb +120 -0
  1028. data/spec/unit/compliance/reporter/automate_spec.rb +451 -0
  1029. data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +197 -0
  1030. data/spec/unit/compliance/reporter/compliance_enforcer_spec.rb +49 -0
  1031. data/spec/unit/compliance/runner_spec.rb +346 -0
  1032. data/spec/unit/compliance/waiver_spec.rb +104 -0
  1033. data/spec/unit/cookbook/chefignore_spec.rb +32 -12
  1034. data/spec/unit/cookbook/cookbook_version_loader_spec.rb +10 -7
  1035. data/spec/unit/cookbook/file_vendor_spec.rb +2 -2
  1036. data/spec/unit/cookbook/gem_installer_spec.rb +7 -6
  1037. data/spec/unit/cookbook/manifest_v0_spec.rb +1 -1
  1038. data/spec/unit/cookbook/manifest_v2_spec.rb +1 -1
  1039. data/spec/unit/cookbook/metadata_spec.rb +39 -321
  1040. data/spec/unit/cookbook/synchronizer_spec.rb +28 -25
  1041. data/spec/unit/cookbook/syntax_check_spec.rb +5 -2
  1042. data/spec/unit/cookbook_loader_spec.rb +21 -58
  1043. data/spec/unit/cookbook_manifest_spec.rb +1 -1
  1044. data/spec/unit/cookbook_spec.rb +3 -3
  1045. data/spec/unit/cookbook_uploader_spec.rb +8 -2
  1046. data/spec/unit/cookbook_version_file_specificity_spec.rb +1 -1
  1047. data/spec/unit/cookbook_version_spec.rb +55 -3
  1048. data/spec/unit/daemon_spec.rb +2 -6
  1049. data/spec/unit/data_bag_item_spec.rb +2 -7
  1050. data/spec/unit/data_bag_spec.rb +8 -5
  1051. data/spec/unit/data_collector/config_validation_spec.rb +208 -0
  1052. data/spec/unit/data_collector_spec.rb +769 -673
  1053. data/spec/unit/decorator/lazy_array_spec.rb +1 -1
  1054. data/spec/unit/decorator/lazy_spec.rb +1 -1
  1055. data/spec/unit/decorator_spec.rb +24 -24
  1056. data/spec/unit/deprecated_spec.rb +4 -4
  1057. data/spec/unit/deprecation_spec.rb +1 -1
  1058. data/spec/unit/digester_spec.rb +1 -1
  1059. data/spec/unit/dsl/data_query_spec.rb +1 -1
  1060. data/spec/unit/dsl/declare_resource_spec.rb +2 -2
  1061. data/spec/unit/dsl/platform_introspection_spec.rb +32 -1
  1062. data/spec/unit/dsl/reboot_pending_spec.rb +6 -6
  1063. data/spec/unit/dsl/recipe_spec.rb +1 -1
  1064. data/spec/unit/dsl/registry_helper_spec.rb +8 -8
  1065. data/spec/unit/dsl/render_helpers_spec.rb +102 -0
  1066. data/spec/unit/dsl/secret_spec.rb +175 -0
  1067. data/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb +2 -2
  1068. data/spec/unit/encrypted_data_bag_item_spec.rb +3 -3
  1069. data/spec/unit/environment_spec.rb +16 -10
  1070. data/spec/unit/event_dispatch/dispatcher_spec.rb +54 -4
  1071. data/spec/unit/exceptions_spec.rb +1 -1
  1072. data/spec/unit/file_access_control_spec.rb +4 -4
  1073. data/spec/unit/file_cache_spec.rb +1 -1
  1074. data/spec/unit/file_content_management/deploy/cp_spec.rb +1 -1
  1075. data/spec/unit/file_content_management/deploy/mv_unix_spec.rb +2 -2
  1076. data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +3 -3
  1077. data/spec/unit/file_content_management/tempfile_spec.rb +2 -2
  1078. data/spec/unit/formatters/base_spec.rb +2 -2
  1079. data/spec/unit/formatters/doc_spec.rb +2 -2
  1080. data/spec/unit/formatters/error_description_spec.rb +1 -1
  1081. data/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +1 -1
  1082. data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +1 -1
  1083. data/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb +3 -3
  1084. data/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb +1 -1
  1085. data/spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb +1 -1
  1086. data/spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb +1 -1
  1087. data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +3 -3
  1088. data/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb +1 -1
  1089. data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +12 -12
  1090. data/spec/unit/guard_interpreter_spec.rb +2 -2
  1091. data/spec/unit/handler/json_file_spec.rb +1 -1
  1092. data/spec/unit/handler_spec.rb +9 -3
  1093. data/spec/unit/http/api_versions_spec.rb +21 -3
  1094. data/spec/unit/http/authenticator_spec.rb +69 -1
  1095. data/spec/unit/http/basic_client_spec.rb +30 -0
  1096. data/spec/unit/http/http_request_spec.rb +1 -1
  1097. data/spec/unit/http/json_input_spec.rb +1 -1
  1098. data/spec/unit/http/simple_spec.rb +1 -1
  1099. data/spec/unit/http/socketless_chef_zero_client_spec.rb +1 -1
  1100. data/spec/unit/http/ssl_policies_spec.rb +126 -67
  1101. data/spec/unit/http/validate_content_length_spec.rb +1 -1
  1102. data/spec/unit/http_spec.rb +10 -4
  1103. data/spec/unit/json_compat_spec.rb +2 -2
  1104. data/spec/unit/key_spec.rb +2 -2
  1105. data/spec/unit/log/syslog_spec.rb +7 -11
  1106. data/spec/unit/log/winevt_spec.rb +22 -14
  1107. data/spec/unit/lwrp_spec.rb +17 -14
  1108. data/spec/unit/mixin/api_version_request_handling_spec.rb +1 -1
  1109. data/spec/unit/mixin/checksum_spec.rb +29 -1
  1110. data/spec/unit/mixin/deep_merge_spec.rb +15 -0
  1111. data/spec/unit/mixin/{path_sanity_spec.rb → default_paths_spec.rb} +18 -18
  1112. data/spec/unit/mixin/deprecation_spec.rb +1 -1
  1113. data/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +1 -1
  1114. data/spec/unit/mixin/homebrew_user_spec.rb +1 -1
  1115. data/spec/unit/mixin/lazy_module_include.rb +1 -1
  1116. data/spec/unit/mixin/openssl_helper_spec.rb +48 -13
  1117. data/spec/unit/mixin/params_validate_spec.rb +5 -4
  1118. data/spec/unit/mixin/powershell_exec_spec.rb +51 -4
  1119. data/spec/unit/mixin/powershell_out_spec.rb +17 -5
  1120. data/spec/unit/mixin/powershell_type_coercions_spec.rb +2 -2
  1121. data/spec/unit/mixin/proxified_socket_spec.rb +1 -1
  1122. data/spec/unit/mixin/securable_spec.rb +6 -7
  1123. data/spec/unit/mixin/shell_out_spec.rb +47 -189
  1124. data/spec/unit/mixin/subclass_directive_spec.rb +3 -3
  1125. data/spec/unit/mixin/template_spec.rb +34 -34
  1126. data/spec/unit/mixin/unformatter_spec.rb +3 -3
  1127. data/spec/unit/mixin/uris_spec.rb +2 -2
  1128. data/spec/unit/mixin/user_context_spec.rb +4 -12
  1129. data/spec/unit/mixin/versioned_api_spec.rb +1 -1
  1130. data/spec/unit/mixin/which.rb +10 -2
  1131. data/spec/unit/mixin/why_run_spec.rb +53 -0
  1132. data/spec/unit/mixin/windows_architecture_helper_spec.rb +5 -5
  1133. data/spec/unit/mixin/xml_escape_spec.rb +1 -1
  1134. data/spec/unit/monologger_spec.rb +1 -1
  1135. data/spec/unit/node/attribute_spec.rb +60 -14
  1136. data/spec/unit/node/immutable_collections_spec.rb +77 -146
  1137. data/spec/unit/node/vivid_mash_spec.rb +109 -4
  1138. data/spec/unit/node_map_spec.rb +50 -16
  1139. data/spec/unit/node_spec.rb +212 -31
  1140. data/spec/unit/org_group_spec.rb +45 -0
  1141. data/spec/unit/org_spec.rb +1 -1
  1142. data/spec/unit/platform/query_helpers_spec.rb +3 -162
  1143. data/spec/unit/policy_builder/dynamic_spec.rb +1 -18
  1144. data/spec/unit/policy_builder/expand_node_object_spec.rb +3 -3
  1145. data/spec/unit/policy_builder/policyfile_spec.rb +145 -57
  1146. data/spec/unit/policy_builder_spec.rb +1 -1
  1147. data/spec/unit/property/state_spec.rb +12 -7
  1148. data/spec/unit/property/validation_spec.rb +55 -1
  1149. data/spec/unit/property_spec.rb +130 -33
  1150. data/spec/unit/provider/apt_preference_spec.rb +16 -12
  1151. data/spec/unit/provider/apt_repository_spec.rb +45 -42
  1152. data/spec/unit/provider/apt_update_spec.rb +16 -13
  1153. data/spec/unit/provider/batch_spec.rb +130 -0
  1154. data/spec/unit/provider/cookbook_file/content_spec.rb +1 -1
  1155. data/spec/unit/provider/cookbook_file_spec.rb +5 -5
  1156. data/spec/unit/provider/cron/unix_spec.rb +1 -1
  1157. data/spec/unit/provider/cron_spec.rb +202 -34
  1158. data/spec/unit/provider/directory_spec.rb +5 -16
  1159. data/spec/unit/provider/dsc_resource_spec.rb +31 -64
  1160. data/spec/unit/provider/dsc_script_spec.rb +20 -20
  1161. data/spec/unit/provider/execute_spec.rb +3 -10
  1162. data/spec/unit/provider/file/content_spec.rb +1 -1
  1163. data/spec/unit/provider/file_spec.rb +6 -5
  1164. data/spec/unit/provider/git_spec.rb +48 -8
  1165. data/spec/unit/provider/group/dscl_spec.rb +1 -1
  1166. data/spec/unit/provider/group/gpasswd_spec.rb +3 -3
  1167. data/spec/unit/provider/group/groupadd_spec.rb +3 -2
  1168. data/spec/unit/provider/group/groupmod_spec.rb +3 -3
  1169. data/spec/unit/provider/group/pw_spec.rb +3 -3
  1170. data/spec/unit/provider/group/solaris_spec.rb +106 -0
  1171. data/spec/unit/provider/group/usermod_spec.rb +5 -8
  1172. data/spec/unit/provider/group/windows_spec.rb +6 -0
  1173. data/spec/unit/provider/group_spec.rb +3 -3
  1174. data/spec/unit/provider/http_request_spec.rb +61 -73
  1175. data/spec/unit/provider/ifconfig/aix_spec.rb +15 -15
  1176. data/spec/unit/provider/ifconfig/debian_spec.rb +1 -1
  1177. data/spec/unit/provider/ifconfig/redhat_spec.rb +1 -1
  1178. data/spec/unit/provider/ifconfig_spec.rb +6 -5
  1179. data/spec/unit/provider/launchd_spec.rb +8 -50
  1180. data/spec/unit/provider/link_spec.rb +18 -13
  1181. data/spec/unit/provider/log_spec.rb +4 -4
  1182. data/spec/unit/provider/mdadm_spec.rb +4 -6
  1183. data/spec/unit/provider/mount/aix_spec.rb +2 -2
  1184. data/spec/unit/provider/mount/linux_spec.rb +130 -0
  1185. data/spec/unit/provider/mount/mount_spec.rb +74 -11
  1186. data/spec/unit/provider/mount/solaris_spec.rb +2 -2
  1187. data/spec/unit/provider/mount/windows_spec.rb +1 -0
  1188. data/spec/unit/provider/mount_spec.rb +32 -1
  1189. data/spec/unit/provider/package/apt_spec.rb +111 -23
  1190. data/spec/unit/provider/package/bff_spec.rb +2 -1
  1191. data/spec/unit/provider/package/cab_spec.rb +2 -2
  1192. data/spec/unit/provider/package/chocolatey_spec.rb +59 -41
  1193. data/spec/unit/provider/package/deb_spec.rb +135 -0
  1194. data/spec/unit/provider/package/dnf/python_helper_spec.rb +11 -4
  1195. data/spec/unit/provider/package/dpkg_spec.rb +28 -1
  1196. data/spec/unit/provider/package/freebsd/pkgng_spec.rb +1 -2
  1197. data/spec/unit/provider/package/freebsd/port_spec.rb +2 -14
  1198. data/spec/unit/provider/package/homebrew_spec.rb +281 -175
  1199. data/spec/unit/provider/package/ips_spec.rb +1 -1
  1200. data/spec/unit/provider/package/macports_spec.rb +1 -1
  1201. data/spec/unit/provider/package/msu_spec.rb +5 -5
  1202. data/spec/unit/provider/package/openbsd_spec.rb +1 -1
  1203. data/spec/unit/provider/package/pacman_spec.rb +63 -148
  1204. data/spec/unit/provider/package/paludis_spec.rb +1 -1
  1205. data/spec/unit/provider/package/portage_spec.rb +3 -3
  1206. data/spec/unit/provider/package/powershell_spec.rb +198 -134
  1207. data/spec/unit/provider/package/rpm_spec.rb +21 -10
  1208. data/spec/unit/provider/package/rubygems_spec.rb +273 -67
  1209. data/spec/unit/provider/package/smartos_spec.rb +1 -1
  1210. data/spec/unit/provider/package/snap_spec.rb +208 -0
  1211. data/spec/unit/provider/package/solaris_spec.rb +3 -2
  1212. data/spec/unit/provider/package/windows/exe_spec.rb +3 -3
  1213. data/spec/unit/provider/package/windows/msi_spec.rb +1 -1
  1214. data/spec/unit/provider/package/windows/registry_uninstall_entry_spec.rb +3 -3
  1215. data/spec/unit/provider/package/windows_spec.rb +33 -56
  1216. data/spec/unit/provider/package/yum/python_helper_spec.rb +2 -1
  1217. data/spec/unit/provider/package/yum/yum_cache_spec.rb +1 -1
  1218. data/spec/unit/provider/package/zypper_spec.rb +51 -44
  1219. data/spec/unit/provider/package_spec.rb +6 -228
  1220. data/spec/unit/provider/powershell_script_spec.rb +22 -77
  1221. data/spec/unit/provider/registry_key_spec.rb +5 -5
  1222. data/spec/unit/provider/remote_directory_spec.rb +9 -9
  1223. data/spec/unit/provider/remote_file/cache_control_data_spec.rb +4 -4
  1224. data/spec/unit/provider/remote_file/content_spec.rb +1 -1
  1225. data/spec/unit/provider/remote_file/fetcher_spec.rb +2 -2
  1226. data/spec/unit/provider/remote_file/http_spec.rb +11 -1
  1227. data/spec/unit/provider/remote_file/local_file_spec.rb +1 -1
  1228. data/spec/unit/provider/remote_file/network_file_spec.rb +2 -2
  1229. data/spec/unit/provider/remote_file_spec.rb +4 -5
  1230. data/spec/unit/provider/route_spec.rb +0 -2
  1231. data/spec/unit/provider/script_spec.rb +20 -110
  1232. data/spec/unit/provider/service/aix_service_spec.rb +1 -1
  1233. data/spec/unit/provider/service/aixinit_service_spec.rb +1 -1
  1234. data/spec/unit/provider/service/arch_service_spec.rb +7 -5
  1235. data/spec/unit/provider/service/debian_service_spec.rb +37 -14
  1236. data/spec/unit/provider/service/gentoo_service_spec.rb +12 -11
  1237. data/spec/unit/provider/service/init_service_spec.rb +1 -1
  1238. data/spec/unit/provider/service/insserv_service_spec.rb +1 -1
  1239. data/spec/unit/provider/service/invokercd_service_spec.rb +1 -1
  1240. data/spec/unit/provider/service/macosx_spec.rb +211 -214
  1241. data/spec/unit/provider/service/redhat_spec.rb +7 -4
  1242. data/spec/unit/provider/service/simple_service_spec.rb +6 -4
  1243. data/spec/unit/provider/service/solaris_smf_service_spec.rb +1 -1
  1244. data/spec/unit/provider/service/systemd_service_spec.rb +151 -36
  1245. data/spec/unit/provider/service/upstart_service_spec.rb +6 -35
  1246. data/spec/unit/provider/service/windows_spec.rb +167 -109
  1247. data/spec/unit/provider/service_spec.rb +1 -1
  1248. data/spec/unit/provider/subversion_spec.rb +13 -14
  1249. data/spec/unit/provider/systemd_unit_spec.rb +108 -85
  1250. data/spec/unit/provider/template/content_spec.rb +1 -1
  1251. data/spec/unit/provider/template_spec.rb +6 -7
  1252. data/spec/unit/provider/user/aix_spec.rb +2 -2
  1253. data/spec/unit/provider/user/linux_spec.rb +97 -3
  1254. data/spec/unit/provider/user/mac_spec.rb +38 -0
  1255. data/spec/unit/provider/user/pw_spec.rb +1 -1
  1256. data/spec/unit/provider/user/solaris_spec.rb +2 -2
  1257. data/spec/unit/provider/user_spec.rb +56 -30
  1258. data/spec/unit/provider/windows_env_spec.rb +23 -38
  1259. data/spec/unit/provider/windows_path_spec.rb +7 -12
  1260. data/spec/unit/provider/windows_task_spec.rb +8 -7
  1261. data/spec/unit/provider/yum_repository_spec.rb +1 -1
  1262. data/spec/unit/provider/zypper_repository_spec.rb +82 -39
  1263. data/spec/unit/provider_spec.rb +25 -9
  1264. data/spec/unit/recipe_spec.rb +69 -6
  1265. data/spec/unit/resource/alternatives_spec.rb +120 -0
  1266. data/spec/unit/resource/apt_package_spec.rb +11 -1
  1267. data/spec/unit/resource/apt_preference_spec.rb +1 -19
  1268. data/spec/unit/resource/apt_repository_spec.rb +1 -19
  1269. data/spec/unit/resource/apt_update_spec.rb +1 -19
  1270. data/spec/unit/resource/archive_file_spec.rb +466 -0
  1271. data/spec/unit/resource/bash_spec.rb +1 -1
  1272. data/spec/unit/resource/batch_spec.rb +7 -7
  1273. data/spec/unit/resource/bff_package_spec.rb +1 -1
  1274. data/spec/unit/resource/breakpoint_spec.rb +2 -2
  1275. data/spec/unit/resource/build_essential_spec.rb +36 -2
  1276. data/spec/unit/resource/cab_package_spec.rb +1 -1
  1277. data/spec/unit/resource/chef_client_config_spec.rb +145 -0
  1278. data/spec/unit/resource/chef_client_cron_spec.rb +161 -0
  1279. data/spec/unit/resource/chef_client_launchd_spec.rb +132 -0
  1280. data/spec/unit/resource/chef_client_scheduled_task_spec.rb +186 -0
  1281. data/spec/unit/resource/chef_client_systemd_timer_spec.rb +108 -0
  1282. data/spec/unit/resource/chef_client_trusted_certificate_spec.rb +68 -0
  1283. data/spec/unit/resource/chef_gem_spec.rb +1 -4
  1284. data/spec/unit/resource/chef_handler_spec.rb +1 -1
  1285. data/spec/unit/{audit/rspec_formatter_spec.rb → resource/chef_sleep_spec.rb} +10 -9
  1286. data/spec/unit/resource/chef_vault_secret_spec.rb +40 -0
  1287. data/spec/unit/resource/chocolatey_config_spec.rb +2 -7
  1288. data/spec/unit/resource/chocolatey_feature_spec.rb +89 -0
  1289. data/spec/unit/resource/chocolatey_package_spec.rb +18 -3
  1290. data/spec/unit/resource/chocolatey_source_spec.rb +57 -8
  1291. data/spec/unit/resource/conditional_spec.rb +5 -5
  1292. data/spec/unit/resource/cookbook_file_spec.rb +4 -4
  1293. data/spec/unit/resource/cron_access_spec.rb +1 -1
  1294. data/spec/unit/resource/cron_d_spec.rb +34 -40
  1295. data/spec/unit/resource/cron_spec.rb +7 -13
  1296. data/spec/unit/resource/csh_spec.rb +1 -1
  1297. data/spec/unit/resource/directory_spec.rb +1 -1
  1298. data/spec/unit/resource/dmg_package_spec.rb +1 -1
  1299. data/spec/unit/resource/dnf_package_spec.rb +1 -1
  1300. data/spec/unit/resource/dpkg_package_spec.rb +23 -1
  1301. data/spec/unit/resource/dsc_resource_spec.rb +1 -1
  1302. data/spec/unit/resource/dsc_script_spec.rb +1 -1
  1303. data/spec/unit/resource/execute_spec.rb +124 -119
  1304. data/spec/unit/resource/file/verification/json_spec.rb +72 -0
  1305. data/spec/unit/resource/file/verification/systemd_unit_spec.rb +1 -1
  1306. data/spec/unit/resource/file/verification/yaml_spec.rb +67 -0
  1307. data/spec/unit/resource/file/verification_spec.rb +3 -2
  1308. data/spec/unit/resource/file_spec.rb +1 -1
  1309. data/spec/unit/resource/freebsd_package_spec.rb +2 -28
  1310. data/spec/unit/resource/gem_package_spec.rb +4 -4
  1311. data/spec/unit/resource/group_spec.rb +1 -1
  1312. data/spec/unit/resource/helpers/cron_validations_spec.rb +81 -0
  1313. data/spec/unit/resource/homebrew_cask_spec.rb +30 -12
  1314. data/spec/unit/resource/homebrew_package_spec.rb +1 -1
  1315. data/spec/unit/resource/homebrew_tap_spec.rb +1 -1
  1316. data/spec/unit/resource/homebrew_update_spec.rb +30 -0
  1317. data/spec/unit/resource/hostname_spec.rb +1 -1
  1318. data/spec/unit/resource/http_request_spec.rb +1 -1
  1319. data/spec/unit/resource/ifconfig_spec.rb +2 -10
  1320. data/spec/unit/resource/inspec_input_spec.rb +300 -0
  1321. data/spec/unit/resource/inspec_waiver_file_entry_spec.rb +80 -0
  1322. data/spec/unit/resource/inspec_waiver_spec.rb +312 -0
  1323. data/spec/unit/resource/ips_package_spec.rb +1 -1
  1324. data/spec/unit/resource/kernel_module_spec.rb +4 -7
  1325. data/spec/unit/resource/ksh_spec.rb +1 -1
  1326. data/spec/unit/resource/launchd_spec.rb +8 -0
  1327. data/spec/unit/resource/link_spec.rb +1 -5
  1328. data/spec/unit/resource/locale_spec.rb +154 -25
  1329. data/spec/unit/resource/log_spec.rb +1 -1
  1330. data/spec/unit/resource/macos_user_defaults_spec.rb +50 -9
  1331. data/spec/unit/{knife/osc_user_list_spec.rb → resource/macosx_service.rb} +14 -14
  1332. data/spec/unit/resource/macports_package_spec.rb +1 -1
  1333. data/spec/unit/resource/mount_spec.rb +29 -6
  1334. data/spec/unit/resource/msu_package_spec.rb +5 -1
  1335. data/spec/unit/{knife/user_list_spec.rb → resource/notify_group_spec.rb} +11 -13
  1336. data/spec/unit/resource/ohai_hint_spec.rb +1 -1
  1337. data/spec/unit/resource/ohai_spec.rb +56 -6
  1338. data/spec/unit/resource/openbsd_package_spec.rb +1 -1
  1339. data/spec/unit/resource/{openssl_dhparam.rb → openssl_dhparam_spec.rb} +1 -1
  1340. data/spec/unit/resource/openssl_ec_private_key_spec.rb +1 -1
  1341. data/spec/unit/resource/openssl_ec_public_key_spec.rb +1 -1
  1342. data/spec/unit/resource/openssl_rsa_private_key_spec.rb +1 -1
  1343. data/spec/unit/resource/openssl_rsa_public_key_spec.rb +1 -1
  1344. data/spec/unit/resource/openssl_x509_certificate_spec.rb +1 -1
  1345. data/spec/unit/resource/openssl_x509_crl_spec.rb +1 -1
  1346. data/spec/unit/resource/openssl_x509_request.rb +1 -1
  1347. data/spec/unit/resource/osx_profile_spec.rb +299 -0
  1348. data/spec/unit/resource/package_spec.rb +1 -11
  1349. data/spec/unit/resource/pacman_package_spec.rb +1 -1
  1350. data/spec/unit/resource/paludis_package_spec.rb +1 -1
  1351. data/spec/unit/resource/perl_spec.rb +1 -1
  1352. data/spec/unit/resource/plist_spec.rb +130 -0
  1353. data/spec/unit/resource/portage_package_spec.rb +1 -1
  1354. data/spec/unit/resource/powershell_package_source_spec.rb +64 -63
  1355. data/spec/unit/resource/powershell_package_spec.rb +1 -1
  1356. data/spec/unit/resource/powershell_script_spec.rb +15 -91
  1357. data/spec/unit/resource/python_spec.rb +1 -1
  1358. data/spec/unit/resource/reboot_spec.rb +1 -1
  1359. data/spec/unit/resource/registry_key_spec.rb +11 -11
  1360. data/spec/unit/resource/remote_directory_spec.rb +23 -10
  1361. data/spec/unit/resource/remote_file_spec.rb +6 -6
  1362. data/spec/unit/resource/resource_notification_spec.rb +1 -1
  1363. data/spec/unit/resource/rest_resource_spec.rb +381 -0
  1364. data/spec/unit/resource/rhsm_errata_level_spec.rb +1 -1
  1365. data/spec/unit/resource/rhsm_errata_spec.rb +1 -1
  1366. data/spec/unit/resource/rhsm_register_spec.rb +120 -16
  1367. data/spec/unit/resource/rhsm_repo_spec.rb +7 -1
  1368. data/spec/unit/resource/rhsm_subscription_spec.rb +51 -4
  1369. data/spec/unit/resource/route_spec.rb +7 -2
  1370. data/spec/unit/resource/ruby_block_spec.rb +1 -1
  1371. data/spec/unit/resource/ruby_spec.rb +1 -1
  1372. data/spec/unit/resource/{git_spec.rb → scm/git_spec.rb} +51 -3
  1373. data/spec/unit/resource/{scm_spec.rb → scm/scm.rb} +2 -53
  1374. data/spec/unit/resource/{subversion_spec.rb → scm/subversion_spec.rb} +3 -4
  1375. data/spec/unit/resource/script_spec.rb +7 -2
  1376. data/spec/unit/resource/selinux_boolean_spec.rb +92 -0
  1377. data/spec/unit/resource/selinux_fcontext_spec.rb +65 -0
  1378. data/spec/unit/resource/selinux_install_spec.rb +60 -0
  1379. data/spec/unit/resource/selinux_module_spec.rb +55 -0
  1380. data/spec/unit/resource/selinux_permissive_spec.rb +39 -0
  1381. data/spec/unit/resource/selinux_port_spec.rb +42 -0
  1382. data/spec/unit/resource/selinux_state_spec.rb +46 -0
  1383. data/spec/unit/resource/service_spec.rb +82 -85
  1384. data/spec/unit/resource/smartos_package_spec.rb +1 -1
  1385. data/spec/unit/resource/snap_package_spec.rb +60 -0
  1386. data/spec/unit/resource/solaris_package_spec.rb +9 -11
  1387. data/spec/unit/resource/ssh_known_hosts_entry_spec.rb +1 -6
  1388. data/spec/unit/resource/sudo_spec.rb +1 -1
  1389. data/spec/unit/resource/swap_file_spec.rb +1 -1
  1390. data/spec/unit/resource/sysctl_spec.rb +23 -1
  1391. data/spec/unit/resource/systemd_unit_spec.rb +1 -1
  1392. data/spec/unit/resource/template_spec.rb +1 -1
  1393. data/spec/unit/resource/timezone_spec.rb +102 -0
  1394. data/spec/unit/resource/user/linux_user_spec.rb +42 -0
  1395. data/spec/{functional/knife/configure_spec.rb → unit/resource/user/windows_user_spec.rb} +13 -10
  1396. data/spec/unit/resource/user_spec.rb +22 -23
  1397. data/spec/unit/resource/user_ulimit_spec.rb +66 -0
  1398. data/spec/unit/resource/windows_ad_join_spec.rb +5 -1
  1399. data/spec/unit/resource/windows_audit_policy_spec.rb +64 -0
  1400. data/spec/unit/resource/windows_auto_run_spec.rb +2 -2
  1401. data/spec/unit/resource/{windows_certificate.rb → windows_certificate_spec.rb} +13 -1
  1402. data/spec/unit/resource/windows_defender_exclusion_spec.rb +62 -0
  1403. data/spec/unit/resource/windows_defender_spec.rb +71 -0
  1404. data/spec/unit/resource/windows_dfs_folder_spec.rb +39 -0
  1405. data/spec/unit/resource/windows_dfs_namespace_spec.rb +39 -0
  1406. data/spec/unit/{knife/client_list_spec.rb → resource/windows_dfs_server_spec.rb} +12 -12
  1407. data/spec/unit/resource/windows_dns_record_spec.rb +55 -0
  1408. data/spec/unit/resource/windows_dns_zone_spec.rb +51 -0
  1409. data/spec/unit/resource/{windows_feature_dism.rb → windows_feature_dism_spec.rb} +3 -18
  1410. data/spec/unit/resource/{windows_feature_powershell.rb → windows_feature_powershell_spec.rb} +28 -17
  1411. data/spec/unit/resource/{windows_feature.rb → windows_feature_spec.rb} +1 -1
  1412. data/spec/unit/resource/windows_firewall_profile_spec.rb +77 -0
  1413. data/spec/unit/resource/windows_firewall_rule_spec.rb +156 -47
  1414. data/spec/unit/resource/windows_font_spec.rb +1 -1
  1415. data/spec/unit/resource/windows_package_spec.rb +27 -7
  1416. data/spec/unit/resource/windows_pagefile_spec.rb +5 -10
  1417. data/spec/unit/resource/windows_path_spec.rb +1 -1
  1418. data/spec/unit/resource/windows_printer_port_spec.rb +1 -1
  1419. data/spec/unit/resource/windows_printer_spec.rb +1 -1
  1420. data/spec/unit/resource/windows_service_spec.rb +43 -14
  1421. data/spec/unit/resource/{windows_share.rb → windows_share_spec.rb} +10 -1
  1422. data/spec/unit/resource/windows_shortcut_spec.rb +1 -1
  1423. data/spec/unit/resource/windows_task_spec.rb +6 -6
  1424. data/spec/unit/resource/windows_uac_spec.rb +50 -0
  1425. data/spec/unit/resource/windows_update_settings_spec.rb +64 -0
  1426. data/spec/unit/resource/windows_user_privilege_spec.rb +55 -0
  1427. data/spec/unit/resource/windows_workgroup_spec.rb +3 -3
  1428. data/spec/unit/resource/yum_package_spec.rb +1 -1
  1429. data/spec/unit/resource/yum_repository_spec.rb +26 -22
  1430. data/spec/unit/resource/zypper_package_spec.rb +1 -1
  1431. data/spec/unit/resource/zypper_repository_spec.rb +2 -2
  1432. data/spec/unit/resource_collection/resource_list_spec.rb +1 -1
  1433. data/spec/unit/resource_collection/resource_set_spec.rb +1 -1
  1434. data/spec/unit/resource_collection_spec.rb +1 -1
  1435. data/spec/unit/resource_definition_spec.rb +1 -1
  1436. data/spec/unit/resource_inspector_spec.rb +11 -6
  1437. data/spec/unit/resource_reporter_spec.rb +227 -203
  1438. data/spec/unit/resource_spec.rb +219 -16
  1439. data/spec/unit/role_spec.rb +33 -28
  1440. data/spec/unit/run_context/child_run_context_spec.rb +1 -8
  1441. data/spec/unit/run_context/cookbook_compiler_spec.rb +14 -2
  1442. data/spec/unit/run_context_spec.rb +18 -2
  1443. data/spec/unit/run_list/run_list_expansion_spec.rb +1 -1
  1444. data/spec/unit/run_list/run_list_item_spec.rb +1 -1
  1445. data/spec/unit/run_list/versioned_recipe_list_spec.rb +2 -2
  1446. data/spec/unit/run_list_spec.rb +1 -1
  1447. data/spec/unit/run_lock_spec.rb +7 -3
  1448. data/spec/unit/run_status_spec.rb +1 -1
  1449. data/spec/unit/runner_spec.rb +2 -3
  1450. data/spec/unit/scan_access_control_spec.rb +2 -2
  1451. data/spec/unit/search/query_spec.rb +10 -3
  1452. data/spec/unit/secret_fetcher/akeyless_vault_spec.rb +37 -0
  1453. data/spec/unit/secret_fetcher/aws_secrets_manager_spec.rb +70 -0
  1454. data/spec/unit/secret_fetcher/azure_key_vault_spec.rb +149 -0
  1455. data/spec/unit/secret_fetcher/hashi_vault_spec.rb +126 -0
  1456. data/spec/unit/secret_fetcher_spec.rb +82 -0
  1457. data/spec/unit/server_api_spec.rb +43 -16
  1458. data/spec/unit/server_api_versions_spec.rb +1 -1
  1459. data/spec/unit/shell/model_wrapper_spec.rb +1 -1
  1460. data/spec/unit/shell/shell_ext_spec.rb +47 -4
  1461. data/spec/unit/shell/shell_session_spec.rb +35 -64
  1462. data/spec/unit/shell_spec.rb +19 -22
  1463. data/spec/unit/train_transport_spec.rb +85 -0
  1464. data/spec/unit/user_spec.rb +2 -2
  1465. data/spec/unit/user_v1_spec.rb +16 -14
  1466. data/spec/unit/util/backup_spec.rb +3 -3
  1467. data/spec/unit/util/diff_spec.rb +3 -17
  1468. data/spec/unit/util/dsc/configuration_generator_spec.rb +81 -2
  1469. data/spec/unit/util/dsc/lcm_output_parser_spec.rb +1 -1
  1470. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +28 -36
  1471. data/spec/unit/util/dsc/resource_store.rb +2 -2
  1472. data/spec/unit/util/file_edit_spec.rb +2 -2
  1473. data/spec/unit/util/powershell/ps_credential_spec.rb +3 -3
  1474. data/spec/unit/util/selinux_spec.rb +7 -4
  1475. data/spec/unit/util/threaded_job_queue_spec.rb +10 -1
  1476. data/spec/unit/util/windows/logon_session_spec.rb +2 -2
  1477. data/spec/unit/version_class_spec.rb +1 -1
  1478. data/spec/unit/version_constraint_spec.rb +1 -1
  1479. data/spec/unit/win32/error_spec.rb +2 -2
  1480. data/spec/unit/win32/link_spec.rb +5 -5
  1481. data/spec/unit/win32/registry_spec.rb +5 -5
  1482. data/spec/unit/win32/security_spec.rb +6 -5
  1483. data/tasks/rspec.rb +23 -26
  1484. metadata +469 -584
  1485. data/bin/chef-apply +0 -24
  1486. data/bin/chef-client +0 -25
  1487. data/bin/chef-resource-inspector +0 -26
  1488. data/bin/chef-shell +0 -31
  1489. data/bin/chef-solo +0 -24
  1490. data/bin/knife +0 -24
  1491. data/chef-universal-mingw32.gemspec +0 -24
  1492. data/lib/chef/application/knife.rb +0 -221
  1493. data/lib/chef/application/windows_service.rb +0 -337
  1494. data/lib/chef/application/windows_service_manager.rb +0 -204
  1495. data/lib/chef/audit/audit_event_proxy.rb +0 -93
  1496. data/lib/chef/audit/audit_reporter.rb +0 -176
  1497. data/lib/chef/audit/control_group_data.rb +0 -145
  1498. data/lib/chef/audit/rspec_formatter.rb +0 -37
  1499. data/lib/chef/audit/runner.rb +0 -196
  1500. data/lib/chef/chef_fs/knife.rb +0 -161
  1501. data/lib/chef/chef_fs/parallelizer/flatten_enumerable.rb +0 -35
  1502. data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +0 -277
  1503. data/lib/chef/chef_fs/parallelizer.rb +0 -103
  1504. data/lib/chef/cookbook_site_streaming_uploader.rb +0 -241
  1505. data/lib/chef/data_collector/messages/helpers.rb +0 -159
  1506. data/lib/chef/data_collector/messages.rb +0 -100
  1507. data/lib/chef/data_collector/resource_report.rb +0 -123
  1508. data/lib/chef/dsl/audit.rb +0 -51
  1509. data/lib/chef/dsl/chef_provisioning.rb +0 -57
  1510. data/lib/chef/dsl/core.rb +0 -52
  1511. data/lib/chef/knife/bootstrap/chef_vault_handler.rb +0 -159
  1512. data/lib/chef/knife/bootstrap/client_builder.rb +0 -208
  1513. data/lib/chef/knife/bootstrap/templates/README.md +0 -11
  1514. data/lib/chef/knife/bootstrap/templates/chef-full.erb +0 -243
  1515. data/lib/chef/knife/bootstrap.rb +0 -525
  1516. data/lib/chef/knife/client_bulk_delete.rb +0 -103
  1517. data/lib/chef/knife/client_create.rb +0 -110
  1518. data/lib/chef/knife/client_delete.rb +0 -62
  1519. data/lib/chef/knife/client_edit.rb +0 -52
  1520. data/lib/chef/knife/client_key_create.rb +0 -70
  1521. data/lib/chef/knife/client_key_delete.rb +0 -77
  1522. data/lib/chef/knife/client_key_edit.rb +0 -80
  1523. data/lib/chef/knife/client_key_list.rb +0 -70
  1524. data/lib/chef/knife/client_key_show.rb +0 -77
  1525. data/lib/chef/knife/client_list.rb +0 -41
  1526. data/lib/chef/knife/client_reregister.rb +0 -58
  1527. data/lib/chef/knife/client_show.rb +0 -48
  1528. data/lib/chef/knife/config_get.rb +0 -127
  1529. data/lib/chef/knife/config_get_profile.rb +0 -37
  1530. data/lib/chef/knife/config_list_profiles.rb +0 -121
  1531. data/lib/chef/knife/config_use_profile.rb +0 -50
  1532. data/lib/chef/knife/configure.rb +0 -147
  1533. data/lib/chef/knife/configure_client.rb +0 -48
  1534. data/lib/chef/knife/cookbook_bulk_delete.rb +0 -71
  1535. data/lib/chef/knife/cookbook_delete.rb +0 -151
  1536. data/lib/chef/knife/cookbook_download.rb +0 -142
  1537. data/lib/chef/knife/cookbook_list.rb +0 -47
  1538. data/lib/chef/knife/cookbook_metadata.rb +0 -106
  1539. data/lib/chef/knife/cookbook_metadata_from_file.rb +0 -43
  1540. data/lib/chef/knife/cookbook_show.rb +0 -98
  1541. data/lib/chef/knife/cookbook_site_download.rb +0 -40
  1542. data/lib/chef/knife/cookbook_site_install.rb +0 -40
  1543. data/lib/chef/knife/cookbook_site_list.rb +0 -40
  1544. data/lib/chef/knife/cookbook_site_search.rb +0 -40
  1545. data/lib/chef/knife/cookbook_site_share.rb +0 -41
  1546. data/lib/chef/knife/cookbook_site_show.rb +0 -40
  1547. data/lib/chef/knife/cookbook_site_unshare.rb +0 -41
  1548. data/lib/chef/knife/cookbook_test.rb +0 -95
  1549. data/lib/chef/knife/cookbook_upload.rb +0 -308
  1550. data/lib/chef/knife/core/bootstrap_context.rb +0 -273
  1551. data/lib/chef/knife/core/cookbook_scm_repo.rb +0 -159
  1552. data/lib/chef/knife/core/gem_glob_loader.rb +0 -138
  1553. data/lib/chef/knife/core/generic_presenter.rb +0 -231
  1554. data/lib/chef/knife/core/hashed_command_loader.rb +0 -99
  1555. data/lib/chef/knife/core/node_editor.rb +0 -130
  1556. data/lib/chef/knife/core/node_presenter.rb +0 -158
  1557. data/lib/chef/knife/core/object_loader.rb +0 -115
  1558. data/lib/chef/knife/core/status_presenter.rb +0 -172
  1559. data/lib/chef/knife/core/subcommand_loader.rb +0 -183
  1560. data/lib/chef/knife/core/text_formatter.rb +0 -85
  1561. data/lib/chef/knife/core/ui.rb +0 -286
  1562. data/lib/chef/knife/data_bag_create.rb +0 -80
  1563. data/lib/chef/knife/data_bag_delete.rb +0 -49
  1564. data/lib/chef/knife/data_bag_edit.rb +0 -74
  1565. data/lib/chef/knife/data_bag_from_file.rb +0 -113
  1566. data/lib/chef/knife/data_bag_secret_options.rb +0 -142
  1567. data/lib/chef/knife/data_bag_show.rb +0 -69
  1568. data/lib/chef/knife/delete.rb +0 -125
  1569. data/lib/chef/knife/deps.rb +0 -154
  1570. data/lib/chef/knife/diff.rb +0 -84
  1571. data/lib/chef/knife/download.rb +0 -84
  1572. data/lib/chef/knife/edit.rb +0 -88
  1573. data/lib/chef/knife/environment_compare.rb +0 -127
  1574. data/lib/chef/knife/environment_create.rb +0 -52
  1575. data/lib/chef/knife/environment_delete.rb +0 -44
  1576. data/lib/chef/knife/environment_from_file.rb +0 -84
  1577. data/lib/chef/knife/environment_list.rb +0 -41
  1578. data/lib/chef/knife/environment_show.rb +0 -47
  1579. data/lib/chef/knife/exec.rb +0 -87
  1580. data/lib/chef/knife/key_create.rb +0 -112
  1581. data/lib/chef/knife/key_create_base.rb +0 -50
  1582. data/lib/chef/knife/key_delete.rb +0 -55
  1583. data/lib/chef/knife/key_edit.rb +0 -118
  1584. data/lib/chef/knife/key_edit_base.rb +0 -55
  1585. data/lib/chef/knife/key_list.rb +0 -88
  1586. data/lib/chef/knife/key_list_base.rb +0 -45
  1587. data/lib/chef/knife/key_show.rb +0 -53
  1588. data/lib/chef/knife/list.rb +0 -172
  1589. data/lib/chef/knife/node_bulk_delete.rb +0 -74
  1590. data/lib/chef/knife/node_create.rb +0 -47
  1591. data/lib/chef/knife/node_delete.rb +0 -46
  1592. data/lib/chef/knife/node_edit.rb +0 -70
  1593. data/lib/chef/knife/node_environment_set.rb +0 -54
  1594. data/lib/chef/knife/node_list.rb +0 -44
  1595. data/lib/chef/knife/node_policy_set.rb +0 -79
  1596. data/lib/chef/knife/node_run_list_add.rb +0 -104
  1597. data/lib/chef/knife/node_run_list_remove.rb +0 -67
  1598. data/lib/chef/knife/node_run_list_set.rb +0 -66
  1599. data/lib/chef/knife/node_show.rb +0 -61
  1600. data/lib/chef/knife/null.rb +0 -10
  1601. data/lib/chef/knife/osc_user_create.rb +0 -97
  1602. data/lib/chef/knife/osc_user_delete.rb +0 -51
  1603. data/lib/chef/knife/osc_user_edit.rb +0 -58
  1604. data/lib/chef/knife/osc_user_list.rb +0 -47
  1605. data/lib/chef/knife/osc_user_reregister.rb +0 -64
  1606. data/lib/chef/knife/osc_user_show.rb +0 -53
  1607. data/lib/chef/knife/raw.rb +0 -124
  1608. data/lib/chef/knife/rehash.rb +0 -65
  1609. data/lib/chef/knife/role_bulk_delete.rb +0 -65
  1610. data/lib/chef/knife/role_create.rb +0 -53
  1611. data/lib/chef/knife/role_delete.rb +0 -46
  1612. data/lib/chef/knife/role_edit.rb +0 -45
  1613. data/lib/chef/knife/role_env_run_list_add.rb +0 -87
  1614. data/lib/chef/knife/role_env_run_list_clear.rb +0 -55
  1615. data/lib/chef/knife/role_env_run_list_remove.rb +0 -57
  1616. data/lib/chef/knife/role_env_run_list_replace.rb +0 -60
  1617. data/lib/chef/knife/role_env_run_list_set.rb +0 -70
  1618. data/lib/chef/knife/role_from_file.rb +0 -51
  1619. data/lib/chef/knife/role_list.rb +0 -42
  1620. data/lib/chef/knife/role_run_list_add.rb +0 -87
  1621. data/lib/chef/knife/role_run_list_clear.rb +0 -55
  1622. data/lib/chef/knife/role_run_list_remove.rb +0 -56
  1623. data/lib/chef/knife/role_run_list_replace.rb +0 -60
  1624. data/lib/chef/knife/role_run_list_set.rb +0 -69
  1625. data/lib/chef/knife/role_show.rb +0 -48
  1626. data/lib/chef/knife/search.rb +0 -194
  1627. data/lib/chef/knife/serve.rb +0 -64
  1628. data/lib/chef/knife/show.rb +0 -72
  1629. data/lib/chef/knife/ssh.rb +0 -640
  1630. data/lib/chef/knife/ssl_check.rb +0 -283
  1631. data/lib/chef/knife/ssl_fetch.rb +0 -161
  1632. data/lib/chef/knife/status.rb +0 -110
  1633. data/lib/chef/knife/supermarket_download.rb +0 -122
  1634. data/lib/chef/knife/supermarket_install.rb +0 -193
  1635. data/lib/chef/knife/supermarket_list.rb +0 -65
  1636. data/lib/chef/knife/supermarket_search.rb +0 -53
  1637. data/lib/chef/knife/supermarket_share.rb +0 -166
  1638. data/lib/chef/knife/supermarket_show.rb +0 -67
  1639. data/lib/chef/knife/supermarket_unshare.rb +0 -61
  1640. data/lib/chef/knife/tag_create.rb +0 -52
  1641. data/lib/chef/knife/tag_delete.rb +0 -60
  1642. data/lib/chef/knife/tag_list.rb +0 -47
  1643. data/lib/chef/knife/upload.rb +0 -86
  1644. data/lib/chef/knife/user_create.rb +0 -151
  1645. data/lib/chef/knife/user_delete.rb +0 -96
  1646. data/lib/chef/knife/user_edit.rb +0 -82
  1647. data/lib/chef/knife/user_key_create.rb +0 -70
  1648. data/lib/chef/knife/user_key_delete.rb +0 -77
  1649. data/lib/chef/knife/user_key_edit.rb +0 -80
  1650. data/lib/chef/knife/user_key_list.rb +0 -70
  1651. data/lib/chef/knife/user_key_show.rb +0 -77
  1652. data/lib/chef/knife/user_list.rb +0 -44
  1653. data/lib/chef/knife/user_reregister.rb +0 -90
  1654. data/lib/chef/knife/user_show.rb +0 -79
  1655. data/lib/chef/knife/xargs.rb +0 -282
  1656. data/lib/chef/knife.rb +0 -630
  1657. data/lib/chef/monkey_patches/net_http.rb +0 -64
  1658. data/lib/chef/nil_argument.rb +0 -3
  1659. data/lib/chef/provider/apt_preference.rb +0 -94
  1660. data/lib/chef/provider/apt_repository.rb +0 -360
  1661. data/lib/chef/provider/apt_update.rb +0 -80
  1662. data/lib/chef/provider/group/suse.rb +0 -83
  1663. data/lib/chef/provider/log.rb +0 -43
  1664. data/lib/chef/provider/mdadm.rb +0 -85
  1665. data/lib/chef/provider/ohai.rb +0 -45
  1666. data/lib/chef/provider/osx_profile.rb +0 -251
  1667. data/lib/chef/provider/package/freebsd/pkg.rb +0 -114
  1668. data/lib/chef/provider/package/yum/simplejson/LICENSE.txt +0 -79
  1669. data/lib/chef/provider/package/yum/simplejson/__init__.py +0 -318
  1670. data/lib/chef/provider/package/yum/simplejson/__init__.pyc +0 -0
  1671. data/lib/chef/provider/package/yum/simplejson/decoder.py +0 -354
  1672. data/lib/chef/provider/package/yum/simplejson/decoder.pyc +0 -0
  1673. data/lib/chef/provider/package/yum/simplejson/encoder.py +0 -440
  1674. data/lib/chef/provider/package/yum/simplejson/encoder.pyc +0 -0
  1675. data/lib/chef/provider/package/yum/simplejson/scanner.py +0 -65
  1676. data/lib/chef/provider/package/yum/simplejson/scanner.pyc +0 -0
  1677. data/lib/chef/provider/package/yum/simplejson/tool.py +0 -37
  1678. data/lib/chef/provider/reboot.rb +0 -78
  1679. data/lib/chef/provider/user/useradd.rb +0 -161
  1680. data/lib/chef/provider/windows_env.rb +0 -207
  1681. data/lib/chef/provider/windows_path.rb +0 -61
  1682. data/lib/chef/provider/windows_task.rb +0 -635
  1683. data/lib/chef/resource/cron.rb +0 -174
  1684. data/lib/chef/resource/cron_d.rb +0 -238
  1685. data/lib/chef/resource/git.rb +0 -35
  1686. data/lib/chef/resource/scm.rb +0 -75
  1687. data/lib/chef/resource/subversion.rb +0 -55
  1688. data/lib/chef/util/powershell/cmdlet.rb +0 -173
  1689. data/lib/chef/util/powershell/cmdlet_result.rb +0 -61
  1690. data/spec/data/mac_users/10.7-8.plist.xml +0 -559
  1691. data/spec/data/mac_users/10.7-8.shadow.xml +0 -11
  1692. data/spec/data/mac_users/10.7.plist.xml +0 -559
  1693. data/spec/data/mac_users/10.7.shadow.xml +0 -11
  1694. data/spec/data/mac_users/10.8.plist.xml +0 -559
  1695. data/spec/data/mac_users/10.8.shadow.xml +0 -21
  1696. data/spec/functional/audit/rspec_formatter_spec.rb +0 -54
  1697. data/spec/functional/audit/runner_spec.rb +0 -121
  1698. data/spec/functional/knife/cookbook_delete_spec.rb +0 -156
  1699. data/spec/functional/knife/exec_spec.rb +0 -55
  1700. data/spec/functional/knife/rehash_spec.rb +0 -39
  1701. data/spec/functional/knife/smoke_test.rb +0 -42
  1702. data/spec/functional/knife/ssh_spec.rb +0 -359
  1703. data/spec/functional/resource/base.rb +0 -28
  1704. data/spec/functional/resource/windows_service_spec.rb +0 -102
  1705. data/spec/functional/util/powershell/cmdlet_spec.rb +0 -111
  1706. data/spec/functional/win32/service_manager_spec.rb +0 -220
  1707. data/spec/integration/knife/chef_fs_data_store_spec.rb +0 -556
  1708. data/spec/integration/knife/chef_repo_path_spec.rb +0 -961
  1709. data/spec/integration/knife/chef_repository_file_system_spec.rb +0 -199
  1710. data/spec/integration/knife/chefignore_spec.rb +0 -300
  1711. data/spec/integration/knife/client_bulk_delete_spec.rb +0 -130
  1712. data/spec/integration/knife/client_create_spec.rb +0 -69
  1713. data/spec/integration/knife/client_delete_spec.rb +0 -63
  1714. data/spec/integration/knife/client_key_create_spec.rb +0 -65
  1715. data/spec/integration/knife/client_key_delete_spec.rb +0 -42
  1716. data/spec/integration/knife/client_key_list_spec.rb +0 -60
  1717. data/spec/integration/knife/client_key_show_spec.rb +0 -44
  1718. data/spec/integration/knife/client_list_spec.rb +0 -48
  1719. data/spec/integration/knife/client_show_spec.rb +0 -36
  1720. data/spec/integration/knife/common_options_spec.rb +0 -173
  1721. data/spec/integration/knife/config_get_profile_spec.rb +0 -112
  1722. data/spec/integration/knife/config_get_spec.rb +0 -190
  1723. data/spec/integration/knife/config_list_profiles_spec.rb +0 -189
  1724. data/spec/integration/knife/config_use_profile_spec.rb +0 -100
  1725. data/spec/integration/knife/cookbook_api_ipv6_spec.rb +0 -112
  1726. data/spec/integration/knife/cookbook_bulk_delete_spec.rb +0 -64
  1727. data/spec/integration/knife/cookbook_download_spec.rb +0 -71
  1728. data/spec/integration/knife/cookbook_list_spec.rb +0 -54
  1729. data/spec/integration/knife/cookbook_show_spec.rb +0 -148
  1730. data/spec/integration/knife/cookbook_upload_spec.rb +0 -90
  1731. data/spec/integration/knife/data_bag_create_spec.rb +0 -124
  1732. data/spec/integration/knife/data_bag_delete_spec.rb +0 -58
  1733. data/spec/integration/knife/data_bag_edit_spec.rb +0 -104
  1734. data/spec/integration/knife/data_bag_from_file_spec.rb +0 -115
  1735. data/spec/integration/knife/data_bag_list_spec.rb +0 -43
  1736. data/spec/integration/knife/data_bag_show_spec.rb +0 -94
  1737. data/spec/integration/knife/delete_spec.rb +0 -1017
  1738. data/spec/integration/knife/deps_spec.rb +0 -702
  1739. data/spec/integration/knife/diff_spec.rb +0 -602
  1740. data/spec/integration/knife/download_spec.rb +0 -1333
  1741. data/spec/integration/knife/environment_compare_spec.rb +0 -74
  1742. data/spec/integration/knife/environment_create_spec.rb +0 -40
  1743. data/spec/integration/knife/environment_delete_spec.rb +0 -36
  1744. data/spec/integration/knife/environment_from_file_spec.rb +0 -115
  1745. data/spec/integration/knife/environment_list_spec.rb +0 -41
  1746. data/spec/integration/knife/environment_show_spec.rb +0 -76
  1747. data/spec/integration/knife/list_spec.rb +0 -1059
  1748. data/spec/integration/knife/node_bulk_delete_spec.rb +0 -51
  1749. data/spec/integration/knife/node_create_spec.rb +0 -46
  1750. data/spec/integration/knife/node_delete_spec.rb +0 -47
  1751. data/spec/integration/knife/node_environment_set_spec.rb +0 -45
  1752. data/spec/integration/knife/node_from_file_spec.rb +0 -58
  1753. data/spec/integration/knife/node_list_spec.rb +0 -44
  1754. data/spec/integration/knife/node_run_list_add_spec.rb +0 -53
  1755. data/spec/integration/knife/node_run_list_remove_spec.rb +0 -35
  1756. data/spec/integration/knife/node_run_list_set_spec.rb +0 -40
  1757. data/spec/integration/knife/node_show_spec.rb +0 -35
  1758. data/spec/integration/knife/raw_spec.rb +0 -248
  1759. data/spec/integration/knife/redirection_spec.rb +0 -54
  1760. data/spec/integration/knife/role_bulk_delete_spec.rb +0 -51
  1761. data/spec/integration/knife/role_create_spec.rb +0 -40
  1762. data/spec/integration/knife/role_delete_spec.rb +0 -47
  1763. data/spec/integration/knife/role_from_file_spec.rb +0 -95
  1764. data/spec/integration/knife/role_list_spec.rb +0 -44
  1765. data/spec/integration/knife/role_show_spec.rb +0 -50
  1766. data/spec/integration/knife/search_node_spec.rb +0 -39
  1767. data/spec/integration/knife/serve_spec.rb +0 -93
  1768. data/spec/integration/knife/show_spec.rb +0 -167
  1769. data/spec/integration/knife/upload_spec.rb +0 -1540
  1770. data/spec/scripts/ssl-serve.rb +0 -47
  1771. data/spec/support/mock/constant.rb +0 -52
  1772. data/spec/support/shared/context/client.rb +0 -306
  1773. data/spec/support/shared/examples/client.rb +0 -104
  1774. data/spec/support/shared/functional/win32_service.rb +0 -57
  1775. data/spec/support/shared/integration/app_server_support.rb +0 -39
  1776. data/spec/unit/application/knife_spec.rb +0 -228
  1777. data/spec/unit/audit/audit_event_proxy_spec.rb +0 -325
  1778. data/spec/unit/audit/audit_reporter_spec.rb +0 -444
  1779. data/spec/unit/audit/control_group_data_spec.rb +0 -487
  1780. data/spec/unit/audit/logger_spec.rb +0 -42
  1781. data/spec/unit/audit/runner_spec.rb +0 -144
  1782. data/spec/unit/chef_fs/parallelizer.rb +0 -477
  1783. data/spec/unit/cookbook_site_streaming_uploader_spec.rb +0 -198
  1784. data/spec/unit/data_collector/messages/helpers_spec.rb +0 -202
  1785. data/spec/unit/data_collector/messages_spec.rb +0 -329
  1786. data/spec/unit/data_collector/resource_report_spec.rb +0 -145
  1787. data/spec/unit/dsl/audit_spec.rb +0 -43
  1788. data/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb +0 -152
  1789. data/spec/unit/knife/bootstrap/client_builder_spec.rb +0 -207
  1790. data/spec/unit/knife/bootstrap_spec.rb +0 -976
  1791. data/spec/unit/knife/client_bulk_delete_spec.rb +0 -166
  1792. data/spec/unit/knife/client_create_spec.rb +0 -186
  1793. data/spec/unit/knife/client_delete_spec.rb +0 -99
  1794. data/spec/unit/knife/client_edit_spec.rb +0 -53
  1795. data/spec/unit/knife/client_reregister_spec.rb +0 -62
  1796. data/spec/unit/knife/client_show_spec.rb +0 -52
  1797. data/spec/unit/knife/configure_client_spec.rb +0 -81
  1798. data/spec/unit/knife/configure_spec.rb +0 -190
  1799. data/spec/unit/knife/cookbook_bulk_delete_spec.rb +0 -87
  1800. data/spec/unit/knife/cookbook_create_spec.rb +0 -42
  1801. data/spec/unit/knife/cookbook_delete_spec.rb +0 -239
  1802. data/spec/unit/knife/cookbook_download_spec.rb +0 -255
  1803. data/spec/unit/knife/cookbook_list_spec.rb +0 -88
  1804. data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +0 -65
  1805. data/spec/unit/knife/cookbook_metadata_spec.rb +0 -182
  1806. data/spec/unit/knife/cookbook_show_spec.rb +0 -254
  1807. data/spec/unit/knife/cookbook_test_spec.rb +0 -84
  1808. data/spec/unit/knife/cookbook_upload_spec.rb +0 -333
  1809. data/spec/unit/knife/core/bootstrap_context_spec.rb +0 -324
  1810. data/spec/unit/knife/core/cookbook_scm_repo_spec.rb +0 -187
  1811. data/spec/unit/knife/core/gem_glob_loader_spec.rb +0 -209
  1812. data/spec/unit/knife/core/hashed_command_loader_spec.rb +0 -112
  1813. data/spec/unit/knife/core/node_editor_spec.rb +0 -211
  1814. data/spec/unit/knife/core/object_loader_spec.rb +0 -81
  1815. data/spec/unit/knife/core/subcommand_loader_spec.rb +0 -64
  1816. data/spec/unit/knife/core/ui_spec.rb +0 -639
  1817. data/spec/unit/knife/data_bag_create_spec.rb +0 -175
  1818. data/spec/unit/knife/data_bag_edit_spec.rb +0 -126
  1819. data/spec/unit/knife/data_bag_from_file_spec.rb +0 -174
  1820. data/spec/unit/knife/data_bag_secret_options_spec.rb +0 -165
  1821. data/spec/unit/knife/data_bag_show_spec.rb +0 -139
  1822. data/spec/unit/knife/environment_compare_spec.rb +0 -112
  1823. data/spec/unit/knife/environment_create_spec.rb +0 -91
  1824. data/spec/unit/knife/environment_delete_spec.rb +0 -71
  1825. data/spec/unit/knife/environment_edit_spec.rb +0 -79
  1826. data/spec/unit/knife/environment_from_file_spec.rb +0 -90
  1827. data/spec/unit/knife/environment_list_spec.rb +0 -54
  1828. data/spec/unit/knife/environment_show_spec.rb +0 -52
  1829. data/spec/unit/knife/key_create_spec.rb +0 -223
  1830. data/spec/unit/knife/key_delete_spec.rb +0 -133
  1831. data/spec/unit/knife/key_edit_spec.rb +0 -264
  1832. data/spec/unit/knife/key_helper.rb +0 -74
  1833. data/spec/unit/knife/key_list_spec.rb +0 -216
  1834. data/spec/unit/knife/key_show_spec.rb +0 -126
  1835. data/spec/unit/knife/node_bulk_delete_spec.rb +0 -94
  1836. data/spec/unit/knife/node_delete_spec.rb +0 -77
  1837. data/spec/unit/knife/node_edit_spec.rb +0 -116
  1838. data/spec/unit/knife/node_environment_set_spec.rb +0 -56
  1839. data/spec/unit/knife/node_from_file_spec.rb +0 -59
  1840. data/spec/unit/knife/node_list_spec.rb +0 -62
  1841. data/spec/unit/knife/node_policy_set_spec.rb +0 -122
  1842. data/spec/unit/knife/node_run_list_add_spec.rb +0 -145
  1843. data/spec/unit/knife/node_run_list_remove_spec.rb +0 -106
  1844. data/spec/unit/knife/node_run_list_set_spec.rb +0 -115
  1845. data/spec/unit/knife/node_show_spec.rb +0 -65
  1846. data/spec/unit/knife/osc_user_create_spec.rb +0 -93
  1847. data/spec/unit/knife/osc_user_delete_spec.rb +0 -44
  1848. data/spec/unit/knife/osc_user_edit_spec.rb +0 -52
  1849. data/spec/unit/knife/osc_user_reregister_spec.rb +0 -58
  1850. data/spec/unit/knife/osc_user_show_spec.rb +0 -46
  1851. data/spec/unit/knife/raw_spec.rb +0 -43
  1852. data/spec/unit/knife/role_bulk_delete_spec.rb +0 -80
  1853. data/spec/unit/knife/role_create_spec.rb +0 -80
  1854. data/spec/unit/knife/role_delete_spec.rb +0 -67
  1855. data/spec/unit/knife/role_edit_spec.rb +0 -77
  1856. data/spec/unit/knife/role_env_run_list_add_spec.rb +0 -217
  1857. data/spec/unit/knife/role_env_run_list_clear_spec.rb +0 -94
  1858. data/spec/unit/knife/role_env_run_list_remove_spec.rb +0 -102
  1859. data/spec/unit/knife/role_env_run_list_replace_spec.rb +0 -105
  1860. data/spec/unit/knife/role_env_run_list_set_spec.rb +0 -99
  1861. data/spec/unit/knife/role_from_file_spec.rb +0 -69
  1862. data/spec/unit/knife/role_list_spec.rb +0 -54
  1863. data/spec/unit/knife/role_run_list_add_spec.rb +0 -179
  1864. data/spec/unit/knife/role_run_list_clear_spec.rb +0 -84
  1865. data/spec/unit/knife/role_run_list_remove_spec.rb +0 -92
  1866. data/spec/unit/knife/role_run_list_replace_spec.rb +0 -98
  1867. data/spec/unit/knife/role_run_list_set_spec.rb +0 -89
  1868. data/spec/unit/knife/role_show_spec.rb +0 -59
  1869. data/spec/unit/knife/ssh_spec.rb +0 -506
  1870. data/spec/unit/knife/ssl_check_spec.rb +0 -256
  1871. data/spec/unit/knife/ssl_fetch_spec.rb +0 -222
  1872. data/spec/unit/knife/status_spec.rb +0 -112
  1873. data/spec/unit/knife/supermarket_download_spec.rb +0 -152
  1874. data/spec/unit/knife/supermarket_install_spec.rb +0 -202
  1875. data/spec/unit/knife/supermarket_share_spec.rb +0 -209
  1876. data/spec/unit/knife/supermarket_unshare_spec.rb +0 -78
  1877. data/spec/unit/knife/tag_create_spec.rb +0 -23
  1878. data/spec/unit/knife/tag_delete_spec.rb +0 -25
  1879. data/spec/unit/knife/tag_list_spec.rb +0 -23
  1880. data/spec/unit/knife/user_create_spec.rb +0 -214
  1881. data/spec/unit/knife/user_delete_spec.rb +0 -65
  1882. data/spec/unit/knife/user_edit_spec.rb +0 -66
  1883. data/spec/unit/knife/user_reregister_spec.rb +0 -74
  1884. data/spec/unit/knife/user_show_spec.rb +0 -65
  1885. data/spec/unit/knife_spec.rb +0 -589
  1886. data/spec/unit/mash_spec.rb +0 -51
  1887. data/spec/unit/monkey_patches/uri_spec.rb +0 -34
  1888. data/spec/unit/provider/group/suse_spec.rb +0 -90
  1889. data/spec/unit/provider/ohai_spec.rb +0 -84
  1890. data/spec/unit/provider/osx_profile_spec.rb +0 -255
  1891. data/spec/unit/provider/package/freebsd/pkg_spec.rb +0 -274
  1892. data/spec/unit/provider/user/dscl_spec.rb +0 -920
  1893. data/spec/unit/provider_resolver_spec.rb +0 -923
  1894. data/spec/unit/resource/timezone.rb +0 -39
  1895. data/spec/unit/util/powershell/cmdlet_spec.rb +0 -106
  1896. data/spec/unit/windows_service_spec.rb +0 -118
  1897. data/tasks/announce.rb +0 -51
  1898. data/tasks/bin/run_external_test +0 -29
  1899. data/tasks/dependencies.rb +0 -58
  1900. data/tasks/templates/release.md.erb +0 -34
@@ -2,7 +2,7 @@
2
2
  # Author:: Richard Lavey (richard.lavey@calastone.com)
3
3
  #
4
4
  # Copyright:: 2015-2017, Calastone Ltd.
5
- # Copyright:: 2018, Chef Software, Inc.
5
+ # Copyright:: Copyright (c) Chef Software Inc.
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
8
8
  # you may not use this file except in compliance with the License.
@@ -17,59 +17,94 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require "chef/util/path_helper"
21
- require "chef/resource"
22
- require "win32-certstore" if Chef::Platform.windows?
23
- require "openssl"
20
+ require_relative "../util/path_helper"
21
+ require_relative "../resource"
22
+ require_relative "../exceptions"
23
+ module Win32
24
+ autoload :Certstore, "win32-certstore" if Chef::Platform.windows?
25
+ end
26
+ autoload :OpenSSL, "openssl"
27
+ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
24
28
 
25
29
  class Chef
26
30
  class Resource
27
31
  class WindowsCertificate < Chef::Resource
28
- preview_resource true
29
- resource_name :windows_certificate
30
32
 
31
- description "Use the windows_certificate resource to install a certificate into the Windows certificate store from a file. The resource grants read-only access to the private key for designated accounts. Due to current limitations in WinRM, installing certificates remotely may not work if the operation requires a user profile. Operations on the local machine store should still work."
33
+ provides :windows_certificate
34
+
35
+ description "Use the **windows_certificate** resource to install a certificate into the Windows certificate store from a file. The resource grants read-only access to the private key for designated accounts. Due to current limitations in WinRM, installing certificates remotely may not work if the operation requires a user profile. Operations on the local machine store should still work."
32
36
  introduced "14.7"
37
+ examples <<~DOC
38
+ **Add PFX cert to local machine personal store and grant accounts read-only access to private key**
39
+
40
+ ```ruby
41
+ windows_certificate 'c:/test/mycert.pfx' do
42
+ pfx_password 'password'
43
+ private_key_acl ["acme\\fred", "pc\\jane"]
44
+ end
45
+ ```
46
+
47
+ **Add cert to trusted intermediate store**
48
+
49
+ ```ruby
50
+ windows_certificate 'c:/test/mycert.cer' do
51
+ store_name 'CA'
52
+ end
53
+ ```
54
+
55
+ **Remove all certificates matching the subject**
56
+
57
+ ```ruby
58
+ windows_certificate 'me.acme.com' do
59
+ action :delete
60
+ end
61
+ ```
62
+ DOC
33
63
 
34
64
  property :source, String,
35
- description: "The source file (for create and acl_add), thumbprint (for delete and acl_add) or subject (for delete) if it differs from the resource block's name.",
36
- name_property: true
65
+ description: "The source file (for `create` and `acl_add`), thumbprint (for `delete`, `export`, and `acl_add`), or subject (for `delete` or `export`) if it differs from the resource block's name.",
66
+ name_property: true
37
67
 
38
68
  property :pfx_password, String,
39
- description: "The password to access the source if it is a pfx file."
69
+ description: "The password to access the object with if it is a PFX file."
40
70
 
41
71
  property :private_key_acl, Array,
42
- description: "An array of 'domain\account' entries to be granted read-only access to the certificate's private key. Not idempotent."
72
+ description: "An array of 'domain\\account' entries to be granted read-only access to the certificate's private key. Not idempotent."
43
73
 
44
74
  property :store_name, String,
45
- description: "The certificate store to manipulate.",
46
- default: "MY", equal_to: ["TRUSTEDPUBLISHER", "TrustedPublisher", "CLIENTAUTHISSUER", "REMOTE DESKTOP", "ROOT", "TRUSTEDDEVICES", "WEBHOSTING", "CA", "AUTHROOT", "TRUSTEDPEOPLE", "MY", "SMARTCARDROOT", "TRUST", "DISALLOWED"]
75
+ description: "The certificate store to manipulate.",
76
+ default: "MY", equal_to: ["TRUSTEDPUBLISHER", "TrustedPublisher", "CLIENTAUTHISSUER", "REMOTE DESKTOP", "ROOT", "TRUSTEDDEVICES", "WEBHOSTING", "CA", "AUTHROOT", "TRUSTEDPEOPLE", "MY", "SMARTCARDROOT", "TRUST", "DISALLOWED"]
47
77
 
48
78
  property :user_store, [TrueClass, FalseClass],
49
- description: "Use the user store of the local machine store if set to false.",
50
- default: false
79
+ description: "Use the `CurrentUser` store instead of the default `LocalMachine` store. Note: Prior to #{ChefUtils::Dist::Infra::CLIENT}. 16.10 this property was ignored.",
80
+ default: false
51
81
 
52
- property :cert_path, String,
53
- description: ""
82
+ deprecated_property_alias :cert_path, :output_path, "The cert_path property was renamed output_path in the 17.0 release of #{ChefUtils::Dist::Infra::CLIENT}. Please update your cookbooks to use the new property name."
54
83
 
55
84
  # lazy used to set default value of sensitive to true if password is set
56
85
  property :sensitive, [TrueClass, FalseClass],
57
- description: "Ensure that sensitive resource data is not logged by the chef-client.",
58
- default: lazy { |r| r.pfx_password ? true : false }, skip_docs: true
86
+ description: "Ensure that sensitive resource data is not logged by the #{ChefUtils::Dist::Infra::CLIENT}.",
87
+ default: lazy { pfx_password ? true : false }, skip_docs: true
59
88
 
60
- action :create do
61
- description "Creates or updates a certificate."
89
+ property :exportable, [TrueClass, FalseClass],
90
+ description: "Ensure that imported pfx certificate is exportable. Please provide 'true' if you want the certificate to be exportable.",
91
+ default: false,
92
+ introduced: "16.8"
62
93
 
63
- # Extension of the certificate
64
- ext = ::File.extname(new_resource.source)
94
+ property :output_path, String,
95
+ description: "A path on the node where a certificate object (PFX, PEM, CER, KEY, etc) can be exported to.",
96
+ introduced: "17.0"
65
97
 
66
- # PFX certificates contains private keys and we import them with some other aproach
67
- import_certificates(fetch_cert_object(ext), (ext == ".pfx"))
98
+ action :create, description: "Creates or updates a certificate." do
99
+ ext = get_file_extension(new_resource.source)
100
+
101
+ # PFX certificates contains private keys and we import them with some other approach
102
+ # import_certificates(fetch_cert_object(ext), (ext == ".pfx"))
103
+ import_certificates(fetch_cert_object_from_file(ext), (ext == ".pfx"))
68
104
  end
69
105
 
70
106
  # acl_add is a modify-if-exists operation : not idempotent
71
- action :acl_add do
72
- description "Adds read-only entries to a certificate's private key ACL."
107
+ action :acl_add, description: "Adds read-only entries to a certificate's private key ACL." do
73
108
 
74
109
  if ::File.exist?(new_resource.source)
75
110
  hash = "$cert.GetCertHashString()"
@@ -77,15 +112,14 @@ class Chef
77
112
  guard_script = cert_script(false)
78
113
  else
79
114
  # make sure we have no spaces in the hash string
80
- hash = "\"#{new_resource.source.gsub(/\s/, '')}\""
115
+ hash = "\"#{new_resource.source.gsub(/\s/, "")}\""
81
116
  code_script = ""
82
117
  guard_script = ""
83
118
  end
84
119
  code_script << acl_script(hash)
85
120
  guard_script << cert_exists_script(hash)
86
121
 
87
- powershell_script "setting the acls on #{new_resource.source} in #{cert_location}\\#{new_resource.store_name}" do
88
- guard_interpreter :powershell_script
122
+ powershell_script "setting the acls on #{new_resource.source} in #{ps_cert_location}\\#{new_resource.store_name}" do
89
123
  convert_boolean_return true
90
124
  code code_script
91
125
  only_if guard_script
@@ -93,32 +127,47 @@ class Chef
93
127
  end
94
128
  end
95
129
 
96
- action :delete do
97
- description "Deletes a certificate."
98
- cert_obj = fetch_cert
99
- if cert_obj
130
+ action :delete, description: "Deletes a certificate." do
131
+ cert_is_valid = verify_cert
132
+
133
+ if cert_is_valid == true
100
134
  converge_by("Deleting certificate #{new_resource.source} from Store #{new_resource.store_name}") do
101
135
  delete_cert
102
136
  end
103
137
  else
104
- Chef::Log.debug("Certificate not found")
138
+ Chef::Log.debug("Certificate Not Found")
105
139
  end
106
140
  end
107
141
 
108
- action :fetch do
109
- description "Fetches a certificate."
142
+ action :fetch, description: "Fetches a certificate." do
143
+ unless new_resource.output_path
144
+ raise Chef::Exceptions::ResourceNotFound, "You must include an output_path parameter when calling the fetch action"
145
+ end
146
+
147
+ if ::File.extname(new_resource.output_path) == ".pfx"
148
+
149
+ validated_thumbprint = validate_thumbprint(new_resource.source)
150
+ if validated_thumbprint != false # is the thumbprint valid
151
+ cert_obj = powershell_exec!(pfx_ps_cmd(validate_thumbprint(new_resource.source), store_location: ps_cert_location, store_name: new_resource.store_name, output_path: new_resource.output_path, password: new_resource.pfx_password ))
152
+ else
153
+ message = "While fetching the certificate, was passed the following invalid certificate thumbprint : #{new_resource.source}\n"
154
+ raise Chef::Exceptions::InvalidKeyAttribute, message
155
+ end
110
156
 
111
- cert_obj = fetch_cert
112
- if cert_obj
113
- show_or_store_cert(cert_obj)
114
157
  else
115
- Chef::Log.debug("Certificate not found")
158
+ cert_obj = fetch_cert
116
159
  end
117
- end
118
160
 
119
- action :verify do
120
- description ""
161
+ if cert_obj != false && cert_obj != "Certificate Not Found"
162
+ converge_by("Fetching certificate #{new_resource.source} from Store \\#{ps_cert_location}\\#{new_resource.store_name}") do
163
+ export_cert(cert_obj, output_path: new_resource.output_path, store_name: new_resource.store_name , store_location: ps_cert_location, pfx_password: new_resource.pfx_password)
164
+ end
165
+ else
166
+ Chef::Log.debug("Certificate Not Found")
167
+ end
168
+ end
121
169
 
170
+ action :verify, description: "Verifies a certificate and logs the result." do
122
171
  out = verify_cert
123
172
  if !!out == out
124
173
  out = out ? "Certificate is valid" : "Certificate not valid"
@@ -127,81 +176,136 @@ class Chef
127
176
  end
128
177
 
129
178
  action_class do
179
+ @local_pfx_path = ""
180
+
181
+ CERT_SYSTEM_STORE_LOCAL_MACHINE = 0x00020000
182
+ CERT_SYSTEM_STORE_CURRENT_USER = 0x00010000
183
+
130
184
  def add_cert(cert_obj)
131
- store = ::Win32::Certstore.open(new_resource.store_name)
185
+ store = ::Win32::Certstore.open(new_resource.store_name, store_location: native_cert_location)
132
186
  store.add(cert_obj)
133
187
  end
134
188
 
135
- def add_pfx_cert
136
- store = ::Win32::Certstore.open(new_resource.store_name)
137
- store.add_pfx(new_resource.source, new_resource.pfx_password)
189
+ def add_pfx_cert(path)
190
+ exportable = new_resource.exportable ? 1 : 0
191
+ store = ::Win32::Certstore.open(new_resource.store_name, store_location: native_cert_location)
192
+ store.add_pfx(path, new_resource.pfx_password, exportable)
138
193
  end
139
194
 
140
195
  def delete_cert
141
- store = ::Win32::Certstore.open(new_resource.store_name)
142
- store.delete(new_resource.source)
196
+ store = ::Win32::Certstore.open(new_resource.store_name, store_location: native_cert_location)
197
+ store.delete(validate_thumbprint(new_resource.source))
143
198
  end
144
199
 
145
200
  def fetch_cert
146
- store = ::Win32::Certstore.open(new_resource.store_name)
147
- store.get(new_resource.source)
201
+ store = ::Win32::Certstore.open(new_resource.store_name, store_location: native_cert_location)
202
+ if new_resource.output_path && ::File.extname(new_resource.output_path) == ".key"
203
+ fetch_key
204
+
205
+ else
206
+ store.get(validate_thumbprint(new_resource.source))
207
+ end
148
208
  end
149
209
 
150
- # Checks whether a certificate with the given thumbprint
151
- # is already present and valid in certificate store
152
- # If the certificate is not present, verify_cert returns a String: "Certificate not found"
153
- # But if it is present but expired, it returns a Boolean: false
154
- # Otherwise, it returns a Boolean: true
155
- def verify_cert(thumbprint = new_resource.source)
156
- store = ::Win32::Certstore.open(new_resource.store_name)
157
- store.valid?(thumbprint)
210
+ def fetch_key
211
+ require "openssl" unless defined?(OpenSSL)
212
+ file_name = ::File.basename(new_resource.output_path, ::File.extname(new_resource.output_path))
213
+ pfx_file = file_name + ".pfx"
214
+ new_pfx_output_path = ::File.join(Chef::FileCache.create_cache_path("pfx_files"), pfx_file)
215
+ powershell_exec(pfx_ps_cmd(validate_thumbprint(new_resource.source), store_location: ps_cert_location, store_name: new_resource.store_name, output_path: new_pfx_output_path, password: new_resource.pfx_password ))
216
+ pkcs12 = OpenSSL::PKCS12.new(::File.binread(new_pfx_output_path), new_resource.pfx_password)
217
+ f = ::File.open(new_resource.output_path, "w")
218
+ f.write(pkcs12.key.to_s)
219
+ f.flush
220
+ f.close
158
221
  end
159
222
 
160
- def show_or_store_cert(cert_obj)
161
- if new_resource.cert_path
162
- export_cert(cert_obj, new_resource.cert_path)
163
- if ::File.size(new_resource.cert_path) > 0
164
- Chef::Log.info("Certificate export in #{new_resource.cert_path}")
165
- else
166
- ::File.delete(new_resource.cert_path)
167
- end
168
- else
169
- Chef::Log.info(cert_obj.display)
223
+ def get_file_extension(file_name)
224
+ if is_file?(file_name)
225
+ ::File.extname(file_name)
226
+ elsif is_url?(file_name)
227
+ require "open-uri" unless defined?(OpenURI)
228
+ uri = URI.parse(file_name)
229
+ output_file = ::File.basename(uri.path)
230
+ ::File.extname(output_file)
170
231
  end
171
232
  end
172
233
 
173
- def export_cert(cert_obj, cert_path)
174
- out_file = ::File.new(cert_path, "w+")
175
- case ::File.extname(cert_path)
176
- when ".pem"
177
- out_file.puts(cert_obj.to_pem)
178
- when ".der"
179
- out_file.puts(cert_obj.to_der)
180
- when ".cer"
181
- cert_out = powershell_out("openssl x509 -text -inform DER -in #{cert_obj.to_pem} -outform CER").stdout
182
- out_file.puts(cert_out)
183
- when ".crt"
184
- cert_out = powershell_out("openssl x509 -text -inform DER -in #{cert_obj.to_pem} -outform CRT").stdout
185
- out_file.puts(cert_out)
186
- when ".pfx"
187
- cert_out = powershell_out("openssl pkcs12 -export -nokeys -in #{cert_obj.to_pem} -outform PFX").stdout
188
- out_file.puts(cert_out)
189
- when ".p7b"
190
- cert_out = powershell_out("openssl pkcs7 -export -nokeys -in #{cert_obj.to_pem} -outform P7B").stdout
191
- out_file.puts(cert_out)
234
+ def get_file_name(path_name)
235
+ if is_file?(path_name)
236
+ ::File.extname(path_name)
237
+ elsif is_url?(path_name)
238
+ require "open-uri" unless defined?(OpenURI)
239
+ uri = URI.parse(path_name)
240
+ ::File.basename(uri.path)
241
+ end
242
+ end
243
+
244
+ def is_url?(source)
245
+ require "uri" unless defined?(URI)
246
+ uri = URI.parse(source)
247
+ uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
248
+ end
249
+
250
+ def is_file?(source)
251
+ ::File.file?(source)
252
+ end
253
+
254
+ # Thumbprints should be exactly 40 Hex characters
255
+ def valid_thumbprint?(string)
256
+ string.match?(/[0-9A-Fa-f]/) && string.length == 40
257
+ end
258
+
259
+ def get_thumbprint(store_name, location, source)
260
+ <<-GETTHUMBPRINTCODE
261
+ $content = Get-ChildItem -Path Cert:\\#{location}\\#{store_name} | Where-Object {$_.Subject -Match "#{source}"} | Select-Object Thumbprint
262
+ $content.thumbprint
263
+ GETTHUMBPRINTCODE
264
+ end
265
+
266
+ def validate_thumbprint(thumbprint)
267
+ # valid_thumbprint can return false under at least 2 conditions:
268
+ # one is that the thumbprint is in fact busted
269
+ # the second is that the thumbprint is valid but belongs to an expired certificate already installed
270
+ results = valid_thumbprint?(thumbprint)
271
+ results == true ? thumbprint : false
272
+ end
273
+
274
+ # Checks to make sure whether the cert is found or not
275
+ # if it IS found, is it still valid - has it expired?
276
+ def verify_cert(thumbprint = new_resource.source)
277
+ store = ::Win32::Certstore.open(new_resource.store_name, store_location: native_cert_location)
278
+ validated_thumbprint = validate_thumbprint(thumbprint)
279
+ if validated_thumbprint != false
280
+ result = store.valid?(thumbprint)
281
+ result == ( "Certificate Not Found" || "Certificate Has Expired" ) ? false : true
192
282
  else
193
- Chef::Log.info("Supported certificate format .pem, .der, .cer, .crt, .pfx and .p7b")
283
+ message = "While verifying the certificate, was passed the following invalid certificate thumbprint : #{thumbprint}\n"
284
+ raise Chef::Exceptions::InvalidKeyAttribute, message
194
285
  end
195
- out_file.close
196
286
  end
197
287
 
198
- def cert_location
199
- @location ||= new_resource.user_store ? "CurrentUser" : "LocalMachine"
288
+ # this structure is solving 2 problems. The first is that we need to have support for both the CurrentUser AND LocalMachine stores
289
+ # Secondly, we need to pass the proper constant name for each store to win32-certstore but also pass the short name to powershell scripts used here
290
+ def ps_cert_location
291
+ new_resource.user_store ? "CurrentUser" : "LocalMachine"
292
+ end
293
+
294
+ def pfx_ps_cmd(thumbprint, store_location: "LocalMachine", store_name: "My", output_path:, password: )
295
+ <<-CMD
296
+ $my_pwd = ConvertTo-SecureString -String "#{password}" -Force -AsPlainText
297
+ $cert = Get-ChildItem -path cert:\\#{store_location}\\#{store_name} -Recurse | Where { $_.Thumbprint -eq "#{thumbprint.upcase}" }
298
+ Export-PfxCertificate -Cert $cert -FilePath "#{output_path}" -Password $my_pwd
299
+ CMD
300
+ end
301
+
302
+ def native_cert_location
303
+ new_resource.user_store ? CERT_SYSTEM_STORE_CURRENT_USER : CERT_SYSTEM_STORE_LOCAL_MACHINE
200
304
  end
201
305
 
202
306
  def cert_script(persist)
203
307
  cert_script = "$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2"
204
- file = Chef::Util::PathHelper.cleanpath(new_resource.source)
308
+ file = Chef::Util::PathHelper.cleanpath(new_resource.source, ps_cert_location)
205
309
  cert_script << " \"#{file}\""
206
310
  if ::File.extname(file.downcase) == ".pfx"
207
311
  cert_script << ", \"#{new_resource.pfx_password}\""
@@ -217,18 +321,18 @@ class Chef
217
321
  def cert_exists_script(hash)
218
322
  <<-EOH
219
323
  $hash = #{hash}
220
- Test-Path "Cert:\\#{cert_location}\\#{new_resource.store_name}\\$hash"
221
- EOH
324
+ Test-Path "Cert:\\#{ps_cert_location}\\#{new_resource.store_name}\\$hash"
325
+ EOH
222
326
  end
223
327
 
224
328
  def within_store_script
225
329
  inner_script = yield "$store"
226
330
  <<-EOH
227
- $store = New-Object System.Security.Cryptography.X509Certificates.X509Store "#{new_resource.store_name}", ([System.Security.Cryptography.X509Certificates.StoreLocation]::#{cert_location})
331
+ $store = New-Object System.Security.Cryptography.X509Certificates.X509Store "#{new_resource.store_name}", ([System.Security.Cryptography.X509Certificates.StoreLocation]::#{ps_cert_location})
228
332
  $store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadWrite)
229
333
  #{inner_script}
230
334
  $store.Close()
231
- EOH
335
+ EOH
232
336
  end
233
337
 
234
338
  def acl_script(hash)
@@ -238,7 +342,7 @@ class Chef
238
342
  # and from https://msdn.microsoft.com/en-us/library/windows/desktop/bb204778(v=vs.85).aspx
239
343
  set_acl_script = <<-EOH
240
344
  $hash = #{hash}
241
- $storeCert = Get-ChildItem "cert:\\#{cert_location}\\#{new_resource.store_name}\\$hash"
345
+ $storeCert = Get-ChildItem "cert:\\#{ps_cert_location}\\#{new_resource.store_name}\\$hash"
242
346
  if ($storeCert -eq $null) { throw 'no key exists.' }
243
347
  $keyname = $storeCert.PrivateKey.CspKeyContainerInfo.UniqueKeyContainerName
244
348
  if ($keyname -eq $null) { throw 'no private key exists.' }
@@ -252,7 +356,7 @@ class Chef
252
356
  $userSID = $currentUser.Translate([System.Security.Principal.SecurityIdentifier]).Value
253
357
  $fullpath = "$Env:ProgramData\\Microsoft\\Crypto\\RSA\\$userSID\\$keyname"
254
358
  }
255
- EOH
359
+ EOH
256
360
  new_resource.private_key_acl.each do |name|
257
361
  set_acl_script << "$uname='#{name}'; icacls $fullpath /grant $uname`:RX\n"
258
362
  end
@@ -273,12 +377,50 @@ class Chef
273
377
  #
274
378
  # @raise [OpenSSL::PKCS12::PKCS12Error] When incorrect password is provided for PFX certificate
275
379
  #
276
- def fetch_cert_object(ext)
277
- contents = if binary_cert?
278
- ::File.binread(new_resource.source)
279
- else
280
- ::File.read(new_resource.source)
281
- end
380
+
381
+ def fetch_cert_object_from_file(ext)
382
+ if is_file?(new_resource.source)
383
+ begin
384
+ ::File.exist?(new_resource.source)
385
+ contents = ::File.binread(new_resource.source)
386
+ rescue => exception
387
+ message = "Unable to load the certificate object from the specified local path : #{new_resource.source}\n"
388
+ message << exception.message
389
+ raise Chef::Exceptions::FileNotFound, message
390
+ end
391
+ elsif is_url?(new_resource.source)
392
+ require "uri" unless defined?(URI)
393
+ uri = URI(new_resource.source)
394
+ state = uri.is_a?(URI::HTTP) && !uri.host.nil? ? true : false
395
+ if state
396
+ begin
397
+ output_file_name = get_file_name(new_resource.source)
398
+ unless Dir.exist?(Chef::Config[:file_cache_path])
399
+ Dir.mkdir(Chef::Config[:file_cache_path])
400
+ end
401
+ local_path = ::File.join(Chef::Config[:file_cache_path], output_file_name)
402
+ @local_pfx_path = local_path
403
+ ::File.open(local_path, "wb") do |file|
404
+ file.write URI.open(new_resource.source).read
405
+ end
406
+ rescue => exception
407
+ message = "Not Able to Download Certificate Object at the URL specified : #{new_resource.source}\n"
408
+ message << exception.message
409
+ raise Chef::Exceptions::FileNotFound, message
410
+ end
411
+
412
+ contents = ::File.binread(local_path)
413
+
414
+ else
415
+ message = "Not Able to Download Certificate Object at the URL specified : #{new_resource.source}\n"
416
+ message << exception.message
417
+ raise Chef::Exceptions::InvalidRemoteFileURI, message
418
+ end
419
+ else
420
+ message = "You passed an invalid file or url to import. Please check the spelling and try again."
421
+ message << exception.message
422
+ raise Chef::Exceptions::ArgumentError, message
423
+ end
282
424
 
283
425
  case ext
284
426
  when ".pfx"
@@ -295,10 +437,55 @@ class Chef
295
437
  end
296
438
  end
297
439
 
298
- # @return [Boolean] Whether the certificate file is binary encoded or not
299
- #
300
- def binary_cert?
301
- powershell_out!("file -b --mime-encoding #{new_resource.source}").stdout.strip == "binary"
440
+ def export_cert(cert_obj, output_path:, store_name:, store_location:, pfx_password:)
441
+ # Delete the cert if it exists on disk already.
442
+ # We want to ensure we're not randomly loading an old stinky cert.
443
+ if ::File.exists?(output_path)
444
+ ::File.delete(output_path)
445
+ end
446
+
447
+ unless ::File.directory?(::File.dirname(output_path))
448
+ FileUtils.mkdir_p(::File.dirname(output_path))
449
+ end
450
+
451
+ out_file = ::File.new(output_path, "w+")
452
+
453
+ case ::File.extname(output_path)
454
+ when ".pem"
455
+ out_file.puts(cert_obj)
456
+ when ".der"
457
+ out_file.puts(cert_obj.to_der)
458
+ when ".cer"
459
+ cert_out = shell_out("openssl x509 -text -inform DER -in #{cert_obj.to_pem} -outform CER").stdout
460
+ out_file.puts(cert_out)
461
+ when ".crt"
462
+ cert_out = shell_out("openssl x509 -text -inform DER -in #{cert_obj} -outform CRT").stdout
463
+ out_file.puts(cert_out)
464
+ when ".pfx"
465
+ validated_thumbprint = validate_thumbprint(new_resource.source)
466
+ if validated_thumbprint != false # is the thumbprint valid
467
+ store = ::Win32::Certstore.open(new_resource.store_name, store_location: native_cert_location)
468
+ result = store.valid?(new_resource.source) # is there a cert in the store matching that thumbprint
469
+ temp = result == ( "Certificate Not Found" || "Certificate Has Expired" ) ? false : true
470
+ if temp == true
471
+ pfx_ps_cmd(validate_thumbprint(new_resource.source), store_location: store_location, store_name: store_name, output_path: output_path, password: pfx_password )
472
+ else
473
+ Chef::Log.debug("The requested certificate is not found or has expired")
474
+ end
475
+ else
476
+ message = "While exporting the pfx, was passed the following invalid certificate thumbprint : #{new_resource.source}\n"
477
+ raise Chef::Exceptions::InvalidKeyAttribute, message
478
+ end
479
+ when ".p7b"
480
+ cert_out = shell_out("openssl pkcs7 -export -nokeys -in #{cert_obj.to_pem} -outform P7B").stdout
481
+ out_file.puts(cert_out)
482
+ when ".key"
483
+ out_file.puts(cert_obj)
484
+ else
485
+ Chef::Log.info("Supported certificate format .pem, .der, .cer, .crt, and .p7b")
486
+ end
487
+
488
+ out_file.close
302
489
  end
303
490
 
304
491
  # Imports the certificate object into cert store
@@ -307,22 +494,34 @@ class Chef
307
494
  #
308
495
  # @param is_pfx [Boolean] true if we want to import a PFX certificate
309
496
  #
310
- def import_certificates(cert_objs, is_pfx)
497
+ def import_certificates(cert_objs, is_pfx, store_name: new_resource.store_name, store_location: native_cert_location)
311
498
  [cert_objs].flatten.each do |cert_obj|
312
- thumbprint = OpenSSL::Digest::SHA1.new(cert_obj.to_der).to_s # Fetch its thumbprint
313
-
314
- # Need to check if return value is Boolean:true
315
- # If not then the given certificate should be added in certstore
499
+ thumbprint = OpenSSL::Digest.new("SHA1", cert_obj.to_der).to_s
316
500
  if verify_cert(thumbprint) == true
317
501
  Chef::Log.debug("Certificate is already present")
318
- else
319
- converge_by("Adding certificate #{new_resource.source} into Store #{new_resource.store_name}") do
320
- if is_pfx
321
- add_pfx_cert
502
+ elsif verify_cert(thumbprint) == false # Not found already in the CertStore
503
+ if is_pfx
504
+ if is_file?(new_resource.source)
505
+ converge_by("Creating a PFX #{new_resource.source} for Store #{new_resource.store_name}") do
506
+ add_pfx_cert(new_resource.source)
507
+ end
508
+ elsif is_url?(new_resource.source)
509
+ converge_by("Creating a PFX #{@local_pfx_path} for Store #{new_resource.store_name}") do
510
+ add_pfx_cert(@local_pfx_path)
511
+ end
322
512
  else
513
+ message = "You passed an invalid file or url to import. Please check the spelling and try again."
514
+ message << exception.message
515
+ raise Chef::Exceptions::ArgumentError, message
516
+ end
517
+ else
518
+ converge_by("Creating a certificate #{new_resource.source} for Store #{new_resource.store_name}") do
323
519
  add_cert(cert_obj)
324
520
  end
325
521
  end
522
+ else
523
+ message = "Certificate could not be imported"
524
+ raise Chef::Exceptions::CertificateNotImportable, message
326
525
  end
327
526
  end
328
527
  end