chef 12.4.0.rc.0-universal-mingw32 → 12.4.0.rc.2-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (298) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +12 -1
  3. data/lib/chef/api_client.rb +130 -26
  4. data/lib/chef/application.rb +0 -1
  5. data/lib/chef/application/client.rb +8 -19
  6. data/lib/chef/audit/audit_reporter.rb +12 -7
  7. data/lib/chef/audit/logger.rb +36 -0
  8. data/lib/chef/audit/runner.rb +4 -2
  9. data/lib/chef/chef_class.rb +62 -11
  10. data/lib/chef/client.rb +587 -207
  11. data/lib/chef/config.rb +0 -1
  12. data/lib/chef/dsl/recipe.rb +45 -56
  13. data/lib/chef/dsl/resources.rb +3 -2
  14. data/lib/chef/event_dispatch/base.rb +7 -2
  15. data/lib/chef/exceptions.rb +4 -1
  16. data/lib/chef/file_content_management/deploy/mv_windows.rb +16 -6
  17. data/lib/chef/formatters/doc.rb +15 -7
  18. data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +10 -7
  19. data/lib/chef/guard_interpreter/default_guard_interpreter.rb +2 -0
  20. data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +4 -1
  21. data/lib/chef/http/authenticator.rb +7 -2
  22. data/lib/chef/knife.rb +16 -4
  23. data/lib/chef/knife/client_create.rb +55 -31
  24. data/lib/chef/knife/core/generic_presenter.rb +1 -1
  25. data/lib/chef/knife/core/subcommand_loader.rb +1 -1
  26. data/lib/chef/knife/osc_user_create.rb +97 -0
  27. data/lib/chef/knife/osc_user_delete.rb +51 -0
  28. data/lib/chef/knife/osc_user_edit.rb +58 -0
  29. data/lib/chef/knife/osc_user_list.rb +47 -0
  30. data/lib/chef/knife/osc_user_reregister.rb +64 -0
  31. data/lib/chef/knife/osc_user_show.rb +54 -0
  32. data/lib/chef/knife/user_create.rb +95 -36
  33. data/lib/chef/knife/user_delete.rb +52 -2
  34. data/lib/chef/knife/user_edit.rb +37 -7
  35. data/lib/chef/knife/user_list.rb +3 -0
  36. data/lib/chef/knife/user_reregister.rb +39 -8
  37. data/lib/chef/knife/user_show.rb +30 -1
  38. data/lib/chef/mixin/api_version_request_handling.rb +66 -0
  39. data/lib/chef/mixin/convert_to_class_name.rb +10 -4
  40. data/lib/chef/mixin/deprecation.rb +24 -0
  41. data/lib/chef/mixin/powershell_out.rb +98 -0
  42. data/lib/chef/mixin/provides.rb +5 -18
  43. data/lib/chef/mixin/uris.rb +11 -0
  44. data/lib/chef/mixin/windows_architecture_helper.rb +5 -2
  45. data/lib/chef/mixin/windows_env_helper.rb +11 -2
  46. data/lib/chef/node_map.rb +130 -75
  47. data/lib/chef/osc_user.rb +194 -0
  48. data/lib/chef/platform/provider_mapping.rb +2 -269
  49. data/lib/chef/platform/provider_priority_map.rb +6 -69
  50. data/lib/chef/platform/query_helpers.rb +5 -0
  51. data/lib/chef/platform/resource_priority_map.rb +12 -15
  52. data/lib/chef/policy_builder/policyfile.rb +1 -0
  53. data/lib/chef/provider.rb +19 -0
  54. data/lib/chef/provider/directory.rb +3 -0
  55. data/lib/chef/provider/dsc_resource.rb +8 -1
  56. data/lib/chef/provider/file.rb +1 -0
  57. data/lib/chef/provider/group/aix.rb +1 -0
  58. data/lib/chef/provider/group/dscl.rb +1 -1
  59. data/lib/chef/provider/group/gpasswd.rb +1 -0
  60. data/lib/chef/provider/group/groupmod.rb +1 -1
  61. data/lib/chef/provider/group/pw.rb +1 -0
  62. data/lib/chef/provider/group/suse.rb +2 -0
  63. data/lib/chef/provider/group/usermod.rb +2 -1
  64. data/lib/chef/provider/group/windows.rb +1 -1
  65. data/lib/chef/provider/ifconfig.rb +2 -0
  66. data/lib/chef/provider/ifconfig/aix.rb +1 -0
  67. data/lib/chef/provider/ifconfig/debian.rb +2 -0
  68. data/lib/chef/provider/ifconfig/redhat.rb +1 -0
  69. data/lib/chef/provider/lwrp_base.rb +4 -0
  70. data/lib/chef/provider/mount.rb +0 -1
  71. data/lib/chef/provider/mount/aix.rb +1 -0
  72. data/lib/chef/provider/mount/mount.rb +2 -0
  73. data/lib/chef/provider/mount/solaris.rb +2 -0
  74. data/lib/chef/provider/package.rb +55 -0
  75. data/lib/chef/provider/package/aix.rb +7 -7
  76. data/lib/chef/provider/package/apt.rb +3 -3
  77. data/lib/chef/provider/package/dpkg.rb +4 -4
  78. data/lib/chef/provider/package/easy_install.rb +5 -5
  79. data/lib/chef/provider/package/freebsd/base.rb +2 -2
  80. data/lib/chef/provider/package/freebsd/pkg.rb +6 -6
  81. data/lib/chef/provider/package/freebsd/pkgng.rb +5 -5
  82. data/lib/chef/provider/package/freebsd/port.rb +4 -4
  83. data/lib/chef/provider/package/homebrew.rb +2 -2
  84. data/lib/chef/provider/package/ips.rb +4 -4
  85. data/lib/chef/provider/package/macports.rb +5 -6
  86. data/lib/chef/provider/package/openbsd.rb +4 -5
  87. data/lib/chef/provider/package/pacman.rb +4 -4
  88. data/lib/chef/provider/package/portage.rb +2 -0
  89. data/lib/chef/provider/package/rpm.rb +7 -8
  90. data/lib/chef/provider/package/rubygems.rb +5 -12
  91. data/lib/chef/provider/package/smartos.rb +4 -4
  92. data/lib/chef/provider/package/solaris.rb +7 -7
  93. data/lib/chef/provider/package/windows/msi.rb +1 -1
  94. data/lib/chef/provider/package/yum.rb +4 -6
  95. data/lib/chef/provider/package/zypper.rb +16 -14
  96. data/lib/chef/provider/powershell_script.rb +129 -47
  97. data/lib/chef/provider/remote_file/content.rb +4 -1
  98. data/lib/chef/provider/remote_file/local_file.rb +10 -4
  99. data/lib/chef/provider/service.rb +44 -0
  100. data/lib/chef/provider/service/freebsd.rb +1 -1
  101. data/lib/chef/provider/service/init.rb +1 -0
  102. data/lib/chef/provider/service/macosx.rb +1 -1
  103. data/lib/chef/provider/service/windows.rb +0 -1
  104. data/lib/chef/provider/user.rb +1 -1
  105. data/lib/chef/provider/user/aix.rb +3 -2
  106. data/lib/chef/provider/user/pw.rb +1 -0
  107. data/lib/chef/provider/user/solaris.rb +2 -0
  108. data/lib/chef/provider/user/useradd.rb +1 -0
  109. data/lib/chef/provider_resolver.rb +87 -134
  110. data/lib/chef/resource.rb +274 -68
  111. data/lib/chef/resource/apt_package.rb +0 -2
  112. data/lib/chef/resource/bash.rb +0 -2
  113. data/lib/chef/resource/batch.rb +1 -1
  114. data/lib/chef/resource/bff_package.rb +0 -7
  115. data/lib/chef/resource/breakpoint.rb +3 -6
  116. data/lib/chef/resource/chef_gem.rb +0 -3
  117. data/lib/chef/resource/cookbook_file.rb +1 -3
  118. data/lib/chef/resource/cron.rb +2 -4
  119. data/lib/chef/resource/csh.rb +0 -2
  120. data/lib/chef/resource/deploy.rb +9 -6
  121. data/lib/chef/resource/deploy_revision.rb +0 -14
  122. data/lib/chef/resource/directory.rb +2 -4
  123. data/lib/chef/resource/dpkg_package.rb +0 -5
  124. data/lib/chef/resource/dsc_resource.rb +2 -3
  125. data/lib/chef/resource/dsc_script.rb +2 -3
  126. data/lib/chef/resource/easy_install_package.rb +0 -7
  127. data/lib/chef/resource/env.rb +3 -3
  128. data/lib/chef/resource/erl_call.rb +2 -5
  129. data/lib/chef/resource/execute.rb +2 -4
  130. data/lib/chef/resource/file.rb +2 -4
  131. data/lib/chef/resource/freebsd_package.rb +0 -5
  132. data/lib/chef/resource/gem_package.rb +0 -3
  133. data/lib/chef/resource/git.rb +0 -3
  134. data/lib/chef/resource/group.rb +2 -4
  135. data/lib/chef/resource/homebrew_package.rb +0 -2
  136. data/lib/chef/resource/http_request.rb +3 -4
  137. data/lib/chef/resource/ifconfig.rb +3 -4
  138. data/lib/chef/resource/ips_package.rb +2 -2
  139. data/lib/chef/resource/link.rb +3 -5
  140. data/lib/chef/resource/log.rb +2 -4
  141. data/lib/chef/resource/lwrp_base.rb +10 -61
  142. data/lib/chef/resource/macosx_service.rb +1 -2
  143. data/lib/chef/resource/macports_package.rb +0 -7
  144. data/lib/chef/resource/mdadm.rb +2 -5
  145. data/lib/chef/resource/mount.rb +2 -4
  146. data/lib/chef/resource/ohai.rb +2 -4
  147. data/lib/chef/resource/openbsd_package.rb +0 -6
  148. data/lib/chef/resource/package.rb +9 -6
  149. data/lib/chef/resource/pacman_package.rb +0 -7
  150. data/lib/chef/resource/paludis_package.rb +2 -3
  151. data/lib/chef/resource/perl.rb +0 -3
  152. data/lib/chef/resource/portage_package.rb +0 -3
  153. data/lib/chef/resource/powershell_script.rb +1 -2
  154. data/lib/chef/resource/python.rb +0 -3
  155. data/lib/chef/resource/reboot.rb +1 -3
  156. data/lib/chef/resource/registry_key.rb +3 -5
  157. data/lib/chef/resource/remote_directory.rb +3 -5
  158. data/lib/chef/resource/remote_file.rb +4 -5
  159. data/lib/chef/resource/route.rb +3 -5
  160. data/lib/chef/resource/rpm_package.rb +0 -2
  161. data/lib/chef/resource/ruby.rb +0 -4
  162. data/lib/chef/resource/ruby_block.rb +2 -4
  163. data/lib/chef/resource/scm.rb +3 -5
  164. data/lib/chef/resource/script.rb +0 -3
  165. data/lib/chef/resource/service.rb +3 -5
  166. data/lib/chef/resource/smartos_package.rb +0 -9
  167. data/lib/chef/resource/solaris_package.rb +0 -10
  168. data/lib/chef/resource/subversion.rb +1 -3
  169. data/lib/chef/resource/template.rb +0 -4
  170. data/lib/chef/resource/timestamped_deploy.rb +0 -4
  171. data/lib/chef/resource/user.rb +2 -5
  172. data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -7
  173. data/lib/chef/resource/windows_package.rb +3 -3
  174. data/lib/chef/resource/windows_script.rb +2 -2
  175. data/lib/chef/resource/windows_service.rb +3 -3
  176. data/lib/chef/resource/yum_package.rb +0 -3
  177. data/lib/chef/resource/zypper_package.rb +27 -0
  178. data/lib/chef/resource_builder.rb +7 -0
  179. data/lib/chef/resource_reporter.rb +1 -1
  180. data/lib/chef/resource_resolver.rb +108 -62
  181. data/lib/chef/resources.rb +1 -0
  182. data/lib/chef/rest.rb +1 -0
  183. data/lib/chef/server_api.rb +2 -0
  184. data/lib/chef/user.rb +193 -42
  185. data/lib/chef/util/backup.rb +9 -1
  186. data/lib/chef/util/path_helper.rb +0 -1
  187. data/lib/chef/version.rb +1 -1
  188. data/spec/functional/audit/runner_spec.rb +22 -42
  189. data/spec/functional/mixin/powershell_out_spec.rb +43 -0
  190. data/spec/functional/resource/execute_spec.rb +9 -2
  191. data/spec/functional/resource/file_spec.rb +25 -0
  192. data/spec/functional/resource/group_spec.rb +5 -0
  193. data/spec/functional/resource/link_spec.rb +5 -11
  194. data/spec/functional/resource/powershell_spec.rb +40 -5
  195. data/spec/functional/resource/user/useradd_spec.rb +10 -18
  196. data/spec/integration/recipes/lwrp_spec.rb +57 -0
  197. data/spec/integration/recipes/provider_choice.rb +2 -7
  198. data/spec/integration/recipes/recipe_dsl_spec.rb +517 -19
  199. data/spec/spec_helper.rb +1 -1
  200. data/spec/support/lib/chef/provider/openldap_includer.rb +29 -0
  201. data/spec/support/lib/chef/resource/cat.rb +0 -2
  202. data/spec/support/lib/chef/resource/one_two_three_four.rb +0 -6
  203. data/spec/support/lib/chef/resource/openldap_includer.rb +27 -0
  204. data/spec/support/lib/chef/resource/with_state.rb +0 -9
  205. data/spec/support/lib/chef/resource/zen_follower.rb +0 -6
  206. data/spec/support/lib/chef/resource/zen_master.rb +1 -6
  207. data/spec/support/shared/context/client.rb +277 -0
  208. data/spec/support/shared/examples/client.rb +53 -0
  209. data/spec/support/shared/functional/file_resource.rb +0 -4
  210. data/spec/support/shared/functional/securable_resource.rb +0 -24
  211. data/spec/support/shared/functional/securable_resource_with_reporting.rb +4 -4
  212. data/spec/support/shared/functional/windows_script.rb +1 -1
  213. data/spec/support/shared/unit/api_versioning.rb +77 -0
  214. data/spec/support/shared/unit/knife_shared.rb +40 -0
  215. data/spec/support/shared/unit/user_and_client_shared.rb +115 -0
  216. data/spec/unit/api_client_spec.rb +189 -14
  217. data/spec/unit/application/client_spec.rb +0 -5
  218. data/spec/unit/audit/audit_reporter_spec.rb +58 -14
  219. data/spec/unit/audit/logger_spec.rb +42 -0
  220. data/spec/unit/audit/runner_spec.rb +2 -2
  221. data/spec/unit/chef_fs/file_pattern_spec.rb +3 -15
  222. data/spec/unit/client_spec.rb +58 -374
  223. data/spec/unit/cookbook_spec.rb +0 -9
  224. data/spec/unit/cookbook_version_spec.rb +0 -20
  225. data/spec/unit/deprecation_spec.rb +55 -0
  226. data/spec/unit/dsl/resources_spec.rb +85 -0
  227. data/spec/unit/exceptions_spec.rb +2 -2
  228. data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +60 -0
  229. data/spec/unit/formatters/doc_spec.rb +46 -0
  230. data/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +12 -10
  231. data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +8 -0
  232. data/spec/unit/http/authenticator_spec.rb +11 -2
  233. data/spec/unit/knife/client_create_spec.rb +122 -51
  234. data/spec/unit/knife/core/subcommand_loader_spec.rb +19 -3
  235. data/spec/unit/knife/core/ui_spec.rb +14 -0
  236. data/spec/unit/knife/osc_user_create_spec.rb +93 -0
  237. data/spec/unit/knife/osc_user_delete_spec.rb +44 -0
  238. data/spec/unit/knife/osc_user_edit_spec.rb +52 -0
  239. data/spec/unit/knife/osc_user_list_spec.rb +37 -0
  240. data/spec/unit/knife/osc_user_reregister_spec.rb +58 -0
  241. data/spec/unit/knife/osc_user_show_spec.rb +46 -0
  242. data/spec/unit/knife/user_create_spec.rb +177 -51
  243. data/spec/unit/knife/user_delete_spec.rb +34 -8
  244. data/spec/unit/knife/user_edit_spec.rb +31 -12
  245. data/spec/unit/knife/user_list_spec.rb +7 -3
  246. data/spec/unit/knife/user_reregister_spec.rb +38 -17
  247. data/spec/unit/knife/user_show_spec.rb +35 -11
  248. data/spec/unit/knife_spec.rb +10 -4
  249. data/spec/unit/lwrp_spec.rb +228 -54
  250. data/spec/unit/mixin/api_version_request_handling_spec.rb +127 -0
  251. data/spec/unit/mixin/command_spec.rb +1 -2
  252. data/spec/unit/mixin/powershell_out_spec.rb +70 -0
  253. data/spec/unit/mixin/uris_spec.rb +23 -11
  254. data/spec/unit/node_map_spec.rb +4 -1
  255. data/spec/unit/osc_user_spec.rb +276 -0
  256. data/spec/unit/platform_spec.rb +0 -60
  257. data/spec/unit/provider/deploy_spec.rb +1 -1
  258. data/spec/unit/provider/directory_spec.rb +199 -135
  259. data/spec/unit/provider/ifconfig/debian_spec.rb +0 -10
  260. data/spec/unit/provider/package/aix_spec.rb +16 -16
  261. data/spec/unit/provider/package/dpkg_spec.rb +2 -2
  262. data/spec/unit/provider/package/freebsd/pkg_spec.rb +13 -13
  263. data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
  264. data/spec/unit/provider/package/freebsd/port_spec.rb +7 -7
  265. data/spec/unit/provider/package/ips_spec.rb +22 -22
  266. data/spec/unit/provider/package/macports_spec.rb +10 -10
  267. data/spec/unit/provider/package/openbsd_spec.rb +4 -26
  268. data/spec/unit/provider/package/pacman_spec.rb +5 -5
  269. data/spec/unit/provider/package/rpm_spec.rb +14 -14
  270. data/spec/unit/provider/package/rubygems_spec.rb +10 -44
  271. data/spec/unit/provider/package/smartos_spec.rb +4 -4
  272. data/spec/unit/provider/package/solaris_spec.rb +11 -11
  273. data/spec/unit/provider/package/zypper_spec.rb +125 -90
  274. data/spec/unit/provider/package_spec.rb +34 -0
  275. data/spec/unit/provider/powershell_spec.rb +53 -11
  276. data/spec/unit/provider/remote_directory_spec.rb +2 -2
  277. data/spec/unit/provider/remote_file/local_file_spec.rb +25 -6
  278. data/spec/unit/provider/service/freebsd_service_spec.rb +0 -12
  279. data/spec/unit/provider/user_spec.rb +3 -3
  280. data/spec/unit/provider_resolver_spec.rb +463 -327
  281. data/spec/unit/recipe_spec.rb +42 -15
  282. data/spec/unit/resource/breakpoint_spec.rb +1 -1
  283. data/spec/unit/resource/erl_call_spec.rb +1 -1
  284. data/spec/unit/resource/file_spec.rb +1 -1
  285. data/spec/unit/resource/ifconfig_spec.rb +10 -6
  286. data/spec/unit/resource/remote_file_spec.rb +5 -0
  287. data/spec/unit/resource/route_spec.rb +1 -1
  288. data/spec/unit/resource/ruby_block_spec.rb +2 -2
  289. data/spec/unit/resource/template_spec.rb +1 -1
  290. data/spec/unit/resource/timestamped_deploy_spec.rb +1 -2
  291. data/spec/unit/resource/windows_service_spec.rb +1 -1
  292. data/spec/unit/resource_spec.rb +99 -13
  293. data/spec/unit/rest_spec.rb +5 -5
  294. data/spec/unit/run_context_spec.rb +41 -0
  295. data/spec/unit/runner_spec.rb +2 -2
  296. data/spec/unit/user_spec.rb +406 -93
  297. data/tasks/maintainers.rb +69 -0
  298. metadata +37 -4
