chef 12.5.1-universal-mingw32 → 12.6.0-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -1
  3. data/README.md +6 -4
  4. data/Rakefile +1 -4
  5. data/chef-windows.gemspec +21 -0
  6. data/chef.gemspec +58 -0
  7. data/lib/chef/api_client/registration.rb +9 -4
  8. data/lib/chef/application.rb +3 -84
  9. data/lib/chef/application/apply.rb +9 -2
  10. data/lib/chef/application/client.rb +8 -3
  11. data/lib/chef/application/solo.rb +7 -1
  12. data/lib/chef/application/windows_service.rb +21 -6
  13. data/lib/chef/application/windows_service_manager.rb +2 -3
  14. data/lib/chef/audit/runner.rb +1 -0
  15. data/lib/chef/chef_class.rb +1 -11
  16. data/lib/chef/chef_fs/chef_fs_data_store.rb +181 -2
  17. data/lib/chef/chef_fs/file_system/cookbook_subdir.rb +5 -0
  18. data/lib/chef/chef_fs/file_system/file_system_entry.rb +11 -7
  19. data/lib/chef/client.rb +28 -1
  20. data/lib/chef/cookbook/cookbook_collection.rb +14 -1
  21. data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
  22. data/lib/chef/cookbook/metadata.rb +115 -9
  23. data/lib/chef/cookbook/remote_file_vendor.rb +1 -1
  24. data/lib/chef/cookbook_version.rb +6 -2
  25. data/lib/chef/data_bag.rb +1 -1
  26. data/lib/chef/data_bag_item.rb +1 -1
  27. data/lib/chef/digester.rb +5 -1
  28. data/lib/chef/dsl/chef_provisioning.rb +57 -0
  29. data/lib/chef/dsl/cheffish.rb +64 -0
  30. data/lib/chef/dsl/declare_resource.rb +108 -0
  31. data/lib/chef/dsl/platform_introspection.rb +3 -3
  32. data/lib/chef/dsl/recipe.rb +3 -73
  33. data/lib/chef/dsl/resources.rb +27 -1
  34. data/lib/chef/event_dispatch/base.rb +3 -0
  35. data/lib/chef/event_dispatch/dispatcher.rb +5 -0
  36. data/lib/chef/event_dispatch/events_output_stream.rb +8 -0
  37. data/lib/chef/exceptions.rb +21 -1
  38. data/lib/chef/file_access_control/unix.rb +12 -12
  39. data/lib/chef/file_content_management/deploy/cp.rb +2 -2
  40. data/lib/chef/file_content_management/deploy/mv_unix.rb +4 -4
  41. data/lib/chef/file_content_management/deploy/mv_windows.rb +1 -1
  42. data/lib/chef/formatters/base.rb +7 -0
  43. data/lib/chef/formatters/error_inspectors/compile_error_inspector.rb +2 -2
  44. data/lib/chef/formatters/indentable_output_stream.rb +5 -0
  45. data/lib/chef/http.rb +19 -3
  46. data/lib/chef/http/decompressor.rb +2 -2
  47. data/lib/chef/json_compat.rb +1 -0
  48. data/lib/chef/knife.rb +16 -2
  49. data/lib/chef/knife/bootstrap.rb +55 -10
  50. data/lib/chef/knife/cookbook_site_install.rb +5 -1
  51. data/lib/chef/knife/core/bootstrap_context.rb +2 -1
  52. data/lib/chef/knife/core/node_presenter.rb +1 -1
  53. data/lib/chef/knife/ssh.rb +30 -16
  54. data/lib/chef/knife/ssl_check.rb +4 -2
  55. data/lib/chef/knife/ssl_fetch.rb +3 -2
  56. data/lib/chef/knife/status.rb +14 -1
  57. data/lib/chef/log.rb +14 -0
  58. data/lib/chef/mixin/get_source_from_package.rb +7 -2
  59. data/lib/chef/mixin/properties.rb +302 -0
  60. data/lib/chef/mixin/proxified_socket.rb +38 -0
  61. data/lib/chef/mixin/subclass_directive.rb +37 -0
  62. data/lib/chef/node.rb +13 -5
  63. data/lib/chef/platform/query_helpers.rb +14 -3
  64. data/lib/chef/platform/service_helpers.rb +20 -38
  65. data/lib/chef/policy_builder/expand_node_object.rb +3 -0
  66. data/lib/chef/policy_builder/policyfile.rb +1 -0
  67. data/lib/chef/property.rb +51 -12
  68. data/lib/chef/provider.rb +40 -35
  69. data/lib/chef/provider/deploy.rb +1 -1
  70. data/lib/chef/provider/dsc_resource.rb +54 -20
  71. data/lib/chef/provider/execute.rb +25 -4
  72. data/lib/chef/provider/group.rb +1 -1
  73. data/lib/chef/provider/lwrp_base.rb +1 -0
  74. data/lib/chef/provider/package.rb +76 -30
  75. data/lib/chef/provider/package/dpkg.rb +152 -69
  76. data/lib/chef/provider/package/openbsd.rb +6 -8
  77. data/lib/chef/provider/package/solaris.rb +2 -0
  78. data/lib/chef/provider/package/windows.rb +95 -14
  79. data/lib/chef/provider/package/windows/exe.rb +129 -0
  80. data/lib/chef/provider/package/windows/msi.rb +37 -13
  81. data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +89 -0
  82. data/lib/chef/provider/package/yum.rb +13 -3
  83. data/lib/chef/provider/powershell_script.rb +3 -0
  84. data/lib/chef/provider/remote_file/cache_control_data.rb +37 -4
  85. data/lib/chef/provider/remote_file/http.rb +1 -1
  86. data/lib/chef/provider/script.rb +1 -0
  87. data/lib/chef/provider/service.rb +13 -10
  88. data/lib/chef/provider/service/solaris.rb +43 -17
  89. data/lib/chef/provider/service/upstart.rb +3 -3
  90. data/lib/chef/provider/user.rb +1 -1
  91. data/lib/chef/provider/user/dscl.rb +111 -100
  92. data/lib/chef/provider/user/windows.rb +5 -3
  93. data/lib/chef/recipe.rb +3 -5
  94. data/lib/chef/resource.rb +77 -320
  95. data/lib/chef/resource/action_class.rb +4 -0
  96. data/lib/chef/resource/dpkg_package.rb +4 -3
  97. data/lib/chef/resource/dsc_resource.rb +40 -2
  98. data/lib/chef/resource/execute.rb +9 -1
  99. data/lib/chef/resource/ksh.rb +32 -0
  100. data/lib/chef/resource/lwrp_base.rb +6 -10
  101. data/lib/chef/resource/package.rb +8 -9
  102. data/lib/chef/resource/registry_key.rb +1 -1
  103. data/lib/chef/resource/resource_notification.rb +14 -1
  104. data/lib/chef/resource/script.rb +1 -1
  105. data/lib/chef/resource/windows_package.rb +1 -1
  106. data/lib/chef/resource_builder.rb +14 -7
  107. data/lib/chef/resource_reporter.rb +6 -0
  108. data/lib/chef/resources.rb +1 -7
  109. data/lib/chef/rest.rb +1 -1
  110. data/lib/chef/run_context.rb +45 -2
  111. data/lib/chef/run_list/run_list_expansion.rb +47 -0
  112. data/lib/chef/runner.rb +25 -0
  113. data/lib/chef/search/query.rb +16 -2
  114. data/lib/chef/util/diff.rb +2 -2
  115. data/lib/chef/util/powershell/ps_credential.rb +2 -3
  116. data/lib/chef/version.rb +1 -1
  117. data/lib/chef/win32/api/file.rb +51 -1
  118. data/lib/chef/win32/file.rb +5 -0
  119. data/lib/chef/win32/file/version_info.rb +93 -0
  120. data/lib/chef/win32/mutex.rb +1 -1
  121. data/spec/data/apt/chef-integration-test2-1.0/debian/changelog +5 -0
  122. data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2.debhelper.log +45 -0
  123. data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2.substvars +1 -0
  124. data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/conffiles +1 -0
  125. data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/control +10 -0
  126. data/spec/data/apt/chef-integration-test2-1.0/debian/chef-integration-test2/DEBIAN/md5sums +1 -0
  127. data/spec/data/apt/chef-integration-test2-1.0/debian/compat +1 -0
  128. data/spec/data/apt/chef-integration-test2-1.0/debian/conffiles +1 -0
  129. data/spec/data/apt/chef-integration-test2-1.0/debian/control +13 -0
  130. data/spec/data/apt/chef-integration-test2-1.0/debian/copyright +34 -0
  131. data/spec/data/apt/chef-integration-test2-1.0/debian/files +1 -0
  132. data/spec/data/apt/chef-integration-test2-1.0/debian/rules +13 -0
  133. data/spec/data/apt/chef-integration-test2-1.0/debian/source/format +1 -0
  134. data/spec/data/apt/chef-integration-test2_1.0-1.debian.tar.gz +0 -0
  135. data/spec/data/apt/chef-integration-test2_1.0-1.dsc +18 -0
  136. data/spec/data/apt/chef-integration-test2_1.0-1_amd64.build +91 -0
  137. data/spec/data/apt/chef-integration-test2_1.0-1_amd64.changes +31 -0
  138. data/spec/data/apt/chef-integration-test2_1.0-1_amd64.deb +0 -0
  139. data/spec/data/apt/chef-integration-test2_1.0.orig.tar.gz +0 -0
  140. data/spec/functional/application_spec.rb +1 -1
  141. data/spec/functional/audit/runner_spec.rb +4 -0
  142. data/spec/functional/knife/ssh_spec.rb +5 -5
  143. data/spec/functional/notifications_spec.rb +74 -4
  144. data/spec/functional/resource/aix_service_spec.rb +2 -2
  145. data/spec/functional/resource/dpkg_package_spec.rb +339 -0
  146. data/spec/functional/resource/ifconfig_spec.rb +3 -1
  147. data/spec/functional/resource/mount_spec.rb +5 -2
  148. data/spec/functional/resource/package_spec.rb +1 -1
  149. data/spec/functional/resource/user/windows_spec.rb +8 -0
  150. data/spec/functional/resource/windows_package_spec.rb +177 -0
  151. data/spec/functional/win32/version_info_spec.rb +50 -0
  152. data/spec/integration/client/client_spec.rb +80 -0
  153. data/spec/integration/knife/download_spec.rb +9 -0
  154. data/spec/integration/knife/upload_spec.rb +28 -1
  155. data/spec/integration/recipes/lwrp_inline_resources_spec.rb +93 -23
  156. data/spec/integration/recipes/resource_action_spec.rb +211 -116
  157. data/spec/integration/recipes/resource_converge_if_changed_spec.rb +72 -0
  158. data/spec/integration/solo/solo_spec.rb +34 -0
  159. data/spec/spec_helper.rb +11 -1
  160. data/spec/support/platform_helpers.rb +8 -0
  161. data/spec/support/shared/integration/integration_helper.rb +6 -0
  162. data/spec/support/shared/unit/execute_resource.rb +5 -0
  163. data/spec/support/shared/unit/platform_introspector.rb +7 -0
  164. data/spec/tiny_server.rb +6 -2
  165. data/spec/unit/api_client/registration_spec.rb +5 -4
  166. data/spec/unit/application_spec.rb +1 -181
  167. data/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb +34 -0
  168. data/spec/unit/cookbook/metadata_spec.rb +122 -2
  169. data/spec/unit/http_spec.rb +102 -0
  170. data/spec/unit/knife/bootstrap_spec.rb +55 -13
  171. data/spec/unit/knife/core/bootstrap_context_spec.rb +10 -3
  172. data/spec/unit/knife/ssl_check_spec.rb +7 -3
  173. data/spec/unit/knife/ssl_fetch_spec.rb +2 -2
  174. data/spec/unit/knife/status_spec.rb +13 -13
  175. data/spec/unit/knife_spec.rb +26 -2
  176. data/spec/unit/lwrp_spec.rb +1 -1
  177. data/spec/unit/mixin/properties_spec.rb +97 -0
  178. data/spec/unit/mixin/proxified_socket_spec.rb +94 -0
  179. data/spec/unit/mixin/subclass_directive_spec.rb +45 -0
  180. data/spec/unit/node_spec.rb +9 -1
  181. data/spec/unit/policy_builder/policyfile_spec.rb +2 -0
  182. data/spec/unit/property/validation_spec.rb +14 -12
  183. data/spec/unit/property_spec.rb +56 -0
  184. data/spec/unit/provider/deploy_spec.rb +1 -1
  185. data/spec/unit/provider/dsc_resource_spec.rb +63 -24
  186. data/spec/unit/provider/execute_spec.rb +95 -28
  187. data/spec/unit/provider/package/dpkg_spec.rb +185 -96
  188. data/spec/unit/provider/package/windows/exe_spec.rb +251 -0
  189. data/spec/unit/provider/package/windows/msi_spec.rb +94 -10
  190. data/spec/unit/provider/package/windows_spec.rb +227 -26
  191. data/spec/unit/provider/package/yum_spec.rb +6 -0
  192. data/spec/unit/provider/package_spec.rb +495 -366
  193. data/spec/unit/provider/remote_file/cache_control_data_spec.rb +62 -36
  194. data/spec/unit/provider/script_spec.rb +2 -2
  195. data/spec/unit/provider/service/solaris_smf_service_spec.rb +110 -39
  196. data/spec/unit/provider/service/upstart_service_spec.rb +19 -0
  197. data/spec/unit/provider/user/dscl_spec.rb +14 -0
  198. data/spec/unit/provider/user/windows_spec.rb +2 -2
  199. data/spec/unit/provider/user_spec.rb +9 -0
  200. data/spec/unit/provider_resolver_spec.rb +6 -30
  201. data/spec/unit/recipe_spec.rb +46 -20
  202. data/spec/unit/resource/chef_gem_spec.rb +1 -1
  203. data/spec/unit/resource/dsc_resource_spec.rb +14 -3
  204. data/spec/unit/resource/ksh_spec.rb +40 -0
  205. data/spec/unit/resource/registry_key_spec.rb +2 -2
  206. data/spec/unit/resource/resource_notification_spec.rb +44 -45
  207. data/spec/unit/resource_reporter_spec.rb +7 -0
  208. data/spec/unit/resource_spec.rb +268 -253
  209. data/spec/unit/rest_spec.rb +2 -2
  210. data/spec/unit/run_list/run_list_expansion_spec.rb +18 -3
  211. data/spec/unit/search/query_spec.rb +19 -1
  212. data/spec/unit/util/powershell/ps_credential_spec.rb +8 -1
  213. data/spec/unit/windows_service_spec.rb +83 -38
  214. data/tasks/external_tests.rb +19 -9
  215. data/tasks/rspec.rb +1 -1
  216. metadata +70 -21
  217. data/spec/support/pedant/Gemfile +0 -3
  218. data/spec/support/pedant/pedant_config.rb +0 -129
  219. data/spec/support/pedant/run_pedant.rb +0 -63
  220. data/spec/support/pedant/stickywicket.pem +0 -27
  221. data/spec/unit/provider/package_spec.rbe +0 -0
