chef 13.6.4 → 13.7.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (257) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/acceptance/Gemfile +2 -2
  4. data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb +1 -6
  5. data/distro/powershell/chef/chef.psm1 +1 -5
  6. data/lib/chef/api_client.rb +5 -5
  7. data/lib/chef/api_client_v1.rb +6 -6
  8. data/lib/chef/application.rb +3 -2
  9. data/lib/chef/application/knife.rb +4 -0
  10. data/lib/chef/chef_class.rb +2 -2
  11. data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
  12. data/lib/chef/chef_fs/data_handler/data_handler_base.rb +2 -4
  13. data/lib/chef/client.rb +3 -3
  14. data/lib/chef/cookbook/chefignore.rb +4 -0
  15. data/lib/chef/cookbook/cookbook_collection.rb +2 -2
  16. data/lib/chef/cookbook/metadata.rb +2 -2
  17. data/lib/chef/data_bag.rb +1 -1
  18. data/lib/chef/deprecated.rb +10 -0
  19. data/lib/chef/event_dispatch/base.rb +2 -2
  20. data/lib/chef/http.rb +10 -10
  21. data/lib/chef/knife.rb +16 -15
  22. data/lib/chef/knife/configure.rb +12 -36
  23. data/lib/chef/knife/cookbook_upload.rb +4 -4
  24. data/lib/chef/knife/core/bootstrap_context.rb +1 -1
  25. data/lib/chef/knife/core/status_presenter.rb +6 -2
  26. data/lib/chef/knife/core/ui.rb +1 -1
  27. data/lib/chef/knife/data_bag_secret_options.rb +1 -1
  28. data/lib/chef/knife/data_bag_show.rb +1 -1
  29. data/lib/chef/knife/edit.rb +1 -1
  30. data/lib/chef/knife/ssh.rb +47 -35
  31. data/lib/chef/knife/user_create.rb +2 -0
  32. data/lib/chef/knife/user_delete.rb +2 -0
  33. data/lib/chef/knife/user_edit.rb +2 -0
  34. data/lib/chef/knife/user_reregister.rb +2 -0
  35. data/lib/chef/knife/user_show.rb +2 -0
  36. data/lib/chef/mixin/powershell_out.rb +1 -1
  37. data/lib/chef/node/attribute.rb +46 -70
  38. data/lib/chef/node/attribute_collections.rb +5 -5
  39. data/lib/chef/node/common_api.rb +1 -1
  40. data/lib/chef/node/immutable_collections.rb +180 -23
  41. data/lib/chef/node/mixin/state_tracking.rb +6 -6
  42. data/lib/chef/node_map.rb +63 -45
  43. data/lib/chef/property.rb +8 -8
  44. data/lib/chef/provider.rb +9 -3
  45. data/lib/chef/provider/apt_preference.rb +1 -1
  46. data/lib/chef/provider/apt_repository.rb +1 -1
  47. data/lib/chef/provider/apt_update.rb +1 -1
  48. data/lib/chef/provider/file.rb +1 -1
  49. data/lib/chef/provider/group/dscl.rb +6 -2
  50. data/lib/chef/provider/ifconfig.rb +96 -34
  51. data/lib/chef/provider/launchd.rb +0 -1
  52. data/lib/chef/provider/log.rb +3 -13
  53. data/lib/chef/provider/package/dnf.rb +1 -1
  54. data/lib/chef/provider/package/smartos.rb +2 -2
  55. data/lib/chef/provider/reboot.rb +12 -0
  56. data/lib/chef/provider/remote_directory.rb +1 -1
  57. data/lib/chef/provider/remote_file/http.rb +3 -2
  58. data/lib/chef/provider/service/solaris.rb +6 -2
  59. data/lib/chef/provider/systemd_unit.rb +34 -33
  60. data/lib/chef/provider/user/dscl.rb +1 -1
  61. data/lib/chef/provider/windows_path.rb +6 -7
  62. data/lib/chef/provider/windows_task.rb +89 -33
  63. data/lib/chef/provider/yum_repository.rb +24 -9
  64. data/lib/chef/resource/apt_package.rb +1 -0
  65. data/lib/chef/resource/apt_preference.rb +4 -0
  66. data/lib/chef/resource/apt_repository.rb +4 -0
  67. data/lib/chef/resource/apt_update.rb +3 -0
  68. data/lib/chef/resource/bash.rb +4 -0
  69. data/lib/chef/resource/batch.rb +5 -0
  70. data/lib/chef/resource/bff_package.rb +4 -0
  71. data/lib/chef/resource/breakpoint.rb +6 -0
  72. data/lib/chef/resource/cab_package.rb +6 -6
  73. data/lib/chef/resource/chef_gem.rb +13 -0
  74. data/lib/chef/resource/chocolatey_package.rb +4 -6
  75. data/lib/chef/resource/cookbook_file.rb +13 -15
  76. data/lib/chef/resource/cron.rb +2 -0
  77. data/lib/chef/resource/csh.rb +4 -0
  78. data/lib/chef/resource/directory.rb +8 -26
  79. data/lib/chef/resource/dnf_package.rb +5 -0
  80. data/lib/chef/resource/dpkg_package.rb +2 -0
  81. data/lib/chef/resource/dsc_resource.rb +5 -0
  82. data/lib/chef/resource/dsc_script.rb +6 -0
  83. data/lib/chef/resource/env.rb +3 -0
  84. data/lib/chef/resource/erl_call.rb +5 -0
  85. data/lib/chef/resource/execute.rb +5 -1
  86. data/lib/chef/resource/file.rb +2 -1
  87. data/lib/chef/resource/file/verification.rb +10 -0
  88. data/lib/chef/resource/freebsd_package.rb +10 -2
  89. data/lib/chef/resource/gem_package.rb +2 -0
  90. data/lib/chef/resource/git.rb +2 -0
  91. data/lib/chef/resource/group.rb +1 -0
  92. data/lib/chef/resource/homebrew_package.rb +3 -0
  93. data/lib/chef/resource/http_request.rb +2 -0
  94. data/lib/chef/resource/ifconfig.rb +23 -150
  95. data/lib/chef/resource/ips_package.rb +1 -0
  96. data/lib/chef/resource/ksh.rb +6 -0
  97. data/lib/chef/resource/launchd.rb +5 -4
  98. data/lib/chef/resource/link.rb +10 -0
  99. data/lib/chef/resource/log.rb +19 -46
  100. data/lib/chef/resource/macports_package.rb +1 -0
  101. data/lib/chef/resource/mdadm.rb +4 -0
  102. data/lib/chef/resource/mount.rb +1 -0
  103. data/lib/chef/resource/msu_package.rb +7 -8
  104. data/lib/chef/resource/ohai.rb +2 -0
  105. data/lib/chef/resource/openbsd_package.rb +3 -0
  106. data/lib/chef/resource/osx_profile.rb +10 -40
  107. data/lib/chef/resource/package.rb +6 -0
  108. data/lib/chef/resource/pacman_package.rb +1 -0
  109. data/lib/chef/resource/paludis_package.rb +3 -0
  110. data/lib/chef/resource/perl.rb +4 -0
  111. data/lib/chef/resource/portage_package.rb +1 -0
  112. data/lib/chef/resource/powershell_package.rb +5 -0
  113. data/lib/chef/resource/powershell_script.rb +8 -0
  114. data/lib/chef/resource/python.rb +4 -0
  115. data/lib/chef/resource/reboot.rb +14 -20
  116. data/lib/chef/resource/registry_key.rb +1 -0
  117. data/lib/chef/resource/remote_directory.rb +3 -0
  118. data/lib/chef/resource/remote_file.rb +2 -0
  119. data/lib/chef/resource/resource_notification.rb +17 -0
  120. data/lib/chef/resource/route.rb +1 -0
  121. data/lib/chef/resource/rpm_package.rb +1 -0
  122. data/lib/chef/resource/ruby.rb +4 -0
  123. data/lib/chef/resource/ruby_block.rb +3 -0
  124. data/lib/chef/resource/script.rb +4 -0
  125. data/lib/chef/resource/service.rb +1 -0
  126. data/lib/chef/resource/smartos_package.rb +1 -0
  127. data/lib/chef/resource/solaris_package.rb +1 -0
  128. data/lib/chef/resource/subversion.rb +1 -0
  129. data/lib/chef/resource/systemd_unit.rb +6 -0
  130. data/lib/chef/resource/template.rb +9 -0
  131. data/lib/chef/resource/user.rb +1 -0
  132. data/lib/chef/resource/windows_package.rb +2 -0
  133. data/lib/chef/resource/windows_path.rb +5 -10
  134. data/lib/chef/resource/windows_service.rb +3 -0
  135. data/lib/chef/resource/windows_task.rb +66 -87
  136. data/lib/chef/resource/yum_repository.rb +26 -22
  137. data/lib/chef/resource/zypper_package.rb +2 -0
  138. data/lib/chef/resource/zypper_repository.rb +6 -1
  139. data/lib/chef/run_context.rb +8 -2
  140. data/lib/chef/server_api.rb +1 -0
  141. data/lib/chef/util/selinux.rb +5 -4
  142. data/lib/chef/version.rb +1 -1
  143. data/lib/chef/version/platform.rb +18 -0
  144. data/lib/chef/version_constraint/platform.rb +2 -0
  145. data/spec/data/client.d_00/02-strings.rb +2 -0
  146. data/spec/functional/assets/chefinittest +6 -4
  147. data/spec/functional/knife/ssh_spec.rb +54 -7
  148. data/spec/functional/resource/bff_spec.rb +3 -3
  149. data/spec/functional/resource/ifconfig_spec.rb +1 -1
  150. data/spec/functional/resource/mount_spec.rb +7 -3
  151. data/spec/functional/resource/user/useradd_spec.rb +4 -4
  152. data/spec/functional/resource/windows_task_spec.rb +6 -6
  153. data/spec/functional/win32/security_spec.rb +7 -33
  154. data/spec/integration/knife/data_bag_show_spec.rb +1 -1
  155. data/spec/integration/recipes/noop_resource_spec.rb +1 -1
  156. data/spec/integration/recipes/recipe_dsl_spec.rb +30 -30
  157. data/spec/integration/recipes/resource_action_spec.rb +2 -2
  158. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +71 -15
  159. data/spec/spec_helper.rb +19 -0
  160. data/spec/support/shared/functional/execute_resource.rb +1 -1
  161. data/spec/support/shared/unit/application_dot_d.rb +2 -0
  162. data/spec/support/shared/unit/execute_resource.rb +8 -1
  163. data/spec/support/shared/unit/provider/file.rb +9 -1
  164. data/spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb +10 -7
  165. data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +2 -2
  166. data/spec/unit/client_spec.rb +1 -1
  167. data/spec/unit/deprecated_spec.rb +4 -4
  168. data/spec/unit/http_spec.rb +9 -0
  169. data/spec/unit/knife/bootstrap_spec.rb +5 -0
  170. data/spec/unit/knife/configure_spec.rb +10 -60
  171. data/spec/unit/knife/data_bag_create_spec.rb +40 -2
  172. data/spec/unit/knife/data_bag_show_spec.rb +16 -2
  173. data/spec/unit/knife/ssh_spec.rb +85 -39
  174. data/spec/unit/knife_spec.rb +2 -0
  175. data/spec/unit/lwrp_spec.rb +5 -3
  176. data/spec/unit/mixin/powershell_type_coercions_spec.rb +7 -6
  177. data/spec/unit/node/attribute_spec.rb +55 -24
  178. data/spec/unit/node/immutable_collections_spec.rb +28 -14
  179. data/spec/unit/node/vivid_mash_spec.rb +27 -10
  180. data/spec/unit/node_map_spec.rb +34 -0
  181. data/spec/unit/property_spec.rb +13 -13
  182. data/spec/unit/provider/group/dscl_spec.rb +14 -5
  183. data/spec/unit/provider/ifconfig_spec.rb +10 -3
  184. data/spec/unit/provider/remote_file/http_spec.rb +23 -19
  185. data/spec/unit/provider/service/solaris_smf_service_spec.rb +6 -5
  186. data/spec/unit/provider/user/dscl_spec.rb +26 -0
  187. data/spec/unit/provider/windows_task_spec.rb +148 -4
  188. data/spec/unit/provider_spec.rb +1 -1
  189. data/spec/unit/resource/apt_package_spec.rb +1 -1
  190. data/spec/unit/resource/bash_spec.rb +8 -10
  191. data/spec/unit/resource/batch_spec.rb +1 -1
  192. data/spec/unit/resource/cab_package_spec.rb +19 -1
  193. data/spec/unit/resource/chef_gem_spec.rb +3 -3
  194. data/spec/unit/resource/chocolatey_package_spec.rb +10 -10
  195. data/spec/unit/resource/conditional_spec.rb +2 -2
  196. data/spec/unit/resource/cookbook_file_spec.rb +24 -30
  197. data/spec/unit/resource/cron_spec.rb +79 -82
  198. data/spec/unit/resource/csh_spec.rb +8 -10
  199. data/spec/unit/resource/deploy_spec.rb +1 -1
  200. data/spec/unit/resource/directory_spec.rb +28 -31
  201. data/spec/unit/resource/dnf_package_spec.rb +9 -9
  202. data/spec/unit/resource/env_spec.rb +7 -7
  203. data/spec/unit/resource/erl_call_spec.rb +9 -9
  204. data/spec/unit/resource/execute_spec.rb +6 -6
  205. data/spec/unit/resource/file/verification_spec.rb +18 -4
  206. data/spec/unit/resource/file_spec.rb +53 -56
  207. data/spec/unit/resource/freebsd_package_spec.rb +7 -7
  208. data/spec/unit/resource/gem_package_spec.rb +1 -1
  209. data/spec/unit/resource/git_spec.rb +7 -9
  210. data/spec/unit/resource/group_spec.rb +60 -70
  211. data/spec/unit/resource/http_request_spec.rb +16 -19
  212. data/spec/unit/resource/ifconfig_spec.rb +3 -3
  213. data/spec/unit/resource/ips_package_spec.rb +3 -5
  214. data/spec/unit/resource/ksh_spec.rb +8 -10
  215. data/spec/unit/resource/launchd_spec.rb +17 -10
  216. data/spec/unit/resource/link_spec.rb +53 -53
  217. data/spec/unit/resource/log_spec.rb +24 -28
  218. data/spec/unit/resource/mdadm_spec.rb +42 -44
  219. data/spec/unit/resource/mount_spec.rb +97 -99
  220. data/spec/unit/resource/msu_package_spec.rb +14 -8
  221. data/spec/unit/resource/ohai_spec.rb +15 -17
  222. data/spec/unit/resource/openbsd_package_spec.rb +3 -3
  223. data/spec/unit/resource/osx_profile_spec.rb +7 -7
  224. data/spec/unit/resource/package_spec.rb +36 -40
  225. data/spec/unit/resource/perl_spec.rb +8 -11
  226. data/spec/unit/resource/portage_package_spec.rb +8 -10
  227. data/spec/unit/resource/powershell_package_spec.rb +9 -9
  228. data/spec/unit/resource/python_spec.rb +8 -11
  229. data/spec/unit/resource/reboot_spec.rb +50 -0
  230. data/spec/unit/resource/registry_key_spec.rb +84 -98
  231. data/spec/unit/resource/remote_directory_spec.rb +40 -42
  232. data/spec/unit/resource/remote_file_spec.rb +78 -80
  233. data/spec/unit/resource/route_spec.rb +42 -44
  234. data/spec/unit/resource/rpm_package_spec.rb +5 -7
  235. data/spec/unit/resource/ruby_block_spec.rb +14 -16
  236. data/spec/unit/resource/ruby_spec.rb +8 -12
  237. data/spec/unit/resource/scm_spec.rb +66 -69
  238. data/spec/unit/resource/script_spec.rb +1 -1
  239. data/spec/unit/resource/service_spec.rb +80 -83
  240. data/spec/unit/resource/smartos_package_spec.rb +5 -0
  241. data/spec/unit/resource/solaris_package_spec.rb +3 -5
  242. data/spec/unit/resource/subversion_spec.rb +18 -16
  243. data/spec/unit/resource/systemd_unit_spec.rb +50 -54
  244. data/spec/unit/resource/template_spec.rb +56 -61
  245. data/spec/unit/resource/user_spec.rb +47 -53
  246. data/spec/unit/resource/windows_package_spec.rb +1 -1
  247. data/spec/unit/resource/windows_path_spec.rb +11 -8
  248. data/spec/unit/resource/windows_task_spec.rb +129 -33
  249. data/spec/unit/resource/yum_package_spec.rb +1 -1
  250. data/spec/unit/resource/yum_repository_spec.rb +61 -8
  251. data/spec/unit/resource/zypper_repository_spec.rb +17 -18
  252. data/spec/unit/util/selinux_spec.rb +3 -6
  253. data/tasks/dependencies.rb +0 -5
  254. data/tasks/rspec.rb +1 -1
  255. metadata +6 -6
  256. data/acceptance/top-cookbooks/.kitchen.docker.yml +0 -13
  257. data/acceptance/top-cookbooks/.kitchen.git.yml +0 -11