@@ -25,26 +25,45 @@ describe Chef::Provider::RemoteFile::LocalFile do
25
25
  let(:new_resource) { Chef::Resource::RemoteFile.new("local file backend test (new_resource)") }
26
26
  let(:current_resource) { Chef::Resource::RemoteFile.new("local file backend test (current_resource)") }
27
27
  subject(:fetcher) { Chef::Provider::RemoteFile::LocalFile.new(uri, new_resource, current_resource) }
28
-
29
- context "when parsing source path" do
28
+
29
+ context "when parsing source path on windows" do
30
+
31
+ before do
32
+ allow(Chef::Platform).to receive(:windows?).and_return(true)
33
+ end
34
+
30
35
  describe "when given local unix path" do
31
36
  let(:uri) { URI.parse("file:///nyan_cat.png") }
32
37
  it "returns a correct unix path" do
33
- expect(fetcher.fix_windows_path(uri.path)).to eq("/nyan_cat.png")
38
+ expect(fetcher.source_path).to eq("/nyan_cat.png")
34
39
  end
35
40
  end
36
41
 
37
42
  describe "when given local windows path" do
38
43
  let(:uri) { URI.parse("file:///z:/windows/path/file.txt") }
39
44
  it "returns a valid windows local path" do
40
- expect(fetcher.fix_windows_path(uri.path)).to eq("z:/windows/path/file.txt")
45
+ expect(fetcher.source_path).to eq("z:/windows/path/file.txt")
46
+ end
47
+ end
48
+
49
+ describe "when given local windows path with spaces" do
50
+ let(:uri) { URI.parse(URI.escape("file:///z:/windows/path/foo & bar.txt")) }
51
+ it "returns a valid windows local path" do
52
+ expect(fetcher.source_path).to eq("z:/windows/path/foo & bar.txt")
41
53
  end