@@ -760,6 +760,13 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
760
760
  provider.dscl_create_comment
761
761
  end
762
762
 
763
+ it "sets the comment field to username" do
764
+ new_resource.comment nil
765
+ expect(provider).to receive(:run_dscl).with("create /Users/toor RealName '#mockssuck'").and_return(true)
766
+ provider.dscl_create_comment
767
+ expect(new_resource.comment).to eq("#mockssuck")
768
+ end
769
+
763
770
  it "should run run_dscl with create /Users/user PrimaryGroupID to set the users primary group" do
764
771
  expect(provider).to receive(:run_dscl).with("create /Users/toor PrimaryGroupID '1001'").and_return(true)
765
772
  provider.dscl_set_gid
@@ -789,6 +796,13 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30")
789
796
  expect { provider.dscl_set_gid }.to raise_error(Chef::Exceptions::GroupIDNotFound)
790
797
  end
791
798
  end
799
+
800
+ it "should set group ID to 20 if it's not specified" do
801
+ new_resource.gid nil
802
+ expect(provider).to receive(:run_dscl).with("create /Users/toor PrimaryGroupID '20'").ordered.and_return(true)
803
+ provider.dscl_set_gid
804
+ expect(new_resource.gid).to eq(20)
805
+ end
792
806
  end