@@ -23,7 +23,7 @@ require "chef/version_string"
23
23
 
24
24
  class Chef
25
25
  CHEF_ROOT = File.expand_path("../..", __FILE__)
26
- VERSION = Chef::VersionString.new("13.6.4")
26
+ VERSION = Chef::VersionString.new("13.7.16")
27
27
  end
28
28
 
29
29
  #
@@ -16,6 +16,24 @@
16
16
 
17
17
  require "chef/version_class"
18
18
 
19
+ # NOTE: this is fairly badly broken for its purpose and should not be used
20
+ # unless it gets fixed.
21
+
22
+ # this strictly wants x, x.y, or x.y.z version constraints in the target and
23
+ # will fail hard if it does not match. the semantics that we need here is that
24
+ # it must always do the best job that it can do and consume as much of the
25
+ # offered version as it can. since we accept arbitrarily parsed strings into
26
+ # node[:platform_version] out of dozens or potentially hundreds of operating
27
+ # systems this parsing code needs to be fixed to never raise. the Gem::Version
28
+ # class is a better model, and in fact it might be a substantially better approach
29
+ # to base this class on Gem::Version and then do pre-mangling of things like windows
30
+ # version strings via e.g. `.gsub(/R/, '.')`. the raising behavior of this parser
31
+ # however, breaks the ProviderResolver in a not just buggy but a "completely unfit
32
+ # for purpose" way.
33
+ #
34
+ # TL;DR: MUST follow the second part of "Be conservative in what you send,
35
+ # be liberal in what you accept"
36
+ #
19
37
  class Chef