42
54
  end
43
55
 
44
56
  describe "when given unc windows path" do
45
57
  let(:uri) { URI.parse("file:////server/share/windows/path/file.txt") }
46
58
  it "returns a valid windows unc path" do
47
- expect(fetcher.fix_windows_path(uri.path)).to eq("//server/share/windows/path/file.txt")
59
+ expect(fetcher.source_path).to eq("//server/share/windows/path/file.txt")
60
+ end
61
+ end
62
+
63
+ describe "when given unc windows path with spaces" do
64
+ let(:uri) { URI.parse(URI.escape("file:////server/share/windows/path/foo & bar.txt")) }
65
+ it "returns a valid windows unc path" do
66
+ expect(fetcher.source_path).to eq("//server/share/windows/path/foo & bar.txt")
48
67
  end
49
68
  end
50
69
  end
@@ -73,7 +92,7 @@ describe Chef::Provider::RemoteFile::LocalFile do
73
92
  it "stages the local file to a temporary file" do
74
93
  expect(Chef::FileContentManagement::Tempfile).to receive(:new).with(new_resource).and_return(chef_tempfile)
75
94
  expect(::FileUtils).to receive(:cp).with(uri.path, tempfile.path)
76
- expect(tempfile).to receive(:close)
95
+ expect(tempfile).to receive(:close)
77
96
 