793
807
 
794
808
  describe "when the user exists and chef is managing it" do
@@ -107,8 +107,8 @@ describe Chef::Provider::User::Windows do
107
107
  expect(@provider.set_options[:home_dir]).to eq('/home/adam')
108
108
  end
109
109
 
110
- it "marks the primary_group_id attribute to be updated" do
111
- expect(@provider.set_options[:primary_group_id]).to eq(1000)
110
+ it "ignores the primary_group_id attribute" do
111
+ expect(@provider.set_options[:primary_group_id]).to eq(nil)
112
112
  end
113
113
 
114
114
  it "marks the user_id attribute to be updated" do
@@ -452,11 +452,20 @@ describe Chef::Provider::User do
452
452
 
453
453
  it "should raise an error if we can't translate the group name during resource assertions" do
454
454
  expect(Etc).to receive(:getgrnam).and_raise(ArgumentError)
455
+ @provider.action = :create
455
456
  @provider.define_resource_requirements
456
457
  @provider.convert_group_name
457
458
  expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::User)
458
459
  end
459
460
 
461
+ it "does not raise an error if we can't translate the group name during resource assertions if we are removing the user" do
462
+ expect(Etc).to receive(:getgrnam).and_raise(ArgumentError)
463
+ @provider.action = :remove
464
+ @provider.define_resource_requirements
465
+ @provider.convert_group_name
466
+ expect { @provider.process_resource_requirements }.not_to raise_error
467
+ end
468
+
460
469
  it "should set the new resources gid to the integerized version if available" do