20
38
  class Version
21
39
  class Platform < Chef::Version
@@ -16,6 +16,8 @@
16
16
  require "chef/version_constraint"
17
17
  require "chef/version/platform"
18
18
 
19
+ # NOTE: this is fairly badly broken for its purpose and should not be used
20
+ # unless it gets fixed. see chef/version/platform.
19
21
  class Chef
20
22
  class VersionConstraint
21
23
  class Platform < Chef::VersionConstraint
@@ -0,0 +1,2 @@
1
+ # 02-strings.rb
2
+ something '/foo/bar'
@@ -1,15 +1,17 @@
1
1
  #!/bin/ksh
2
2
 
3
+ TMPDIR="${TMPDIR:-/tmp}"
4
+
3
5
  function create_chef_txt {
4
- touch /tmp/chefinittest.txt
6
+ touch $TMPDIR/chefinittest.txt
5
7
  }
6
8
 
7
9
  function delete_chef_txt {
8
- rm /tmp/chefinittest.txt
10
+ rm $TMPDIR/chefinittest.txt
9
11
  }
10
12
 
11
13
  function rename_chef_txt {
12
- mv /tmp/chefinittest.txt /tmp/$1
14
+ mv $TMPDIR/chefinittest.txt $TMPDIR/$1
13
15
  }