78
97
  result = fetcher.fetch
79
98
  expect(result).to eq(tempfile)
@@ -189,18 +189,6 @@ PS_SAMPLE
189
189
  expect(provider.status_load_success).to be_nil
190
190
  end
191
191
 
192
- context "when ps command is nil" do
193
- before do
194
- node.automatic_attrs[:command] = {:ps => nil}
195
- end
196
-
197
- it "should set running to nil" do
198
- pending "superclass raises no conversion of nil to string which seems broken"
199
- provider.determine_current_status!
200
- expect(current_resource.running).to be_nil
201
- end
202
- end
203
-
204
192
  context "when ps is empty string" do
205
193
  before do
206
194
  node.automatic_attrs[:command] = {:ps => ""}
@@ -143,8 +143,8 @@ describe Chef::Provider::User do
143
143
  begin
144
144
  require 'rubygems'
145
145
  require 'shadow'
146
- rescue LoadError => e
147
- pending "ruby-shadow gem not installed for dynamic load test"
146
+ rescue LoadError
147
+ skip "ruby-shadow gem not installed for dynamic load test"
148
148
  true
149
149
  else
150
150
  false
@@ -161,7 +161,7 @@ describe Chef::Provider::User do
161
161
 
162
162
  unless shadow_lib_unavail?
163
163
  context "and we have the ruby-shadow gem" do
164
- pending "and we are not root (rerun this again as root)", :requires_unprivileged_user => true
164
+ skip "and we are not root (rerun this again as root)", :requires_unprivileged_user => true
165
165
 
166
166
  context "and we are root", :requires_root => true do
167
167
  it "should pass assertions when ruby-shadow can be loaded" do
@@ -19,9 +19,13 @@
19
19
  require 'spec_helper'
20
20
  require 'chef/mixin/convert_to_class_name'
21
21
  require 'chef/provider_resolver'
22
+ require 'chef/platform/service_helpers'
22
23
 
23
24
  include Chef::Mixin::ConvertToClassName
24
25
 
26
+ # Open up Provider so we can write things down easier in here
27
+ #module Chef::Provider
28
+
25
29
  describe Chef::ProviderResolver do
26
30
 
27
31
  let(:node) do
@@ -50,6 +54,51 @@ describe Chef::ProviderResolver do
50
54
  allow(resource).to receive(:is_a?).with(Chef::Resource).and_return(true)
51
55
  end
52
56
 
57
+ def self.on_platform(platform, *tags,
58
+ platform_version: '11.0.1',
59
+ platform_family: nil,
60
+ os: nil,
61
+ &block)
62
+ Array(platform).each do |platform|
63
+ Array(platform_version).each do |platform_version|
64
+ on_one_platform(platform, platform_version, platform_family || platform, os || platform_family || platform, *tags, &block)
65
+ end
66
+ end
67
+ end
68
+
69
+ def self.on_one_platform(platform, platform_version, platform_family, os, *tags, &block)
70
+ describe "on #{platform} #{platform_version}, platform_family: #{platform_family}, os: #{os}", *tags do
71
+ let(:os) { os }
72
+ let(:platform) { platform }
73
+ let(:platform_family) { platform_family }
74
+ let(:platform_version) { platform_version }
75
+
76
+ define_singleton_method(:os) { os }
77
+ define_singleton_method(:platform) { platform }
78
+ define_singleton_method(:platform_family) { platform_family }
79
+ define_singleton_method(:platform_version) { platform_version }
80
+
81
+ instance_eval(&block)
82
+ end
83
+ end
84
+
85
+ def self.expect_providers(**providers)
86
+ providers.each do |name, provider|
87
+ describe name.to_s do
88
+ let(:resource_name) { name }
89
+ if provider
90
+ it "resolves to a #{provider}" do
91
+ expect(resolved_provider).to eql(provider)
92
+ end
93
+ else
94
+ it "Fails to resolve (since #{name.inspect} is unsupported on #{platform} #{platform_version})" do
95
+ expect { resolved_provider }.to raise_error /Cannot find a provider/
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+
53
102
  describe "resolving service resource" do
54
103
  def stub_service_providers(*services)
55
104
  services ||= []
@@ -64,7 +113,6 @@ describe Chef::ProviderResolver do
64
113
  end
65
114
 
66
115
  before do
67
- expect(provider_resolver).not_to receive(:maybe_chef_platform_lookup)
68
116
  allow(resource).to receive(:service_name).and_return("ntp")
69
117
  end
70
118
 
@@ -301,389 +349,477 @@ describe Chef::ProviderResolver do
301
349
  end
302
350
  end
303
351
 
304
- describe "on Ubuntu 14.10" do
305
- let(:os) { "linux" }
306
- let(:platform) { "ubuntu" }
307
- let(:platform_family) { "debian" }
308
- let(:platform_version) { "14.04" }
309
-
352
+ on_platform "ubuntu", platform_version: "14.10", platform_family: "debian", os: "linux" do
310
353
  it_behaves_like "an ubuntu platform with upstart, update-rc.d and systemd"
311
354
  end
312
355
 
313
- describe "on Ubuntu 14.04" do
314
- let(:os) { "linux" }
315
- let(:platform) { "ubuntu" }
316
- let(:platform_family) { "debian" }
317
- let(:platform_version) { "14.04" }
318
-
356
+ on_platform "ubuntu", platform_version: "14.04", platform_family: "debian", os: "linux" do
319
357
  it_behaves_like "an ubuntu platform with upstart and update-rc.d"
320
358
  end
321
359
 
322
- describe "on Ubuntu 10.04" do
323
- let(:os) { "linux" }
324
- let(:platform) { "ubuntu" }
325
- let(:platform_family) { "debian" }
326
- let(:platform_version) { "10.04" }
327
-
360
+ on_platform "ubuntu", platform_version: "10.04", platform_family: "debian", os: "linux" do
328
361
  it_behaves_like "an ubuntu platform with upstart and update-rc.d"
329
362
  end
330
363
 
331
364
  # old debian uses the Debian provider (does not have insserv or upstart, or update-rc.d???)
332
- describe "on Debian 4.0" do
333
- let(:os) { "linux" }
334
- let(:platform) { "debian" }
335
- let(:platform_family) { "debian" }
336
- let(:platform_version) { "4.0" }
337
-
365
+ on_platform "debian", platform_version: "4.0", os: "linux" do
338
366
  #it_behaves_like "a debian platform using the debian provider"
339
367
  end
340
368
 
341
369
  # Debian replaced the debian provider with insserv in the FIXME:VERSION distro