461
470
  expect(Etc).to receive(:getgrnam).with("999").and_return(@group)
462
471
  @provider.convert_group_name
@@ -147,25 +147,17 @@ describe Chef::ProviderResolver do
147
147
  services.each do |service|
148
148
  case service
149
149
  when :debian
150
- directory 'usr/sbin/update-rc.d'
150
+ file 'usr/sbin/update-rc.d', ''
151
151
  when :invokercd
152
- directory 'usr/sbin/invoke-rc.d'
152
+ file 'usr/sbin/invoke-rc.d', ''
153
153
  when :insserv
154
- directory 'sbin/insserv'
154
+ file 'sbin/insserv', ''
155
155
  when :upstart
156
- directory 'etc/init'
157
- directory 'sbin/start'
156
+ file 'sbin/initctl', ''
158
157
  when :redhat
159
- directory 'sbin/chkconfig'
158
+ file 'sbin/chkconfig', ''
160
159
  when :systemd
161
- file 'bin/systemctl', ''
162
- # Make systemctl executable
163
- File.chmod(0755, path_to('bin/systemctl'))
164
- # Windows doesn't respect executable bit, do this to let Windows users see if they've broken the resolver
165
- allow(::File).to receive(:executable?) { |p| p == path_to('bin/systemctl') } if windows?
166
160
  file 'proc/1/comm', "systemd\n"
167
- mock_shellout_command("/bin/systemctl --all", stdout: "")
168
- mock_shellout_command("/bin/systemctl list-unit-files", stdout: "")
169
161
  else
170
162
  raise ArgumentError, service
171
163
  end
@@ -186,24 +178,8 @@ describe Chef::ProviderResolver do
186
178
  when :usr_local_etc_rcd
187
179
  file "usr/local/etc/rc.d/#{service_name}", ""
188
180
  when :systemd
189
- file 'bin/systemctl', ''
190
- # Make systemctl executable
191
- File.chmod(0755, path_to("bin/systemctl"))
192
- # Windows doesn't respect executable bit, do this to let Windows users see if they've broken the resolver
193
- allow(::File).to receive(:executable?) { |p| p == path_to('bin/systemctl') } if windows?
194
181
  file 'proc/1/comm', "systemd\n"
195
- mock_shellout_command("/bin/systemctl --all", stdout: <<-EOM)
196
- superv loaded
197
- stinky something-else
198
- #{service_name} loaded
199
- blargh not-found
200
- EOM
201
- mock_shellout_command("/bin/systemctl list-unit-files", stdout: <<-EOM)
202
- usuperv loaded
203
- ustinky something-else
204
- u#{service_name} loaded
205
- ublargh not-found
206
- EOM
182
+ file "etc/systemd/system/#{service_name}.service", ""
207
183
  else
208
184
  raise ArgumentError, config
209
185
  end
@@ -3,7 +3,7 @@
3
3
  # Author:: Christopher Walters (<cw@opscode.com>)