14
16
 
15
17
  case "$1" in
@@ -20,7 +22,7 @@ stop )
20
22
  delete_chef_txt
21
23
  ;;
22
24
  status )
23
- [ -f /tmp/chefinittest.txt ] || [ -f /tmp/chefinittest_reload.txt ] || [ -f /tmp/chefinittest_restart.txt ]
25
+ [ -f $TMPDIR/chefinittest.txt ] || [ -f $TMPDIR/chefinittest_reload.txt ] || [ -f $TMPDIR/chefinittest_restart.txt ]
24
26
  ;;
25
27
  reload )
26
28
  rename_chef_txt "chefinittest_reload.txt"
@@ -181,11 +181,11 @@ describe Chef::Knife::Ssh do
181
181
 
182
182
  it "uses the ssh_attribute" do
183
183
  @knife.run
184
- expect(@knife.get_ssh_attribute({ "knife_config" => "ec2.public_hostname" })).to eq("ec2.public_hostname")
184
+ expect(@knife.get_ssh_attribute({ "target" => "ec2.public_hostname" })).to eq("ec2.public_hostname")
185
185
  end
186
186
  end
187
187
 
188
- context "when knife[:ssh_attribute] is not provided]" do
188
+ context "when knife[:ssh_attribute] is not provided" do
189
189
  before do
190
190
  setup_knife(["*:*", "uptime"])
191
191
  Chef::Config[:knife][:ssh_attribute] = nil
@@ -199,22 +199,69 @@ describe Chef::Knife::Ssh do
199
199
 
200
200
  context "when -a ec2.public_public_hostname is provided" do
201
201
  before do
202
- setup_knife(["-a ec2.public_hostname", "*:*", "uptime"])
202
+ setup_knife(["-a", "ec2.public_hostname", "*:*", "uptime"])
203
203
  Chef::Config[:knife][:ssh_attribute] = nil
204
204
  end
205
205
 
206
206
  it "should use the value on the command line" do
207
207
  @knife.run
208
- expect(@knife.config[:attribute]).to eq("ec2.public_hostname")
208
+ expect(@knife.config[:ssh_attribute]).to eq("ec2.public_hostname")
209
209
  end
210
210
 
211
211
  it "should override what is set in knife.rb" do
212
212
  # This is the setting imported from knife.rb
213
213
  Chef::Config[:knife][:ssh_attribute] = "fqdn"
214
214
  # Then we run knife with the -a flag, which sets the above variable
215
- setup_knife(["-a ec2.public_hostname", "*:*", "uptime"])
215
+ setup_knife(["-a", "ec2.public_hostname", "*:*", "uptime"])
216
216
  @knife.run
217
- expect(@knife.config[:attribute]).to eq("ec2.public_hostname")
217
+ expect(@knife.config[:ssh_attribute]).to eq("ec2.public_hostname")
218
+ end
219
+ end
220
+ end
221
+
222
+ describe "prefix" do
223
+ context "when knife[:prefix_attribute] is set" do
224
+ before do
225
+ setup_knife(["*:*", "uptime"])
226
+ Chef::Config[:knife][:prefix_attribute] = "name"
227
+ end
228
+
229
+ it "uses the prefix_attribute" do
230
+ @knife.run
231
+ expect(@knife.get_prefix_attribute({ "prefix" => "name" })).to eq("name")
232
+ end
233
+ end
234
+
235
+ context "when knife[:prefix_attribute] is not provided" do
236
+ before do
237
+ setup_knife(["*:*", "uptime"])
238
+ Chef::Config[:knife][:prefix_attribute] = nil
239
+ end
240
+
241
+ it "falls back to nil" do
242
+ @knife.run
243
+ expect(@knife.get_prefix_attribute({})).to eq(nil)
244
+ end
245
+ end
246
+
247
+ context "when --prefix-attribute ec2.public_public_hostname is provided" do
248
+ before do
249
+ setup_knife(["--prefix-attribute", "ec2.public_hostname", "*:*", "uptime"])
250
+ Chef::Config[:knife][:prefix_attribute] = nil
251
+ end
252
+
253
+ it "should use the value on the command line" do
254
+ @knife.run
255
+ expect(@knife.config[:prefix_attribute]).to eq("ec2.public_hostname")
256
+ end
257
+
258
+ it "should override what is set in knife.rb" do
259
+ # This is the setting imported from knife.rb
260
+ Chef::Config[:knife][:prefix_attribute] = "fqdn"
261
+ # Then we run knife with the -b flag, which sets the above variable
262
+ setup_knife(["--prefix-attribute", "ec2.public_hostname", "*:*", "uptime"])
263
+ @knife.run
264
+ expect(@knife.config[:prefix_attribute]).to eq("ec2.public_hostname")
218
265
  end