342
- describe "on Debian 7.0" do
343
- let(:os) { "linux" }
344
- let(:platform) { "debian" }
345
- let(:platform_family) { "debian" }
346
- let(:platform_version) { "7.0" }
347
-
370
+ on_platform "debian", platform_version: "7.0", os: "linux" do
348
371
  it_behaves_like "a debian platform using the insserv provider"
349
372
  end
350
373
 
351
- %w{solaris2 openindiana opensolaris nexentacore omnios smartos}.each do |platform|
352
- describe "on #{platform}" do
353
- let(:os) { "solaris2" }
354
- let(:platform) { platform }
355
- let(:platform_family) { platform }
356
- let(:platform_version) { "5.11" }
357
-
358
- it "returns a Solaris provider" do
359
- stub_service_providers
360
- stub_service_configs
361
- expect(resolved_provider).to eql(Chef::Provider::Service::Solaris)
362
- end
374
+ on_platform %w{solaris2 openindiana opensolaris nexentacore omnios smartos}, os: "solaris2", platform_version: "5.11" do
375
+ it "returns a Solaris provider" do
376
+ stub_service_providers
377
+ stub_service_configs
378
+ expect(resolved_provider).to eql(Chef::Provider::Service::Solaris)
379
+ end
363
380
 
364
- it "always returns a Solaris provider" do
365
- # no matter what we stub on the next two lines we should get a Solaris provider
366
- stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
367
- stub_service_configs(:initd, :upstart, :xinetd, :user_local_etc_rcd, :systemd)
368
- expect(resolved_provider).to eql(Chef::Provider::Service::Solaris)
369
- end
381
+ it "always returns a Solaris provider" do
382
+ # no matter what we stub on the next two lines we should get a Solaris provider
383
+ stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
384
+ stub_service_configs(:initd, :upstart, :xinetd, :user_local_etc_rcd, :systemd)
385
+ expect(resolved_provider).to eql(Chef::Provider::Service::Solaris)
370
386
  end
371
387
  end
372
388
 
373
- %w{mswin mingw32 windows}.each do |platform|
374
- describe "on #{platform}" do
375
- let(:os) { "windows" }
376
- let(:platform) { platform }
377
- let(:platform_family) { "windows" }
378
- let(:platform_version) { "5.11" }
379
-
380
- it "returns a Windows provider" do
381
- stub_service_providers
382
- stub_service_configs
383
- expect(resolved_provider).to eql(Chef::Provider::Service::Windows)
384
- end
389
+ on_platform %w{mswin mingw32 windows}, platform_family: "windows", platform_version: "5.11" do
390
+ it "returns a Windows provider" do
391
+ stub_service_providers
392
+ stub_service_configs
393
+ expect(resolved_provider).to eql(Chef::Provider::Service::Windows)
394
+ end
385
395
 
386
- it "always returns a Windows provider" do
387
- # no matter what we stub on the next two lines we should get a Windows provider
388
- stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
389
- stub_service_configs(:initd, :upstart, :xinetd, :user_local_etc_rcd, :systemd)
390
- expect(resolved_provider).to eql(Chef::Provider::Service::Windows)
391
- end
396
+ it "always returns a Windows provider" do
397
+ # no matter what we stub on the next two lines we should get a Windows provider
398
+ stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
399
+ stub_service_configs(:initd, :upstart, :xinetd, :user_local_etc_rcd, :systemd)
400
+ expect(resolved_provider).to eql(Chef::Provider::Service::Windows)
392
401
  end
393
402
  end
394
403
 
395
- %w{mac_os_x mac_os_x_server}.each do |platform|
396
- describe "on #{platform}" do
397
- let(:os) { "darwin" }
398
- let(:platform) { platform }
399
- let(:platform_family) { "mac_os_x" }
400
- let(:platform_version) { "10.9.2" }
401
-
402
- it "returns a Macosx provider" do
403
- stub_service_providers
404
- stub_service_configs
405
- expect(resolved_provider).to eql(Chef::Provider::Service::Macosx)
406
- end
404
+ on_platform %w{mac_os_x mac_os_x_server}, os: "darwin", platform_family: "mac_os_x", platform_version: "10.9.2" do
405
+ it "returns a Macosx provider" do
406
+ stub_service_providers
407
+ stub_service_configs
408
+ expect(resolved_provider).to eql(Chef::Provider::Service::Macosx)
409
+ end
407
410
 
408
- it "always returns a Macosx provider" do
409
- # no matter what we stub on the next two lines we should get a Macosx provider
410
- stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
411
- stub_service_configs(:initd, :upstart, :xinetd, :user_local_etc_rcd, :systemd)
412
- expect(resolved_provider).to eql(Chef::Provider::Service::Macosx)
413
- end
411
+ it "always returns a Macosx provider" do
412
+ # no matter what we stub on the next two lines we should get a Macosx provider
413
+ stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
414
+ stub_service_configs(:initd, :upstart, :xinetd, :user_local_etc_rcd, :systemd)
415
+ expect(resolved_provider).to eql(Chef::Provider::Service::Macosx)
414
416
  end
415
417
  end
416
418
 
417
- %w{freebsd netbsd}.each do |platform|
418
- describe "on #{platform}" do
419
- let(:os) { platform }
420
- let(:platform) { platform }
421
- let(:platform_family) { platform }
422
- let(:platform_version) { "10.0-RELEASE" }
423
-
424
- it "returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
425
- stub_service_providers
426
- stub_service_configs(:usr_local_etc_rcd)
427
- expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
428
- end
419
+ on_platform %w(freebsd netbsd), platform_version: '3.1.4' do
420
+ it "returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
421
+ stub_service_providers
422
+ stub_service_configs(:usr_local_etc_rcd)
423
+ expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
424
+ end
429
425
 
430
- it "returns a Freebsd provider if it finds the /etc/rc.d initscript" do
431
- stub_service_providers
432
- stub_service_configs(:etc_rcd)
433
- expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
434
- end
426
+ it "returns a Freebsd provider if it finds the /etc/rc.d initscript" do
427
+ stub_service_providers
428
+ stub_service_configs(:etc_rcd)
429
+ expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
430
+ end
435
431
 
436
- it "always returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
437
- # should only care about :usr_local_etc_rcd stub in the service configs
438
- stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
439
- stub_service_configs(:usr_local_etc_rcd, :initd, :upstart, :xinetd, :systemd)
440
- expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
441
- end
432
+ it "always returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
433
+ # should only care about :usr_local_etc_rcd stub in the service configs
434
+ stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
435
+ stub_service_configs(:usr_local_etc_rcd, :initd, :upstart, :xinetd, :systemd)
436
+ expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
437
+ end
442
438
 
443
- it "always returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
444
- # should only care about :etc_rcd stub in the service configs
445
- stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
446
- stub_service_configs(:etc_rcd, :initd, :upstart, :xinetd, :systemd)
447
- expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
448
- end
439
+ it "always returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
440
+ # should only care about :etc_rcd stub in the service configs
441
+ stub_service_providers(:debian, :invokercd, :insserv, :upstart, :redhat, :systemd)
442
+ stub_service_configs(:etc_rcd, :initd, :upstart, :xinetd, :systemd)
443
+ expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
444
+ end
449
445
 
450
- it "foo" do
451
- stub_service_providers
452
- stub_service_configs
453
- expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
454
- end
446
+ it "foo" do
447
+ stub_service_providers
448
+ stub_service_configs
449
+ expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
455
450
  end
456
451
  end