4
4
  # Author:: Tim Hinderliter (<tim@opscode.com>)
5
5
  # Author:: Seth Chisamore (<schisamo@opscode.com>)
6
- # Copyright:: Copyright (c) 2008-2011 Opscode, Inc.
6
+ # Copyright:: Copyright (c) 2008-2015 Chef Software, Inc.
7
7
  # License:: Apache License, Version 2.0
8
8
  #
9
9
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,25 +24,19 @@ require 'chef/platform/resource_priority_map'
24
24
 
25
25
  describe Chef::Recipe do
26
26
 
27
- let(:cookbook_repo) { File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks")) }
28
-
29
- let(:cookbook_loader) do
30
- loader = Chef::CookbookLoader.new(cookbook_repo)
31
- loader.load_cookbooks
32
- loader
27
+ let(:cookbook_collection) do
28
+ cookbook_repo = File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks"))
29
+ cookbook_loader = Chef::CookbookLoader.new(cookbook_repo)
30
+ cookbook_loader.load_cookbooks
31
+ Chef::CookbookCollection.new(cookbook_loader)
33
32
  end
34
33
 
35
- let(:cookbook_collection) { Chef::CookbookCollection.new(cookbook_loader) }
36
-
37
34
  let(:node) do
38
- Chef::Node.new.tap {|n| n.normal[:tags] = [] }
39
- end
40
-
41
- let(:events) do
42
- Chef::EventDispatch::Dispatcher.new
35
+ Chef::Node.new
43
36
  end
44
37
 
45
38
  let(:run_context) do
39
+ events = Chef::EventDispatch::Dispatcher.new
46
40
  Chef::RunContext.new(node, cookbook_collection, events)
47
41
  end
48
42
 
@@ -305,6 +299,34 @@ describe Chef::Recipe do
305
299
  zm_resource # force let binding evaluation
306
300
  expect(run_context.resource_collection.resources(:zen_master => "klopp")).to eq(zm_resource)
307
301
  end
302
+
303
+ it "will insert another resource if create_if_missing is not set (cloned resource as of Chef-12)" do
304
+ zm_resource
305
+ recipe.declare_resource(:zen_master, "klopp")
306
+ expect(run_context.resource_collection.count).to eql(2)
307
+ end
308
+
309
+ it "does not insert two resources if create_if_missing is used" do
310
+ zm_resource
311
+ recipe.declare_resource(:zen_master, "klopp", create_if_missing: true)
312
+ expect(run_context.resource_collection.count).to eql(1)
313
+ end
314
+
315
+ context "injecting a different run_context" do
316
+ let(:run_context2) do
317
+ events = Chef::EventDispatch::Dispatcher.new
318
+ Chef::RunContext.new(node, cookbook_collection, events)
319
+ end
320
+
321
+ it "should insert resources into the correct run_context" do
322
+ zm_resource
323
+ recipe.declare_resource(:zen_master, "klopp2", run_context: run_context2)
324
+ run_context2.resource_collection.lookup("zen_master[klopp2]")
325
+ expect {run_context2.resource_collection.lookup("zen_master[klopp]")}.to raise_error(Chef::Exceptions::ResourceNotFound)
326
+ expect {run_context.resource_collection.lookup("zen_master[klopp2]")}.to raise_error(Chef::Exceptions::ResourceNotFound)
327
+ run_context.resource_collection.lookup("zen_master[klopp]")
328
+ end
329
+ end
308
330
  end
309
331
 
310
332
  describe "creating a resource with short name" do
@@ -615,21 +637,25 @@ describe Chef::Recipe do
615
637
  end
616
638
  end
617
639
 
640
+ it "should initialize tags to an empty Array" do
641
+ expect(node.tags).to eql([])
642
+ end
643
+
618
644
  it "should set tags via tag" do
619
645
  recipe.tag "foo"
620
- expect(node[:tags]).to include("foo")
646
+ expect(node.tags).to include("foo")
621
647
  end
622
648
 
623
649
  it "should set multiple tags via tag" do
624
650
  recipe.tag "foo", "bar"
625
- expect(node[:tags]).to include("foo")
626
- expect(node[:tags]).to include("bar")
651
+ expect(node.tags).to include("foo")
652
+ expect(node.tags).to include("bar")
627
653
  end
628
654
 
629
655
  it "should not set the same tag twice via tag" do
630
656
  recipe.tag "foo"
631
657
  recipe.tag "foo"
632
- expect(node[:tags]).to eql([ "foo" ])
658
+ expect(node.tags).to eql([ "foo" ])
633
659
  end
634
660
 
635
661
  it "should return the current list of tags from tag with no arguments" do
@@ -653,13 +679,13 @@ describe Chef::Recipe do
653
679
  it "should remove a tag from the tag list via untag" do
654
680
  recipe.tag "foo"
655
681
  recipe.untag "foo"
656
- expect(node[:tags]).to eql([])
682
+ expect(node.tags).to eql([])
657
683
  end
658
684
 
659
685
  it "should remove multiple tags from the tag list via untag" do
660
686
  recipe.tag "foo", "bar"
661
687
  recipe.untag "bar", "foo"
662
- expect(node[:tags]).to eql([])
688
+ expect(node.tags).to eql([])
663
689
  end
664
690
  end
665
691
 
@@ -52,7 +52,7 @@ describe Chef::Resource::ChefGem, "gem_binary" do
52
52
 
53
53
  context "when building the resource" do
54
54
  let(:node) do
55
- Chef::Node.new.tap {|n| n.normal[:tags] = [] }
55
+ Chef::Node.new
56
56
  end
57
57
 
58
58
  let(:run_context) do
@@ -15,13 +15,13 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
-
19
18
  require 'spec_helper'
20
-
21
19
  describe Chef::Resource::DscResource do
22
20
  let(:dsc_test_resource_name) { 'DSCTest' }
23
21
  let(:dsc_test_property_name) { :DSCTestProperty }
24
22
  let(:dsc_test_property_value) { 'DSCTestValue' }
23
+ let(:dsc_test_reboot_action) { :reboot_now }
24
+ let(:dsc_test_timeout) { 101 }
25
25
 
26
26
  context 'when Powershell supports Dsc' do
27
27
  let(:dsc_test_run_context) {
@@ -30,6 +30,7 @@ describe Chef::Resource::DscResource do
30
30
  empty_events = Chef::EventDispatch::Dispatcher.new
31
31
  Chef::RunContext.new(node, {}, empty_events)
32
32
  }
33
+
33
34
  let(:dsc_test_resource) {
34
35
  Chef::Resource::DscResource.new(dsc_test_resource_name, dsc_test_run_context)
35
36
  }
@@ -38,7 +39,7 @@ describe Chef::Resource::DscResource do
38
39
  expect(dsc_test_resource.action).to eq([:run])
39
40
  end
40
41
 
41
- it "has an allowed_actions attribute with only the `:run` and `:nothing` attributes" do
42
+ it "has an ed_actions attribute with only the `:run` and `:nothing` attributes" do
42
43
  expect(dsc_test_resource.allowed_actions.to_set).to eq([:run,:nothing].to_set)
43
44
  end
44
45
 
@@ -52,6 +53,16 @@ describe Chef::Resource::DscResource do
52
53
  expect(dsc_test_resource.module_name).to eq(dsc_test_resource_name)
53
54
  end
54
55
 
56
+ it "allows the reboot_action attribute to be set" do
57
+ dsc_test_resource.reboot_action(dsc_test_reboot_action)
58
+ expect(dsc_test_resource.reboot_action).to eq(dsc_test_reboot_action)
59
+ end
60
+
61
+ it "allows the timeout attribute to be set" do
62
+ dsc_test_resource.timeout(dsc_test_timeout)
63
+ expect(dsc_test_resource.timeout).to eq(dsc_test_timeout)
64
+ end
65
+
55
66
  context "when setting a dsc property" do
56
67
  it "allows setting a dsc property with a property name of type Symbol" do
57
68
  dsc_test_resource.property(dsc_test_property_name, dsc_test_property_value)
@@ -0,0 +1,40 @@
1
+ #
2
+ # Author:: Nolan Davidson (<nolan.davidson@gmail.com>)
3
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'spec_helper'
20
+
21
+ describe Chef::Resource::Ksh do
22
+
23
+ before(:each) do
24
+ @resource = Chef::Resource::Ksh.new("fakey_fakerton")
25
+ end
26
+
27
+ it "should create a new Chef::Resource::Ksh" do
28
+ expect(@resource).to be_a_kind_of(Chef::Resource)
29
+ expect(@resource).to be_a_kind_of(Chef::Resource::Ksh)
30
+ end
31
+
32
+ it "should have a resource name of :ksh" do
33
+ expect(@resource.resource_name).to eql(:ksh)
34
+ end
35
+
36
+ it "should have an interpreter of ksh" do
37
+ expect(@resource.interpreter).to eql("ksh")
38
+ end
39
+
40
+ end
@@ -91,7 +91,7 @@ describe Chef::Resource::RegistryKey, "values" do
91
91
 
92
92
  it "should return checksummed data if the type is unsafe" do
93
93
  @resource.values( { :name => 'poosh', :type => :binary, :data => 255.chr * 1 })
94
- expect(@resource.values).to eql([ { :name => 'poosh', :type => :binary, :data => "00594fd4f42ba43fc1ca0427a0576295" } ])
94
+ expect(@resource.values).to eql([ { :name => 'poosh', :type => :binary, :data => 'a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89' } ])
95
95
  end
96
96
 
97
97
  it "should throw an exception if the name field is missing" do
@@ -194,6 +194,6 @@ describe Chef::Resource::RegistryKey, "state" do
194
194
 
195
195
  it "should return scrubbed values" do
196
196
  @resource.values([ { :name => 'poosh', :type => :binary, :data => 255.chr * 1 } ])
197
- expect(@resource.state).to eql( { :values => [{ :name => 'poosh', :type => :binary, :data => "00594fd4f42ba43fc1ca0427a0576295" }] } )
197
+ expect(@resource.state).to eql( { :values => [{ :name => 'poosh', :type => :binary, :data => 'a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89'}] } )
198
198
  end
199
199
  end
@@ -19,149 +19,148 @@ require 'spec_helper'
19
19
  require 'chef/resource/resource_notification'
20
20
 
21
21
  describe Chef::Resource::Notification do
22
- before do
23
- @notification = Chef::Resource::Notification.new(:service_apache, :restart, :template_httpd_conf)
24
- end
22
+
23
+ let(:notification) { Chef::Resource::Notification.new(:service_apache, :restart, :template_httpd_conf) }
25
24
 
26
25
  it "has a resource to be notified" do
27
- expect(@notification.resource).to eq(:service_apache)
26
+ expect(notification.resource).to eq(:service_apache)
28
27
  end
29
28
 
30
29
  it "has an action to take on the service" do
31
- expect(@notification.action).to eq(:restart)
30
+ expect(notification.action).to eq(:restart)
32
31
  end
33
32
 
34
33
  it "has a notifying resource" do
35
- expect(@notification.notifying_resource).to eq(:template_httpd_conf)
34
+ expect(notification.notifying_resource).to eq(:template_httpd_conf)
36
35
  end
37
36
 
38
37
  it "is a duplicate of another notification with the same target resource and action" do
39
38
  other = Chef::Resource::Notification.new(:service_apache, :restart, :sync_web_app_code)
40
- expect(@notification.duplicates?(other)).to be_truthy
39
+ expect(notification.duplicates?(other)).to be_truthy
41
40
  end
42
41
 
43
42
  it "is not a duplicate of another notification if the actions differ" do
44
43
  other = Chef::Resource::Notification.new(:service_apache, :enable, :install_apache)
45
- expect(@notification.duplicates?(other)).to be_falsey
44
+ expect(notification.duplicates?(other)).to be_falsey
46
45
  end
47
46
 
48
47
  it "is not a duplicate of another notification if the target resources differ" do
49
48
  other = Chef::Resource::Notification.new(:service_sshd, :restart, :template_httpd_conf)
50
- expect(@notification.duplicates?(other)).to be_falsey
49
+ expect(notification.duplicates?(other)).to be_falsey
51
50
  end
52
51
 
53
52
  it "raises an ArgumentError if you try to check a non-ducktype object for duplication" do
54
- expect {@notification.duplicates?(:not_a_notification)}.to raise_error(ArgumentError)
53
+ expect {notification.duplicates?(:not_a_notification)}.to raise_error(ArgumentError)
55
54
  end
56
55
 
57
56
  it "takes no action to resolve a resource reference that doesn't need to be resolved" do
58
57
  @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
59
- @notification.resource = @keyboard_cat
58
+ notification.resource = @keyboard_cat
60
59
  @long_cat = Chef::Resource::Cat.new("long_cat")
61
- @notification.notifying_resource = @long_cat
60
+ notification.notifying_resource = @long_cat
62
61
  @resource_collection = Chef::ResourceCollection.new
63
62
  # would raise an error since the resource is not in the collection
64
- @notification.resolve_resource_reference(@resource_collection)
65
- expect(@notification.resource).to eq(@keyboard_cat)
63
+ notification.resolve_resource_reference(@resource_collection)
64
+ expect(notification.resource).to eq(@keyboard_cat)
66
65
  end
67
66
 
68
67
  it "resolves a lazy reference to a resource" do
69
- @notification.resource = {:cat => "keyboard_cat"}
68
+ notification.resource = {:cat => "keyboard_cat"}
70
69
  @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
71
70
  @resource_collection = Chef::ResourceCollection.new
72
71
  @resource_collection << @keyboard_cat
73
72
  @long_cat = Chef::Resource::Cat.new("long_cat")
74
- @notification.notifying_resource = @long_cat
75
- @notification.resolve_resource_reference(@resource_collection)
76
- expect(@notification.resource).to eq(@keyboard_cat)
73
+ notification.notifying_resource = @long_cat
74
+ notification.resolve_resource_reference(@resource_collection)
75
+ expect(notification.resource).to eq(@keyboard_cat)
77
76
  end
78
77
 
79
78
  it "resolves a lazy reference to its notifying resource" do
80
79
  @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
81
- @notification.resource = @keyboard_cat
82
- @notification.notifying_resource = {:cat => "long_cat"}
80
+ notification.resource = @keyboard_cat
81
+ notification.notifying_resource = {:cat => "long_cat"}
83
82
  @long_cat = Chef::Resource::Cat.new("long_cat")
84
83
  @resource_collection = Chef::ResourceCollection.new
85
84
  @resource_collection << @long_cat
86
- @notification.resolve_resource_reference(@resource_collection)
87
- expect(@notification.notifying_resource).to eq(@long_cat)
85
+ notification.resolve_resource_reference(@resource_collection)
86
+ expect(notification.notifying_resource).to eq(@long_cat)
88
87
  end
89
88
 
90
89
  it "resolves lazy references to both its resource and its notifying resource" do
91
- @notification.resource = {:cat => "keyboard_cat"}
90
+ notification.resource = {:cat => "keyboard_cat"}
92
91
  @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
93
92
  @resource_collection = Chef::ResourceCollection.new
94
93
  @resource_collection << @keyboard_cat
95
- @notification.notifying_resource = {:cat => "long_cat"}
94
+ notification.notifying_resource = {:cat => "long_cat"}
96
95
  @long_cat = Chef::Resource::Cat.new("long_cat")
97
96
  @resource_collection << @long_cat
98
- @notification.resolve_resource_reference(@resource_collection)
99
- expect(@notification.resource).to eq(@keyboard_cat)
100
- expect(@notification.notifying_resource).to eq(@long_cat)
97
+ notification.resolve_resource_reference(@resource_collection)
98
+ expect(notification.resource).to eq(@keyboard_cat)
99
+ expect(notification.notifying_resource).to eq(@long_cat)
101
100
  end
102
101
 
103
102
  it "raises a RuntimeError if you try to reference multiple resources" do
104
- @notification.resource = {:cat => ["keyboard_cat", "cheez_cat"]}
103
+ notification.resource = {:cat => ["keyboard_cat", "cheez_cat"]}
105
104
  @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
106
105
  @cheez_cat = Chef::Resource::Cat.new("cheez_cat")
107
106
  @resource_collection = Chef::ResourceCollection.new
108
107
  @resource_collection << @keyboard_cat
109
108
  @resource_collection << @cheez_cat
110
109
  @long_cat = Chef::Resource::Cat.new("long_cat")
111
- @notification.notifying_resource = @long_cat
112
- expect {@notification.resolve_resource_reference(@resource_collection)}.to raise_error(RuntimeError)
110
+ notification.notifying_resource = @long_cat
111
+ expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(RuntimeError)
113
112
  end
114
113
 
115
114
  it "raises a RuntimeError if you try to reference multiple notifying resources" do
116
- @notification.notifying_resource = {:cat => ["long_cat", "cheez_cat"]}
115
+ notification.notifying_resource = {:cat => ["long_cat", "cheez_cat"]}
117
116
  @long_cat = Chef::Resource::Cat.new("long_cat")
118
117
  @cheez_cat = Chef::Resource::Cat.new("cheez_cat")
119
118
  @resource_collection = Chef::ResourceCollection.new
120
119
  @resource_collection << @long_cat
121
120
  @resource_collection << @cheez_cat
122
121
  @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
123
- @notification.resource = @keyboard_cat
124
- expect {@notification.resolve_resource_reference(@resource_collection)}.to raise_error(RuntimeError)
122
+ notification.resource = @keyboard_cat
123
+ expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(RuntimeError)
125
124
  end
126
125
 
127
126
  it "raises a RuntimeError if it can't find a resource in the resource collection when resolving a lazy reference" do
128
- @notification.resource = {:cat => "keyboard_cat"}
127
+ notification.resource = {:cat => "keyboard_cat"}
129
128
  @cheez_cat = Chef::Resource::Cat.new("cheez_cat")
130
129
  @resource_collection = Chef::ResourceCollection.new
131
130
  @resource_collection << @cheez_cat
132
131
  @long_cat = Chef::Resource::Cat.new("long_cat")
133
- @notification.notifying_resource = @long_cat
134
- expect {@notification.resolve_resource_reference(@resource_collection)}.to raise_error(RuntimeError)
132
+ notification.notifying_resource = @long_cat
133
+ expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(RuntimeError)
135
134
  end
136
135
 
137
136
  it "raises a RuntimeError if it can't find a notifying resource in the resource collection when resolving a lazy reference" do
138
- @notification.notifying_resource = {:cat => "long_cat"}
137
+ notification.notifying_resource = {:cat => "long_cat"}
139
138
  @cheez_cat = Chef::Resource::Cat.new("cheez_cat")
140
139
  @resource_collection = Chef::ResourceCollection.new
141
140
  @resource_collection << @cheez_cat
142
141
  @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
143
- @notification.resource = @keyboard_cat
144
- expect {@notification.resolve_resource_reference(@resource_collection)}.to raise_error(RuntimeError)
142
+ notification.resource = @keyboard_cat
143
+ expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(RuntimeError)
145
144
  end
146
145
 
147
146
  it "raises an ArgumentError if improper syntax is used in the lazy reference to its resource" do
148
- @notification.resource = "cat => keyboard_cat"
147
+ notification.resource = "cat => keyboard_cat"
149
148
  @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
150
149
  @resource_collection = Chef::ResourceCollection.new
151
150
  @resource_collection << @keyboard_cat
152
151
  @long_cat = Chef::Resource::Cat.new("long_cat")
153
- @notification.notifying_resource = @long_cat
154
- expect {@notification.resolve_resource_reference(@resource_collection)}.to raise_error(ArgumentError)
152
+ notification.notifying_resource = @long_cat
153
+ expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(ArgumentError)
155
154
  end
156
155
 
157
156
  it "raises an ArgumentError if improper syntax is used in the lazy reference to its notifying resource" do
158
- @notification.notifying_resource = "cat => long_cat"
157
+ notification.notifying_resource = "cat => long_cat"
159
158
  @long_cat = Chef::Resource::Cat.new("long_cat")
160
159
  @resource_collection = Chef::ResourceCollection.new
161
160
  @resource_collection << @long_cat
162
161
  @keyboard_cat = Chef::Resource::Cat.new("keyboard_cat")
163
- @notification.resource = @keyboard_cat
164
- expect {@notification.resolve_resource_reference(@resource_collection)}.to raise_error(ArgumentError)
162
+ notification.resource = @keyboard_cat
163
+ expect {notification.resolve_resource_reference(@resource_collection)}.to raise_error(ArgumentError)
165
164
  end
166
165
 
167
166
  # Create test to resolve lazy references to both notifying resource and dest. resource