219
266
  end
220
267
  end
@@ -305,7 +352,7 @@ describe Chef::Knife::Ssh do
305
352
  Chef::Config[:chef_server_url] = "http://localhost:9000"
306
353
 
307
354
  @api.post("/search/node?q=*:*&start=0&rows=1000", 200) do
308
- %({"total":1, "start":0, "rows":[{"data": {"fqdn":"the.fqdn", "config": "the_public_hostname", "knife_config": "the_public_hostname" }}]})
355
+ %({"total":1, "start":0, "rows":[{"data": {"fqdn":"the.fqdn", "target": "the_public_hostname"}}]})
309
356
  end
310
357
  end
311
358
 
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Prabhu Das (<prabhu.das@clogeny.com>)
3
- # Copyright:: Copyright 2013-2016, Chef Software Inc.
3
+ # Copyright:: Copyright 2013-2017, Chef Software Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -62,7 +62,7 @@ describe Chef::Resource::BffPackage, :requires_root, :external => ohai[:platform
62
62
 
63
63
  context "package install action with options" do
64
64
  it "should install a package" do
65
- new_resource.options("-e/tmp/installp.log")
65
+ new_resource.options("-e#{Dir.tmpdir}/installp.log")
66
66
  new_resource.run_action(:install)
67
67
  bff_pkg_should_be_installed(new_resource)
68
68
  end