457
452
 
458
453
  end
459
454
 
460
- describe "for the package provider" do
461
- let(:resource_name) { :package }
462
-
463
- before do
464
- expect(provider_resolver).not_to receive(:maybe_chef_platform_lookup)
465
- end
466
-
467
- %w{mac_os_x mac_os_x_server}.each do |platform|
468
- describe "on #{platform}" do
469
- let(:os) { "darwin" }
470
- let(:platform) { platform }
471
- let(:platform_family) { "mac_os_x" }
472
- let(:platform_version) { "10.9.2" }
473
-
474
-
475
- it "returns a Chef::Provider::Package::Homebrew provider" do
476
- expect(resolved_provider).to eql(Chef::Provider::Package::Homebrew)
477
- end
478
- end
479
- end
480
- end
455
+ PROVIDERS =
456
+ {
457
+ bash: Chef::Provider::Script,
458
+ breakpoint: Chef::Provider::Breakpoint,
459
+ chef_gem: Chef::Provider::Package::Rubygems,
460
+ cookbook_file: Chef::Provider::CookbookFile,
461
+ csh: Chef::Provider::Script,
462
+ deploy: Chef::Provider::Deploy::Timestamped,
463
+ deploy_revision: Chef::Provider::Deploy::Revision,
464
+ directory: Chef::Provider::Directory,
465
+ easy_install_package: Chef::Provider::Package::EasyInstall,
466
+ erl_call: Chef::Provider::ErlCall,
467
+ execute: Chef::Provider::Execute,
468
+ file: Chef::Provider::File,
469
+ gem_package: Chef::Provider::Package::Rubygems,
470
+ git: Chef::Provider::Git,
471
+ group: Chef::Provider::Group::Gpasswd,
472
+ homebrew_package: Chef::Provider::Package::Homebrew,
473
+ http_request: Chef::Provider::HttpRequest,
474
+ ifconfig: Chef::Provider::Ifconfig,
475
+ link: Chef::Provider::Link,
476
+ log: Chef::Provider::Log::ChefLog,
477
+ macports_package: Chef::Provider::Package::Macports,
478
+ mdadm: Chef::Provider::Mdadm,
479
+ mount: Chef::Provider::Mount::Mount,
480
+ perl: Chef::Provider::Script,
481
+ portage_package: Chef::Provider::Package::Portage,
482
+ python: Chef::Provider::Script,
483
+ remote_directory: Chef::Provider::RemoteDirectory,
484
+ route: Chef::Provider::Route,
485
+ rpm_package: Chef::Provider::Package::Rpm,
486
+ ruby: Chef::Provider::Script,
487
+ ruby_block: Chef::Provider::RubyBlock,
488
+ script: Chef::Provider::Script,
489
+ subversion: Chef::Provider::Subversion,
490
+ template: Chef::Provider::Template,
491
+ timestamped_deploy: Chef::Provider::Deploy::Timestamped,
492
+ user: Chef::Provider::User::Useradd,
493
+ whyrun_safe_ruby_block: Chef::Provider::WhyrunSafeRubyBlock,
494
+
495
+ # We want to check that these are unsupported:
496
+ apt_package: nil,
497
+ bff_package: nil,
498
+ dsc_script: nil,
499
+ dpkg_package: nil,
500
+ ips_package: nil,
501
+ pacman_package: nil,
502
+ paludis_package: nil,
503
+ rpm_package: nil,
504
+ smartos_package: nil,
505
+ solaris_package: nil,
506
+ yum_package: nil,
507
+ windows_package: nil,
508
+ windows_service: nil,
509
+
510
+ "linux" => {
511
+ apt_package: Chef::Provider::Package::Apt,
512
+ dpkg_package: Chef::Provider::Package::Dpkg,
513
+ pacman_package: Chef::Provider::Package::Pacman,
514
+ paludis_package: Chef::Provider::Package::Paludis,
515
+ rpm_package: Chef::Provider::Package::Rpm,
516
+ yum_package: Chef::Provider::Package::Yum,
517
+
518
+ "debian" => {
519
+ ifconfig: Chef::Provider::Ifconfig::Debian,
520
+ package: Chef::Provider::Package::Apt,
521
+ # service: Chef::Provider::Service::Debian,
522
+
523
+ "debian" => {
524
+ "7.0" => {
525
+ },
526
+ "6.0" => {
527
+ ifconfig: Chef::Provider::Ifconfig,
528
+ # service: Chef::Provider::Service::Insserv,
529
+ },
530
+ "5.0" => {
531
+ ifconfig: Chef::Provider::Ifconfig,
532
+ },
533
+ },
534
+ "gcel" => {
535
+ "3.1.4" => {
536
+ ifconfig: Chef::Provider::Ifconfig,
537
+ },
538
+ },
539
+ "linaro" => {
540
+ "3.1.4" => {
541
+ ifconfig: Chef::Provider::Ifconfig,
542
+ },
543
+ },
544
+ "linuxmint" => {
545
+ "3.1.4" => {
546
+ ifconfig: Chef::Provider::Ifconfig,
547
+ # service: Chef::Provider::Service::Upstart,
548
+ },
549
+ },
550
+ "raspbian" => {
551
+ "3.1.4" => {
552
+ ifconfig: Chef::Provider::Ifconfig,
553
+ },
554
+ },
555
+ "ubuntu" => {
556
+ "11.10" => {
557
+ },
558
+ "10.04" => {
559
+ ifconfig: Chef::Provider::Ifconfig,
560
+ },
561
+ },
562
+ },
563
+
564
+ "arch" => {
565
+ package: Chef::Provider::Package::Pacman,
566
+
567
+ "arch" => {
568
+ "3.1.4" => {
569
+ }
570
+ },
571
+ },
572
+
573
+ "freebsd" => {
574
+ group: Chef::Provider::Group::Pw,
575
+ user: Chef::Provider::User::Pw,
576
+
577
+ "freebsd" => {
578
+ "3.1.4" => {
579
+ },
580
+ },
581
+ },
582
+ "suse" => {
583
+ group: Chef::Provider::Group::Gpasswd,
584
+ "suse" => {
585
+ "12.0" => {
586
+ },
587
+ %w(11.1 11.2 11.3) => {
588
+ group: Chef::Provider::Group::Suse,
589
+ },
590
+ },
591
+ "opensuse" => {
592
+ # service: Chef::Provider::Service::Redhat,
593
+ package: Chef::Provider::Package::Zypper,
594
+ group: Chef::Provider::Group::Usermod,
595
+ "12.3" => {
596
+ },
597
+ "12.2" => {
598
+ group: Chef::Provider::Group::Suse,
599
+ },
600
+ },
601
+ },
602
+
603
+ "gentoo" => {
604
+ package: Chef::Provider::Package::Portage,
605
+ portage_package: Chef::Provider::Package::Portage,
606
+ # service: Chef::Provider::Service::Gentoo,
607
+
608
+ "gentoo" => {
609
+ "3.1.4" => {
610
+ },
611
+ },
612
+ },
613
+
614
+ "rhel" => {
615
+ # service: Chef::Provider::Service::Systemd,
616
+ package: Chef::Provider::Package::Yum,
617
+ ifconfig: Chef::Provider::Ifconfig::Redhat,
618
+
619
+ %w(amazon xcp xenserver ibm_powerkvm cloudlinux parallels) => {
620
+ "3.1.4" => {
621
+ # service: Chef::Provider::Service::Redhat,
622
+ },
623
+ },
624
+ %w(redhat centos scientific oracle) => {
625
+ "7.0" => {
626
+ },
627
+ "6.0" => {
628
+ # service: Chef::Provider::Service::Redhat,
629
+ },
630
+ },
631
+ "fedora" => {
632
+ "15.0" => {
633
+ },
634
+ "14.0" => {
635
+ # service: Chef::Provider::Service::Redhat,
636
+ },
637
+ },
638
+ },
481
639
 
482
- provider_mapping = {
483
- "mac_os_x" => {
484
- :package => Chef::Provider::Package::Homebrew,
485
- :user => Chef::Provider::User::Dscl,
486
- :group => Chef::Provider::Group::Dscl,
487
640
  },
488
- "mac_os_x_server" => {
489
- :package => Chef::Provider::Package::Homebrew,
490
- :user => Chef::Provider::User::Dscl,
491
- :group => Chef::Provider::Group::Dscl,
492
- },
493
- "mswin" => {
494
- :env => Chef::Provider::Env::Windows,
495
- :user => Chef::Provider::User::Windows,
496
- :group => Chef::Provider::Group::Windows,
497
- :mount => Chef::Provider::Mount::Windows,
498
- :batch => Chef::Provider::Batch,
499
- :powershell_script => Chef::Provider::PowershellScript,
500
- },
501
- "mingw32" => {
502
- :env => Chef::Provider::Env::Windows,
503
- :user => Chef::Provider::User::Windows,
504
- :group => Chef::Provider::Group::Windows,
505
- :mount => Chef::Provider::Mount::Windows,
506
- :batch => Chef::Provider::Batch,
507
- :powershell_script => Chef::Provider::PowershellScript,
641
+
642
+ "darwin" => {
643
+ %w(mac_os_x mac_os_x_server) => {
644
+ group: Chef::Provider::Group::Dscl,
645
+ package: Chef::Provider::Package::Homebrew,
646
+ user: Chef::Provider::User::Dscl,
647
+
648
+ "mac_os_x" => {
649
+ "10.9.2" => {
650
+ },
651
+ },
652
+ },
508
653
  },
654
+
509
655
  "windows" => {
510
- :env => Chef::Provider::Env::Windows,
511
- :user => Chef::Provider::User::Windows,
512
- :group => Chef::Provider::Group::Windows,
513
- :mount => Chef::Provider::Mount::Windows,
514
- :batch => Chef::Provider::Batch,
515
- :powershell_script => Chef::Provider::PowershellScript,
656
+ batch: Chef::Provider::Batch,
657
+ dsc_script: Chef::Provider::DscScript,
658
+ env: Chef::Provider::Env::Windows,
659
+ group: Chef::Provider::Group::Windows,
660
+ mount: Chef::Provider::Mount::Windows,
661
+ package: Chef::Provider::Package::Windows,
662
+ powershell_script: Chef::Provider::PowershellScript,
663
+ service: Chef::Provider::Service::Windows,
664
+ user: Chef::Provider::User::Windows,
665
+ windows_package: Chef::Provider::Package::Windows,
666
+ windows_service: Chef::Provider::Service::Windows,
667
+
668
+ "windows" => {
669
+ %w(mswin mingw32 windows) => {
670
+ "10.9.2" => {
671
+ },
672
+ },
673
+ },
516
674
  },
675
+
517
676
  "aix" => {
518
- :cron => Chef::Provider::Cron::Aix,
519
- },
520
- "netbsd"=> {
521
- :group => Chef::Provider::Group::Groupmod,
677
+ bff_package: Chef::Provider::Package::Aix,
678
+ cron: Chef::Provider::Cron::Aix,
679
+ group: Chef::Provider::Group::Aix,
680
+ ifconfig: Chef::Provider::Ifconfig::Aix,
681
+ mount: Chef::Provider::Mount::Aix,
682
+ package: Chef::Provider::Package::Aix,
683
+ rpm_package: Chef::Provider::Package::Rpm,
684
+ user: Chef::Provider::User::Aix,
685
+ # service: Chef::Provider::Service::Aix,
686
+
687
+ "aix" => {
688
+ "aix" => {
689
+ "5.6" => {
690
+ },
691
+ },
692
+ },
522
693
  },
523
- "openbsd" => {
524
- :group => Chef::Provider::Group::Usermod,
525
- :package => Chef::Provider::Package::Openbsd,
526
- },
527
- }
528
694
 
529
- def self.do_platform(platform_hash)
530
- platform_hash.each do |resource, provider|
531
- describe "for #{resource}" do
532
- let(:resource_name) { resource }
533
-
534
- it "resolves to a #{provider}" do
535
- expect(resolved_provider).to eql(provider)
536
- end
537
- end
538
- end
539
- end
540
-
541
- describe "individual platform mappings" do
542
- let(:resource_name) { :user }
543
-
544
- before do
545
- expect(provider_resolver).not_to receive(:maybe_chef_platform_lookup)
546
- end
547
-
548
- %w{mac_os_x mac_os_x_server}.each do |platform|
549
- describe "on #{platform}" do
550
- let(:os) { "darwin" }
551
- let(:platform) { platform }
552
- let(:platform_family) { "mac_os_x" }
553
- let(:platform_version) { "10.9.2" }
554
-
555
- do_platform(provider_mapping[platform])
556
- end
557
- end
558
-
559
- %w{mswin mingw32 windows}.each do |platform|
560
- describe "on #{platform}" do
561
- let(:os) { "windows" }
562
- let(:platform) { platform }
563
- let(:platform_family) { "windows" }
564
- let(:platform_version) { "10.9.2" }
695
+ "hpux" => {
696
+ "hpux" => {
697
+ "hpux" => {
698
+ "3.1.4" => {
699
+ group: Chef::Provider::Group::Usermod
700
+ }
701
+ }
702
+ }
703
+ },
565
704
 
566
- do_platform(provider_mapping[platform])
567
- end
568
- end
705
+ "netbsd" => {
706
+ "netbsd" => {
707
+ "netbsd" => {
708
+ "3.1.4" => {
709
+ group: Chef::Provider::Group::Groupmod,
710
+ },
711
+ },
712
+ },
713
+ },
569
714
 
570
- describe "on AIX" do
571
- let(:os) { "aix" }
572
- let(:platform) { "aix" }
573
- let(:platform_family) { "aix" }
574
- let(:platform_version) { "6.2" }
715
+ "openbsd" => {
716
+ group: Chef::Provider::Group::Usermod,
717
+ package: Chef::Provider::Package::Openbsd,
718
+
719
+ "openbsd" => {
720
+ "openbsd" => {
721
+ "3.1.4" => {
722
+ },
723
+ },
724
+ },
725
+ },
575
726
 
576
- do_platform(provider_mapping['aix'])
577
- end
727
+ "solaris2" => {
728
+ group: Chef::Provider::Group::Usermod,
729
+ ips_package: Chef::Provider::Package::Ips,
730
+ package: Chef::Provider::Package::Ips,
731
+ mount: Chef::Provider::Mount::Solaris,
732
+ solaris_package: Chef::Provider::Package::Solaris,
733
+
734
+ "smartos" => {
735
+ smartos_package: Chef::Provider::Package::SmartOS,
736
+ package: Chef::Provider::Package::SmartOS,
737
+
738
+ "smartos" => {
739
+ "3.1.4" => {
740
+ },
741
+ },
742
+ },
743
+
744
+ "solaris2" => {
745
+ "nexentacore" => {
746
+ "3.1.4" => {
747
+ package: Chef::Provider::Package::Solaris,
748
+ },
749
+ },
750
+ "omnios" => {
751
+ "3.1.4" => {
752
+ user: Chef::Provider::User::Solaris,
753
+ }
754
+ },
755
+ "openindiana" => {
756
+ "3.1.4" => {
757
+ },
758
+ },
759
+ "opensolaris" => {
760
+ "3.1.4" => {
761
+ },
762
+ },
763
+ "solaris2" => {
764
+ user: Chef::Provider::User::Solaris,
765
+ "5.11" => {
766
+ },
767
+ "5.9" => {
768
+ package: Chef::Provider::Package::Solaris,
769
+ },
770
+ },
771
+ },
578
772
 
579
- %w{netbsd openbsd}.each do |platform|
580
- describe "on #{platform}" do
581
- let(:os) { platform }
582
- let(:platform) { platform }
583
- let(:platform_family) { platform }
584
- let(:platform_version) { "10.0-RELEASE" }
773
+ },
585
774
 
586
- do_platform(provider_mapping[platform])
587
- end
588
- end
589
- end
775
+ "solaris" => {
776
+ "solaris" => {
777
+ "solaris" => {
778
+ "3.1.4" => {
779
+ },
780
+ },
781
+ },
782
+ },
590
783
 
591
- describe "resolving static providers" do
592
- def resource_class(resource)
593
- Chef::Resource.const_get(convert_to_class_name(resource.to_s))
594
- end
595
- static_mapping = {
596
- apt_package: Chef::Provider::Package::Apt,
597
- bash: Chef::Provider::Script,
598
- bff_package: Chef::Provider::Package::Aix,
599
- breakpoint: Chef::Provider::Breakpoint,
600
- chef_gem: Chef::Provider::Package::Rubygems,
601
- cookbook_file: Chef::Provider::CookbookFile,
602
- csh: Chef::Provider::Script,
603
- deploy: Chef::Provider::Deploy::Timestamped,
604
- deploy_revision: Chef::Provider::Deploy::Revision,
605
- directory: Chef::Provider::Directory,
606
- dpkg_package: Chef::Provider::Package::Dpkg,
607
- dsc_script: Chef::Provider::DscScript,
608
- easy_install_package: Chef::Provider::Package::EasyInstall,
609
- erl_call: Chef::Provider::ErlCall,
610
- execute: Chef::Provider::Execute,
611
- file: Chef::Provider::File,
612
- gem_package: Chef::Provider::Package::Rubygems,
613
- git: Chef::Provider::Git,
614
- homebrew_package: Chef::Provider::Package::Homebrew,
615
- http_request: Chef::Provider::HttpRequest,
616
- ips_package: Chef::Provider::Package::Ips,
617
- link: Chef::Provider::Link,
618
- log: Chef::Provider::Log::ChefLog,
619
- macports_package: Chef::Provider::Package::Macports,
620
- mdadm: Chef::Provider::Mdadm,
621
- pacman_package: Chef::Provider::Package::Pacman,
622
- paludis_package: Chef::Provider::Package::Paludis,
623
- perl: Chef::Provider::Script,
624
- portage_package: Chef::Provider::Package::Portage,
625
- python: Chef::Provider::Script,
626
- remote_directory: Chef::Provider::RemoteDirectory,
627
- route: Chef::Provider::Route,
628
- rpm_package: Chef::Provider::Package::Rpm,
629
- ruby: Chef::Provider::Script,
630
- ruby_block: Chef::Provider::RubyBlock,
631
- script: Chef::Provider::Script,
632
- smartos_package: Chef::Provider::Package::SmartOS,
633
- solaris_package: Chef::Provider::Package::Solaris,
634
- subversion: Chef::Provider::Subversion,
635
- template: Chef::Provider::Template,
636
- timestamped_deploy: Chef::Provider::Deploy::Timestamped,
637
- whyrun_safe_ruby_block: Chef::Provider::WhyrunSafeRubyBlock,
638
- windows_package: Chef::Provider::Package::Windows,
639
- windows_service: Chef::Provider::Service::Windows,
640
- yum_package: Chef::Provider::Package::Yum,
784
+ "exherbo" => {
785
+ "exherbo" => {
786
+ "exherbo" => {
787
+ "3.1.4" => {
788
+ package: Chef::Provider::Package::Paludis
789
+ }
790
+ }
641
791
  }
792
+ }
793
+ }
642
794
 
643
- describe "on Ubuntu 14.04" do
644
- let(:os) { "linux" }
645
- let(:platform) { "ubuntu" }
646
- let(:platform_family) { "debian" }
647
- let(:platform_version) { "14.04" }
648
-
649
- supported_providers = [
650
- :apt_package, :bash, :breakpoint, :chef_gem, :cookbook_file, :csh, :deploy,
651
- :deploy_revision, :directory, :dpkg_package, :easy_install_package, :erl_call,
652
- :execute, :file, :gem_package, :git, :homebrew_package, :http_request, :link,
653
- :log, :macports_package, :pacman_package, :paludis_package, :perl, :python,
654
- :remote_directory, :route, :rpm_package, :ruby, :ruby_block, :script, :subversion,
655
- :template, :timestamped_deploy, :whyrun_safe_ruby_block, :yum_package,
656
- ]
657
-
658
- supported_providers.each do |static_resource|
659
- static_provider = static_mapping[static_resource]
660
- context "when the resource is a #{static_resource}" do
661
- let(:resource) { double(Chef::Resource, provider: nil, resource_name: static_resource) }
662
- let(:action) { :start } # in reality this doesn't matter much
663
- it "should resolve to a #{static_provider} provider" do
664
- expect(provider_resolver).not_to receive(:maybe_chef_platform_lookup)
665
- expect(resolved_provider).to eql(static_provider)
795
+ def self.create_provider_tests(providers, test, expected, filter)
796
+ expected = expected.merge(providers.select { |key, value| key.is_a?(Symbol) })
797
+ providers.each do |key, value|
798
+ if !key.is_a?(Symbol)
799
+ next_test = test.merge({ filter => key })
800
+ next_filter =
801
+ case filter
802
+ when :os
803
+ :platform_family
804
+ when :platform_family
805
+ :platform
806
+ when :platform
807
+ :platform_version
808
+ when :platform_version
809
+ nil
810
+ else
811
+ raise "Hash too deep; only os, platform_family, platform and platform_version supported"
666
812
  end
667
- end
813
+ create_provider_tests(value, next_test, expected, next_filter)
668
814
  end
669
-
670
- unsupported_providers = [
671
- :bff_package, :dsc_script, :ips_package, :smartos_package,
672
- :solaris_package, :windows_package, :windows_service,
673
- ]
674
-
675
- unsupported_providers.each do |static_resource|
676
- static_provider = static_mapping[static_resource]
677
- context "when the resource is a #{static_resource}" do
678
- let(:resource) { double(Chef::Resource, provider: nil, resource_name: static_resource) }
679
- let(:action) { :start } # in reality this doesn't matter much
680
- it "should fall back into the old provider mapper code and hooks" do
681
- retval = Object.new
682
- expect(provider_resolver).to receive(:maybe_chef_platform_lookup).and_return(retval)
683
- expect(resolved_provider).to equal(retval)
684
- end
685
- end
815
+ end
816
+ # If there is no filter, we're as deep as we need to go
817
+ if !filter
818
+ on_platform test.delete(:platform), test do
819
+ expect_providers(expected)
686
820
  end
687
821
  end
688
822
  end
823
+
824
+ create_provider_tests(PROVIDERS, {}, {}, :os)
689
825
  end