@@ -108,7 +108,7 @@ describe Chef::Resource::BffPackage, :requires_root, :external => ohai[:platform
108
108
  end
109
109
 
110
110
  it "should remove an installed package" do
111
- new_resource.options("-e/tmp/installp.log")
111
+ new_resource.options("-e#{Dir.tmpdir}/installp.log")
112
112
  new_resource.run_action(:remove)
113
113
  bff_pkg_should_be_removed(new_resource)
114
114
  end
@@ -20,7 +20,7 @@ require "functional/resource/base"
20
20
  require "chef/mixin/shell_out"
21
21
 
22
22
  # run this test only for following platforms.
23
- include_flag = !(%w{ubuntu centos aix}.include?(ohai[:platform]))
23
+ include_flag = !(%w{amazon debian aix}.include?(ohai[:platform_family]) || (ohai[:platform_family] == "rhel" && ohai[:platform_version].to_i < 7))
24
24
 
25
25
  describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => include_flag do
26
26
  # This test does not work in travis because there is no eth0
@@ -22,7 +22,7 @@ require "chef/mixin/shell_out"
22
22
  require "tmpdir"
23
23
 
24
24
  # run this test only for following platforms.
25
- include_flag = !(%w{ubuntu centos aix solaris2}.include?(ohai[:platform]))
25
+ include_flag = !(%w{debian rhel amazon aix solaris2}.include?(ohai[:platform_family]))
26
26
 
27
27
  describe Chef::Resource::Mount, :requires_root, :skip_travis, :external => include_flag do
28
28
  # Disabled in travis because it refuses to let us mount a ramdisk. /dev/ramX does not
@@ -35,15 +35,19 @@ describe Chef::Resource::Mount, :requires_root, :skip_travis, :external => inclu
35
35
  def setup_device_for_mount
36
36
  # use ramdisk for creating a test device for mount.
37
37
  # This can cleaner if we have chef resource/provider for ramdisk.
38
- case ohai[:platform]
38
+ case ohai[:platform_family]
39
39
  when "aix"
40
40
  # On AIX, we can't create a ramdisk inside a WPAR, so we use
41
41
  # a "namefs" mount against / to test
42
42
  # https://www-304.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.performance/namefs_file_sys.htm
43
43
  device = "/"
44
44
  fstype = "namefs"
45
- when "ubuntu", "centos"
45
+ when "debian", "rhel", "amazon"
46
46
  device = "/dev/ram1"
47
+ unless File.exist?(device)
48
+ shell_out("mknod -m 660 #{device} b 1 0")
49
+ shell_out("chown root:disk #{device}")
50
+ end
47
51
  shell_out("ls -1 /dev/ram*").stdout.each_line do |d|
48
52
  if shell_out("mount | grep #{d}").exitstatus == "1"
49
53
  # this device is not mounted, so use it.
@@ -646,10 +646,10 @@ describe Chef::Provider::User::Useradd, metadata do
646
646
  expect(@error.message).to include("Cannot unlock the password")
647
647
  end
648
648
  elsif %w{rhel}.include?(OHAI_SYSTEM["platform_family"]) &&
649
- OHAI_SYSTEM["platform_version"].to_f == 6.8
650
- # usermod -U returns following message for rhel68 on s390x platforms
651
- # usermod: unlocking the user's password would result in a passwordless account.
652
- #You should set a password with usermod -p to unlock this user's password.
649
+ (Chef::VersionConstraint.new("~> 6.8").include?(OHAI_SYSTEM["platform_version"].to_f) || Chef::VersionConstraint.new("~> 7.3").include?(OHAI_SYSTEM["platform_version"].to_f))
650
+ # RHEL 6.8 and 7.3 ship with a fixed `usermod` command
651
+ # Reference: https://access.redhat.com/errata/RHBA-2016:0864
652
+ # Reference: https://access.redhat.com/errata/RHBA-2016:2322
653
653
  it "errors out trying to unlock the user" do
654
654
  expect(@error).to be_a(Mixlib::ShellOut::ShellCommandFailed)
655
655
  expect(@error.message).to include("You should set a password")
@@ -308,7 +308,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
308
308
  it "raises error if invalid random_delay is passed" do
309
309
  subject.frequency :minute
310
310
  subject.random_delay "abc"
311
- expect { subject.after_created }.to raise_error("Invalid value passed for `random_delay`. Please pass seconds as a String e.g. '60'.")
311
+ expect { subject.after_created }.to raise_error("Invalid value passed for `random_delay`. Please pass seconds as an Integer (e.g. 60) or a String with numeric values only (e.g. '60').")
312
312
  end
313
313
 
314
314
  it "raises error if random_delay is passed with frequency on_idle" do
@@ -339,7 +339,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
339
339
  it "raises error" do
340
340
  subject.user "Administrator"
341
341
  subject.frequency :onstart
342
- expect { subject.after_created }.to raise_error("Can't specify a non-system user without a password!")
342
+ expect { subject.after_created }.to raise_error(%q{Cannot specify a user other than the system users without specifying a password!. Valid passwordless users: 'NT AUTHORITY\SYSTEM', 'SYSTEM', 'NT AUTHORITY\LOCALSERVICE', 'NT AUTHORITY\NETWORKSERVICE', 'BUILTIN\USERS', 'USERS'})
343
343
  end
344
344
  end
345
345
 
@@ -355,7 +355,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
355
355
  it "raises error" do
356
356
  subject.frequency_modifier 1450
357
357
  subject.frequency :minute
358
- expect { subject.after_created }.to raise_error("frequency_modifier value 1450 is invalid. Valid values for :minute frequency are 1 - 1439.")
358
+ expect { subject.after_created }.to raise_error("frequency_modifier value 1450 is invalid. Valid values for :minute frequency are 1 - 1439.")
359
359
  end
360
360
  end
361
361
 
@@ -363,7 +363,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
363
363
  it "raises error" do
364
364
  subject.months "xyz"
365
365
  subject.frequency :monthly
366
- expect { subject.after_created }.to raise_error("months attribute invalid. Only valid values are: JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC and *. Multiple values must be separated by a comma.")
366
+ expect { subject.after_created }.to raise_error("months property invalid. Only valid values are: JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC and *. Multiple values must be separated by a comma.")
367
367
  end
368
368
  end
369
369
 
@@ -371,7 +371,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
371
371
  it "raises error" do
372
372
  subject.idle_time 1000
373
373
  subject.frequency :on_idle
374
- expect { subject.after_created }.to raise_error("idle_time value 1000 is invalid. Valid values for :on_idle frequency are 1 - 999.")
374
+ expect { subject.after_created }.to raise_error("idle_time value 1000 is invalid. Valid values for :on_idle frequency are 1 - 999.")
375
375
  end
376
376
  end
377
377
 
@@ -379,7 +379,7 @@ describe Chef::Resource::WindowsTask, :windows_only do
379
379
  it "raises error" do
380
380
  subject.idle_time 300
381
381
  subject.frequency :monthly
382
- expect { subject.after_created }.to raise_error("idle_time attribute is only valid for tasks that run on_idle")
382
+ expect { subject.after_created }.to raise_error("idle_time property is only valid for tasks that run on_idle")
383
383
  end
384
384
  end
385
385
  end
@@ -17,8 +17,6 @@
17
17
  #
18
18
 
19
19
  require "spec_helper"
20
- require "mixlib/shellout"
21
- require "chef/mixin/user_context"
22
20
  if Chef::Platform.windows?
23
21
  require "chef/win32/security"
24
22
  end
@@ -28,37 +26,13 @@ describe "Chef::Win32::Security", :windows_only do
28
26
  expect(Chef::ReservedNames::Win32::Security.has_admin_privileges?).to eq(true)
29
27
  end
30
28
 
31
- describe "running as non admin user" do
32
- include Chef::Mixin::UserContext
33
- let(:user) { "security_user" }
34
- let(:password) { "Security@123" }
35
-
36
- let(:domain) do
37
- whoami = Mixlib::ShellOut.new("whoami")
38
- whoami.run_command
39
- whoami.error!
40
- whoami.stdout.split("\\")[0]
41
- end
42
- before do
43
- allow_any_instance_of(Chef::Mixin::UserContext).to receive(:node).and_return({ "platform_family" => "windows" })
44
- allow(Chef::Platform).to receive(:windows_server_2003?).and_return(false)
45
- allow(Chef::ReservedNames::Win32::Security).to receive(:OpenProcessToken).and_return(true)
46
- add_user = Mixlib::ShellOut.new("net user #{user} #{password} /ADD")
47
- add_user.run_command
48
- add_user.error!
49
- end
50
-
51
- after do
52
- delete_user = Mixlib::ShellOut.new("net user #{user} /delete")
53
- delete_user.run_command
54
- delete_user.error!
55
- end
56
- it "has_admin_privileges? returns false" do
57
- has_admin_privileges = with_user_context(user, password, domain) do
58
- Chef::ReservedNames::Win32::Security.has_admin_privileges?
59
- end
60
- expect(has_admin_privileges).to eq(false)
61
- end
29
+ # We've done some investigation adding a negative test and it turned
30
+ # out to be a lot of work since mixlib-shellout doesn't have user
31
+ # support for windows.
32
+ #
33
+ # TODO - Add negative tests once mixlib-shellout has user support
34
+ it "has_admin_privileges? returns false when running as non-admin" do
35
+ skip "requires user support in mixlib-shellout"
62
36
  end
63
37
 
64
38
  describe "get_file_security" do
@@ -44,7 +44,7 @@ EOM
44
44
  end
45
45
 
46
46
  it "with a single item" do
47
- knife("data bag show rocket falcon9").should_succeed <<EOM, stderr: "WARNING: Unencrypted data bag detected, ignoring any provided secret options.\n"
47
+ knife("data bag show rocket falcon9").should_succeed <<EOM
48
48
  heavy: true
49
49
  id: falcon9
50
50
  EOM
@@ -4,7 +4,7 @@ describe "Resources with a no-op provider" do
4
4
  include IntegrationSupport
5
5
 
6
6
  context "with noop provider providing foo" do
7
- before(:context) do
7
+ before(:each) do
8
8
  class NoOpFoo < Chef::Resource
9
9
  resource_name "hi_there"
10
10
  default_action :update
@@ -12,7 +12,7 @@ describe "Recipe DSL methods" do
12
12
  before { Namer.current_index += 1 }
13
13
 
14
14
  context "with resource 'base_thingy' declared as BaseThingy" do
15
- before(:context) do
15
+ before(:each) do
16
16
 
17
17
  class BaseThingy < Chef::Resource
18
18
  resource_name "base_thingy"
@@ -66,7 +66,7 @@ describe "Recipe DSL methods" do
66
66
  end
67
67
 
68
68
  context "nameless resources" do
69
- before(:context) do
69
+ before(:each) do
70
70
  class NamelessThingy < BaseThingy
71
71
  resource_name :nameless_thingy
72
72
  provides :nameless_thingy
@@ -91,7 +91,7 @@ describe "Recipe DSL methods" do
91
91
  end
92
92
 
93
93
  context "with a resource named RecipeDSLSpecNamespace::Bar::BarThingy" do
94
- before(:context) do
94
+ before(:each) do
95
95
 
96
96
  class RecipeDSLSpecNamespace::Bar::BarThingy < BaseThingy
97
97
  end
@@ -106,7 +106,7 @@ describe "Recipe DSL methods" do
106
106
  end
107
107
 
108
108
  context "with a resource named Chef::Resource::NoNameThingy with resource_name nil" do
109
- before(:context) do
109
+ before(:each) do
110
110
 
111
111
  class Chef::Resource::NoNameThingy < BaseThingy
112
112
  resource_name nil
@@ -122,7 +122,7 @@ describe "Recipe DSL methods" do
122
122
  end
123
123
 
124
124
  context "with a resource named AnotherNoNameThingy with resource_name :another_thingy_name" do
125
- before(:context) do
125
+ before(:each) do
126
126
 
127
127
  class AnotherNoNameThingy < BaseThingy
128
128
  resource_name :another_thingy_name
@@ -146,7 +146,7 @@ describe "Recipe DSL methods" do
146
146
  end
147
147
 
148
148
  context "with a resource named AnotherNoNameThingy2 with resource_name :another_thingy_name2; resource_name :another_thingy_name3" do
149
- before(:context) do
149
+ before(:each) do
150
150
 
151
151
  class AnotherNoNameThingy2 < BaseThingy
152
152
  resource_name :another_thingy_name2
@@ -178,7 +178,7 @@ describe "Recipe DSL methods" do
178
178
 
179
179
  context "provides overriding resource_name" do
180
180
  context "with a resource named AnotherNoNameThingy3 with provides :another_no_name_thingy3, os: 'blarghle'" do
181
- before(:context) do
181
+ before(:each) do
182
182
 
183
183
  class AnotherNoNameThingy3 < BaseThingy
184
184
  resource_name :another_no_name_thingy_3
@@ -207,7 +207,7 @@ describe "Recipe DSL methods" do
207
207
  end
208
208
 
209
209
  context "with a resource named AnotherNoNameThingy4 with two provides" do
210
- before(:context) do
210
+ before(:each) do
211
211
 
212
212
  class AnotherNoNameThingy4 < BaseThingy
213
213
  resource_name :another_no_name_thingy_4
@@ -247,7 +247,7 @@ describe "Recipe DSL methods" do
247
247
  end
248
248
 
249
249
  context "with a resource named AnotherNoNameThingy5, a different resource_name, and a provides with the original resource_name" do
250
- before(:context) do
250
+ before(:each) do
251
251
 
252
252
  class AnotherNoNameThingy5 < BaseThingy
253
253
  resource_name :another_thingy_name_for_another_no_name_thingy5
@@ -284,7 +284,7 @@ describe "Recipe DSL methods" do
284
284
  end
285
285
 
286
286
  context "with a resource named AnotherNoNameThingy6, a provides with the original resource name, and a different resource_name" do
287
- before(:context) do
287
+ before(:each) do
288
288
 
289
289
  class AnotherNoNameThingy6 < BaseThingy
290
290
  provides :another_no_name_thingy6, os: "blarghle"
@@ -321,7 +321,7 @@ describe "Recipe DSL methods" do
321
321
  end
322
322
 
323
323
  context "with a resource named AnotherNoNameThingy7, a new resource_name, and provides with that new resource name" do
324
- before(:context) do
324
+ before(:each) do
325
325
 
326
326
  class AnotherNoNameThingy7 < BaseThingy
327
327
  resource_name :another_thingy_name_for_another_no_name_thingy7
@@ -359,7 +359,7 @@ describe "Recipe DSL methods" do
359
359
 
360
360
  # opposite order from the previous test (provides, then resource_name)
361
361
  context "with a resource named AnotherNoNameThingy8, a provides with a new resource name, and resource_name with that new resource name" do
362
- before(:context) do
362
+ before(:each) do
363
363
 
364
364
  class AnotherNoNameThingy8 < BaseThingy
365
365
  provides :another_thingy_name_for_another_no_name_thingy8, os: "blarghle"
@@ -399,7 +399,7 @@ describe "Recipe DSL methods" do
399
399
 
400
400
  context "provides" do
401
401
  context "when MySupplier provides :hemlock" do
402
- before(:context) do
402
+ before(:each) do
403
403
 
404
404
  class RecipeDSLSpecNamespace::MySupplier < BaseThingy
405
405
  resource_name :hemlock
@@ -422,7 +422,7 @@ describe "Recipe DSL methods" do
422
422
  end
423
423
 
424
424
  context "when Thingy3 has resource_name :thingy3" do
425
- before(:context) do
425
+ before(:each) do
426
426
 
427
427
  class RecipeDSLSpecNamespace::Thingy3 < BaseThingy
428
428
  resource_name :thingy3
@@ -438,7 +438,7 @@ describe "Recipe DSL methods" do
438
438
  end
439
439
 
440
440
  context "and Thingy4 has resource_name :thingy3" do
441
- before(:context) do
441
+ before(:each) do
442
442
 
443
443
  class RecipeDSLSpecNamespace::Thingy4 < BaseThingy
444
444
  resource_name :thingy3
@@ -466,7 +466,7 @@ describe "Recipe DSL methods" do
466
466
  end
467
467
 
468
468
  context "when Thingy5 has resource_name :thingy5 and provides :thingy5reverse, :thingy5_2 and :thingy5_2reverse" do
469
- before(:context) do
469
+ before(:each) do
470
470
 
471
471
  class RecipeDSLSpecNamespace::Thingy5 < BaseThingy
472
472
  resource_name :thingy5
@@ -485,7 +485,7 @@ describe "Recipe DSL methods" do
485
485
  end
486
486
 
487
487
  context "and Thingy6 provides :thingy5" do
488
- before(:context) do
488
+ before(:each) do
489
489
 
490
490
  class RecipeDSLSpecNamespace::Thingy6 < BaseThingy
491
491
  resource_name :thingy6
@@ -513,7 +513,7 @@ describe "Recipe DSL methods" do
513
513
  end
514
514
 
515
515
  context "and AThingy5 provides :thingy5reverse" do
516
- before(:context) do
516
+ before(:each) do
517
517
 
518
518
  class RecipeDSLSpecNamespace::AThingy5 < BaseThingy
519
519
  resource_name :thingy5reverse
@@ -530,7 +530,7 @@ describe "Recipe DSL methods" do
530
530
  end
531
531
 
532
532
  context "and ZRecipeDSLSpecNamespace::Thingy5 provides :thingy5_2" do
533
- before(:context) do
533
+ before(:each) do
534
534
 
535
535
  module ZRecipeDSLSpecNamespace
536
536
  class Thingy5 < BaseThingy
@@ -549,7 +549,7 @@ describe "Recipe DSL methods" do
549
549
  end
550
550
 
551
551
  context "and ARecipeDSLSpecNamespace::Thingy5 provides :thingy5_2" do
552
- before(:context) do
552
+ before(:each) do
553
553
 
554
554
  module ARecipeDSLSpecNamespace
555
555
  class Thingy5 < BaseThingy
@@ -569,7 +569,7 @@ describe "Recipe DSL methods" do
569
569
  end
570
570
 
571
571
  context "when Thingy3 has resource_name :thingy3" do
572
- before(:context) do
572
+ before(:each) do
573
573
 
574
574
  class RecipeDSLSpecNamespace::Thingy3 < BaseThingy
575
575
  resource_name :thingy3
@@ -585,7 +585,7 @@ describe "Recipe DSL methods" do
585
585
  end
586
586
 
587
587
  context "and Thingy4 has resource_name :thingy3" do
588
- before(:context) do
588
+ before(:each) do
589
589
 
590
590
  class RecipeDSLSpecNamespace::Thingy4 < BaseThingy
591
591
  resource_name :thingy3
@@ -612,7 +612,7 @@ describe "Recipe DSL methods" do
612
612
  end
613
613
 
614
614
  context "and Thingy4 has resource_name :thingy3" do
615
- before(:context) do
615
+ before(:each) do
616
616
 
617
617
  class RecipeDSLSpecNamespace::Thingy4 < BaseThingy
618
618
  resource_name :thingy3
@@ -642,7 +642,7 @@ describe "Recipe DSL methods" do
642
642
  end
643
643
 
644
644
  context "when Thingy7 provides :thingy8" do
645
- before(:context) do
645
+ before(:each) do
646
646
 
647
647
  class RecipeDSLSpecNamespace::Thingy7 < BaseThingy
648
648
  resource_name :thingy7
@@ -652,7 +652,7 @@ describe "Recipe DSL methods" do
652
652
  end
653
653
 
654
654
  context "and Thingy8 has resource_name :thingy8" do
655
- before(:context) do
655
+ before(:each) do
656
656
 
657
657
  class RecipeDSLSpecNamespace::Thingy8 < BaseThingy
658
658
  resource_name :thingy8
@@ -681,7 +681,7 @@ describe "Recipe DSL methods" do
681
681
  end
682
682
 
683
683
  context "when Thingy12 provides :thingy12, :twizzle and :twizzle2" do
684
- before(:context) do
684
+ before(:each) do
685
685
 
686
686
  class RecipeDSLSpecNamespace::Thingy12 < BaseThingy
687
687
  resource_name :thingy12
@@ -714,7 +714,7 @@ describe "Recipe DSL methods" do
714
714
  end
715
715
 
716
716
  context "with platform-specific resources 'my_super_thingy_foo' and 'my_super_thingy_bar'" do
717
- before(:context) do
717
+ before(:each) do
718
718
  class MySuperThingyFoo < BaseThingy
719
719
  resource_name :my_super_thingy_foo
720
720
  provides :my_super_thingy, platform: "foo"
@@ -760,7 +760,7 @@ describe "Recipe DSL methods" do
760
760
  end
761
761
 
762
762
  context "when Thingy10 provides :thingy10" do
763
- before(:context) do
763
+ before(:each) do
764
764
  class RecipeDSLSpecNamespace::Thingy10 < BaseThingy
765
765
  resource_name :thingy10
766
766
  end
@@ -775,7 +775,7 @@ describe "Recipe DSL methods" do
775
775
  end
776
776
 
777
777
  context "when Thingy11 provides :thingy11" do
778
- before(:context) do
778
+ before(:each) do
779
779
  class RecipeDSLSpecNamespace::Thingy11 < BaseThingy
780
780
  resource_name :thingy10
781
781
  end
@@ -1309,7 +1309,7 @@ describe "Recipe DSL methods" do
1309
1309
  end
1310
1310
 
1311
1311
  context "with UTF-8 provides" do
1312
- before(:context) do
1312
+ before(:each) do
1313
1313
  class UTF8Thingy < BaseThingy
1314
1314
  resource_name :Straße
1315
1315
  provides :Straße