chef 13.6.4-universal-mingw32 → 13.7.16-universal-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/VERSION +1 -1
- data/acceptance/Gemfile +2 -2
- data/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb +1 -6
- data/distro/powershell/chef/chef.psm1 +1 -5
- data/lib/chef/api_client.rb +5 -5
- data/lib/chef/api_client_v1.rb +6 -6
- data/lib/chef/application.rb +3 -2
- data/lib/chef/application/knife.rb +4 -0
- data/lib/chef/chef_class.rb +2 -2
- data/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +1 -1
- data/lib/chef/chef_fs/data_handler/data_handler_base.rb +2 -4
- data/lib/chef/client.rb +3 -3
- data/lib/chef/cookbook/chefignore.rb +4 -0
- data/lib/chef/cookbook/cookbook_collection.rb +2 -2
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/data_bag.rb +1 -1
- data/lib/chef/deprecated.rb +10 -0
- data/lib/chef/event_dispatch/base.rb +2 -2
- data/lib/chef/http.rb +10 -10
- data/lib/chef/knife.rb +16 -15
- data/lib/chef/knife/configure.rb +12 -36
- data/lib/chef/knife/cookbook_upload.rb +4 -4
- data/lib/chef/knife/core/bootstrap_context.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +6 -2
- data/lib/chef/knife/core/ui.rb +1 -1
- data/lib/chef/knife/data_bag_secret_options.rb +1 -1
- data/lib/chef/knife/data_bag_show.rb +1 -1
- data/lib/chef/knife/edit.rb +1 -1
- data/lib/chef/knife/ssh.rb +47 -35
- data/lib/chef/knife/user_create.rb +2 -0
- data/lib/chef/knife/user_delete.rb +2 -0
- data/lib/chef/knife/user_edit.rb +2 -0
- data/lib/chef/knife/user_reregister.rb +2 -0
- data/lib/chef/knife/user_show.rb +2 -0
- data/lib/chef/mixin/powershell_out.rb +1 -1
- data/lib/chef/node/attribute.rb +46 -70
- data/lib/chef/node/attribute_collections.rb +5 -5
- data/lib/chef/node/common_api.rb +1 -1
- data/lib/chef/node/immutable_collections.rb +180 -23
- data/lib/chef/node/mixin/state_tracking.rb +6 -6
- data/lib/chef/node_map.rb +63 -45
- data/lib/chef/property.rb +8 -8
- data/lib/chef/provider.rb +9 -3
- data/lib/chef/provider/apt_preference.rb +1 -1
- data/lib/chef/provider/apt_repository.rb +1 -1
- data/lib/chef/provider/apt_update.rb +1 -1
- data/lib/chef/provider/file.rb +1 -1
- data/lib/chef/provider/group/dscl.rb +6 -2
- data/lib/chef/provider/ifconfig.rb +96 -34
- data/lib/chef/provider/launchd.rb +0 -1
- data/lib/chef/provider/log.rb +3 -13
- data/lib/chef/provider/package/dnf.rb +1 -1
- data/lib/chef/provider/package/smartos.rb +2 -2
- data/lib/chef/provider/reboot.rb +12 -0
- data/lib/chef/provider/remote_directory.rb +1 -1
- data/lib/chef/provider/remote_file/http.rb +3 -2
- data/lib/chef/provider/service/solaris.rb +6 -2
- data/lib/chef/provider/systemd_unit.rb +34 -33
- data/lib/chef/provider/user/dscl.rb +1 -1
- data/lib/chef/provider/windows_path.rb +6 -7
- data/lib/chef/provider/windows_task.rb +89 -33
- data/lib/chef/provider/yum_repository.rb +24 -9
- data/lib/chef/resource/apt_package.rb +1 -0
- data/lib/chef/resource/apt_preference.rb +4 -0
- data/lib/chef/resource/apt_repository.rb +4 -0
- data/lib/chef/resource/apt_update.rb +3 -0
- data/lib/chef/resource/bash.rb +4 -0
- data/lib/chef/resource/batch.rb +5 -0
- data/lib/chef/resource/bff_package.rb +4 -0
- data/lib/chef/resource/breakpoint.rb +6 -0
- data/lib/chef/resource/cab_package.rb +6 -6
- data/lib/chef/resource/chef_gem.rb +13 -0
- data/lib/chef/resource/chocolatey_package.rb +4 -6
- data/lib/chef/resource/cookbook_file.rb +13 -15
- data/lib/chef/resource/cron.rb +2 -0
- data/lib/chef/resource/csh.rb +4 -0
- data/lib/chef/resource/directory.rb +8 -26
- data/lib/chef/resource/dnf_package.rb +5 -0
- data/lib/chef/resource/dpkg_package.rb +2 -0
- data/lib/chef/resource/dsc_resource.rb +5 -0
- data/lib/chef/resource/dsc_script.rb +6 -0
- data/lib/chef/resource/env.rb +3 -0
- data/lib/chef/resource/erl_call.rb +5 -0
- data/lib/chef/resource/execute.rb +5 -1
- data/lib/chef/resource/file.rb +2 -1
- data/lib/chef/resource/file/verification.rb +10 -0
- data/lib/chef/resource/freebsd_package.rb +10 -2
- data/lib/chef/resource/gem_package.rb +2 -0
- data/lib/chef/resource/git.rb +2 -0
- data/lib/chef/resource/group.rb +1 -0
- data/lib/chef/resource/homebrew_package.rb +3 -0
- data/lib/chef/resource/http_request.rb +2 -0
- data/lib/chef/resource/ifconfig.rb +23 -150
- data/lib/chef/resource/ips_package.rb +1 -0
- data/lib/chef/resource/ksh.rb +6 -0
- data/lib/chef/resource/launchd.rb +5 -4
- data/lib/chef/resource/link.rb +10 -0
- data/lib/chef/resource/log.rb +19 -46
- data/lib/chef/resource/macports_package.rb +1 -0
- data/lib/chef/resource/mdadm.rb +4 -0
- data/lib/chef/resource/mount.rb +1 -0
- data/lib/chef/resource/msu_package.rb +7 -8
- data/lib/chef/resource/ohai.rb +2 -0
- data/lib/chef/resource/openbsd_package.rb +3 -0
- data/lib/chef/resource/osx_profile.rb +10 -40
- data/lib/chef/resource/package.rb +6 -0
- data/lib/chef/resource/pacman_package.rb +1 -0
- data/lib/chef/resource/paludis_package.rb +3 -0
- data/lib/chef/resource/perl.rb +4 -0
- data/lib/chef/resource/portage_package.rb +1 -0
- data/lib/chef/resource/powershell_package.rb +5 -0
- data/lib/chef/resource/powershell_script.rb +8 -0
- data/lib/chef/resource/python.rb +4 -0
- data/lib/chef/resource/reboot.rb +14 -20
- data/lib/chef/resource/registry_key.rb +1 -0
- data/lib/chef/resource/remote_directory.rb +3 -0
- data/lib/chef/resource/remote_file.rb +2 -0
- data/lib/chef/resource/resource_notification.rb +17 -0
- data/lib/chef/resource/route.rb +1 -0
- data/lib/chef/resource/rpm_package.rb +1 -0
- data/lib/chef/resource/ruby.rb +4 -0
- data/lib/chef/resource/ruby_block.rb +3 -0
- data/lib/chef/resource/script.rb +4 -0
- data/lib/chef/resource/service.rb +1 -0
- data/lib/chef/resource/smartos_package.rb +1 -0
- data/lib/chef/resource/solaris_package.rb +1 -0
- data/lib/chef/resource/subversion.rb +1 -0
- data/lib/chef/resource/systemd_unit.rb +6 -0
- data/lib/chef/resource/template.rb +9 -0
- data/lib/chef/resource/user.rb +1 -0
- data/lib/chef/resource/windows_package.rb +2 -0
- data/lib/chef/resource/windows_path.rb +5 -10
- data/lib/chef/resource/windows_service.rb +3 -0
- data/lib/chef/resource/windows_task.rb +66 -87
- data/lib/chef/resource/yum_repository.rb +26 -22
- data/lib/chef/resource/zypper_package.rb +2 -0
- data/lib/chef/resource/zypper_repository.rb +6 -1
- data/lib/chef/run_context.rb +8 -2
- data/lib/chef/server_api.rb +1 -0
- data/lib/chef/util/selinux.rb +5 -4
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version/platform.rb +18 -0
- data/lib/chef/version_constraint/platform.rb +2 -0
- data/spec/data/client.d_00/02-strings.rb +2 -0
- data/spec/functional/assets/chefinittest +6 -4
- data/spec/functional/knife/ssh_spec.rb +54 -7
- data/spec/functional/resource/bff_spec.rb +3 -3
- data/spec/functional/resource/ifconfig_spec.rb +1 -1
- data/spec/functional/resource/mount_spec.rb +7 -3
- data/spec/functional/resource/user/useradd_spec.rb +4 -4
- data/spec/functional/resource/windows_task_spec.rb +6 -6
- data/spec/functional/win32/security_spec.rb +7 -33
- data/spec/integration/knife/data_bag_show_spec.rb +1 -1
- data/spec/integration/recipes/noop_resource_spec.rb +1 -1
- data/spec/integration/recipes/recipe_dsl_spec.rb +30 -30
- data/spec/integration/recipes/resource_action_spec.rb +2 -2
- data/spec/integration/recipes/resource_converge_if_changed_spec.rb +71 -15
- data/spec/spec_helper.rb +19 -0
- data/spec/support/shared/functional/execute_resource.rb +1 -1
- data/spec/support/shared/unit/application_dot_d.rb +2 -0
- data/spec/support/shared/unit/execute_resource.rb +8 -1
- data/spec/support/shared/unit/provider/file.rb +9 -1
- data/spec/unit/chef_fs/data_handler/data_bag_item_data_handler.rb +10 -7
- data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +2 -2
- data/spec/unit/client_spec.rb +1 -1
- data/spec/unit/deprecated_spec.rb +4 -4
- data/spec/unit/http_spec.rb +9 -0
- data/spec/unit/knife/bootstrap_spec.rb +5 -0
- data/spec/unit/knife/configure_spec.rb +10 -60
- data/spec/unit/knife/data_bag_create_spec.rb +40 -2
- data/spec/unit/knife/data_bag_show_spec.rb +16 -2
- data/spec/unit/knife/ssh_spec.rb +85 -39
- data/spec/unit/knife_spec.rb +2 -0
- data/spec/unit/lwrp_spec.rb +5 -3
- data/spec/unit/mixin/powershell_type_coercions_spec.rb +7 -6
- data/spec/unit/node/attribute_spec.rb +55 -24
- data/spec/unit/node/immutable_collections_spec.rb +28 -14
- data/spec/unit/node/vivid_mash_spec.rb +27 -10
- data/spec/unit/node_map_spec.rb +34 -0
- data/spec/unit/property_spec.rb +13 -13
- data/spec/unit/provider/group/dscl_spec.rb +14 -5
- data/spec/unit/provider/ifconfig_spec.rb +10 -3
- data/spec/unit/provider/remote_file/http_spec.rb +23 -19
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +6 -5
- data/spec/unit/provider/user/dscl_spec.rb +26 -0
- data/spec/unit/provider/windows_task_spec.rb +148 -4
- data/spec/unit/provider_spec.rb +1 -1
- data/spec/unit/resource/apt_package_spec.rb +1 -1
- data/spec/unit/resource/bash_spec.rb +8 -10
- data/spec/unit/resource/batch_spec.rb +1 -1
- data/spec/unit/resource/cab_package_spec.rb +19 -1
- data/spec/unit/resource/chef_gem_spec.rb +3 -3
- data/spec/unit/resource/chocolatey_package_spec.rb +10 -10
- data/spec/unit/resource/conditional_spec.rb +2 -2
- data/spec/unit/resource/cookbook_file_spec.rb +24 -30
- data/spec/unit/resource/cron_spec.rb +79 -82
- data/spec/unit/resource/csh_spec.rb +8 -10
- data/spec/unit/resource/deploy_spec.rb +1 -1
- data/spec/unit/resource/directory_spec.rb +28 -31
- data/spec/unit/resource/dnf_package_spec.rb +9 -9
- data/spec/unit/resource/env_spec.rb +7 -7
- data/spec/unit/resource/erl_call_spec.rb +9 -9
- data/spec/unit/resource/execute_spec.rb +6 -6
- data/spec/unit/resource/file/verification_spec.rb +18 -4
- data/spec/unit/resource/file_spec.rb +53 -56
- data/spec/unit/resource/freebsd_package_spec.rb +7 -7
- data/spec/unit/resource/gem_package_spec.rb +1 -1
- data/spec/unit/resource/git_spec.rb +7 -9
- data/spec/unit/resource/group_spec.rb +60 -70
- data/spec/unit/resource/http_request_spec.rb +16 -19
- data/spec/unit/resource/ifconfig_spec.rb +3 -3
- data/spec/unit/resource/ips_package_spec.rb +3 -5
- data/spec/unit/resource/ksh_spec.rb +8 -10
- data/spec/unit/resource/launchd_spec.rb +17 -10
- data/spec/unit/resource/link_spec.rb +53 -53
- data/spec/unit/resource/log_spec.rb +24 -28
- data/spec/unit/resource/mdadm_spec.rb +42 -44
- data/spec/unit/resource/mount_spec.rb +97 -99
- data/spec/unit/resource/msu_package_spec.rb +14 -8
- data/spec/unit/resource/ohai_spec.rb +15 -17
- data/spec/unit/resource/openbsd_package_spec.rb +3 -3
- data/spec/unit/resource/osx_profile_spec.rb +7 -7
- data/spec/unit/resource/package_spec.rb +36 -40
- data/spec/unit/resource/perl_spec.rb +8 -11
- data/spec/unit/resource/portage_package_spec.rb +8 -10
- data/spec/unit/resource/powershell_package_spec.rb +9 -9
- data/spec/unit/resource/python_spec.rb +8 -11
- data/spec/unit/resource/reboot_spec.rb +50 -0
- data/spec/unit/resource/registry_key_spec.rb +84 -98
- data/spec/unit/resource/remote_directory_spec.rb +40 -42
- data/spec/unit/resource/remote_file_spec.rb +78 -80
- data/spec/unit/resource/route_spec.rb +42 -44
- data/spec/unit/resource/rpm_package_spec.rb +5 -7
- data/spec/unit/resource/ruby_block_spec.rb +14 -16
- data/spec/unit/resource/ruby_spec.rb +8 -12
- data/spec/unit/resource/scm_spec.rb +66 -69
- data/spec/unit/resource/script_spec.rb +1 -1
- data/spec/unit/resource/service_spec.rb +80 -83
- data/spec/unit/resource/smartos_package_spec.rb +5 -0
- data/spec/unit/resource/solaris_package_spec.rb +3 -5
- data/spec/unit/resource/subversion_spec.rb +18 -16
- data/spec/unit/resource/systemd_unit_spec.rb +50 -54
- data/spec/unit/resource/template_spec.rb +56 -61
- data/spec/unit/resource/user_spec.rb +47 -53
- data/spec/unit/resource/windows_package_spec.rb +1 -1
- data/spec/unit/resource/windows_path_spec.rb +11 -8
- data/spec/unit/resource/windows_task_spec.rb +129 -33
- data/spec/unit/resource/yum_package_spec.rb +1 -1
- data/spec/unit/resource/yum_repository_spec.rb +61 -8
- data/spec/unit/resource/zypper_repository_spec.rb +17 -18
- data/spec/unit/util/selinux_spec.rb +3 -6
- data/tasks/dependencies.rb +0 -5
- data/tasks/rspec.rb +1 -1
- metadata +7 -19
- data/acceptance/.DS_Store +0 -0
- data/acceptance/.bundle/config +0 -2
- data/acceptance/top-cookbooks/.kitchen.docker.yml +0 -13
- data/acceptance/top-cookbooks/.kitchen.git.yml +0 -11
- data/distro/.DS_Store +0 -0
- data/lib/.DS_Store +0 -0
- data/lib/chef/.DS_Store +0 -0
- data/lib/chef/knife/.DS_Store +0 -0
- data/lib/chef/mixin/.DS_Store +0 -0
- data/spec/.DS_Store +0 -0
- data/spec/functional/.DS_Store +0 -0
- data/spec/support/.DS_Store +0 -0
- data/spec/unit/.DS_Store +0 -0
- data/tasks/.DS_Store +0 -0
@@ -118,6 +118,7 @@ describe Chef::Provider::Service::Solaris do
|
|
118
118
|
it "should create a current resource with the name of the new resource" do
|
119
119
|
expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
|
120
120
|
expect(Chef::Resource::Service).to receive(:new).and_return(@current_resource)
|
121
|
+
expect(@provider.maintenance).to be_falsey
|
121
122
|
@provider.load_current_resource
|
122
123
|
end
|
123
124
|
|
@@ -162,7 +163,7 @@ describe Chef::Provider::Service::Solaris do
|
|
162
163
|
end
|
163
164
|
|
164
165
|
it "should call svcadm enable -s chef" do
|
165
|
-
expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
|
166
|
+
expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
|
166
167
|
expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
|
167
168
|
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success)
|
168
169
|
@provider.load_current_resource
|
@@ -172,7 +173,7 @@ describe Chef::Provider::Service::Solaris do
|
|
172
173
|
end
|
173
174
|
|
174
175
|
it "should call svcadm enable -s chef for start_service" do
|
175
|
-
expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
|
176
|
+
expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
|
176
177
|
expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
|
177
178
|
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success)
|
178
179
|
@provider.load_current_resource
|
@@ -182,7 +183,7 @@ describe Chef::Provider::Service::Solaris do
|
|
182
183
|
|
183
184
|
it "should call svcadm clear chef for start_service when state maintenance" do
|
184
185
|
# we are in maint mode
|
185
|
-
expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@maintenance_svc_status)
|
186
|
+
expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@maintenance_svc_status)
|
186
187
|
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name).and_return(@success)
|
187
188
|
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", @current_resource.service_name).and_return(@success)
|
188
189
|
|
@@ -205,7 +206,7 @@ describe Chef::Provider::Service::Solaris do
|
|
205
206
|
|
206
207
|
it "should call svcadm enable -s -r chef" do
|
207
208
|
@new_resource.options("-r")
|
208
|
-
expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
|
209
|
+
expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
|
209
210
|
expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
|
210
211
|
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", "-r", @current_resource.service_name).and_return(@success)
|
211
212
|
@provider.load_current_resource
|
@@ -215,7 +216,7 @@ describe Chef::Provider::Service::Solaris do
|
|
215
216
|
|
216
217
|
it "should call svcadm enable -s -r -t chef when passed an array of options" do
|
217
218
|
@new_resource.options(["-r", "-t"])
|
218
|
-
expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
|
219
|
+
expect(@provider).to receive(:shell_out!).twice.with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status)
|
219
220
|
expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name)
|
220
221
|
expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", "-r", "-t", @current_resource.service_name).and_return(@success)
|
221
222
|
@provider.load_current_resource
|
@@ -213,6 +213,32 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30"
|
|
213
213
|
end
|
214
214
|
end
|
215
215
|
|
216
|
+
describe "current_home_exists?" do
|
217
|
+
let(:current_resource) do
|
218
|
+
new_resource.dup
|
219
|
+
end
|
220
|
+
|
221
|
+
before do
|
222
|
+
provider.current_resource = current_resource
|
223
|
+
end
|
224
|
+
|
225
|
+
it "returns false for nil home dir" do
|
226
|
+
current_resource.home nil
|
227
|
+
expect(provider.current_home_exists?).to be_falsey
|
228
|
+
end
|
229
|
+
|
230
|
+
it "is false for empty string" do
|
231
|
+
current_resource.home ""
|
232
|
+
expect(provider.current_home_exists?).to be_falsey
|
233
|
+
end
|
234
|
+
|
235
|
+
it "is true for existing directory" do
|
236
|
+
current_resource.home "/Users/blah"
|
237
|
+
allow(::File).to receive(:exist?).with("/Users/blah").and_return(true)
|
238
|
+
expect(provider.current_home_exists?).to be_truthy
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
216
242
|
describe "when modifying the home directory" do
|
217
243
|
let(:current_resource) do
|
218
244
|
new_resource.dup
|
@@ -40,7 +40,7 @@ describe Chef::Provider::WindowsTask do
|
|
40
40
|
:LastRunTime => "3/30/2017 2:27:00 PM",
|
41
41
|
:LastResult => "1",
|
42
42
|
:Author => "Administrator",
|
43
|
-
:TaskToRun => "chef-client",
|
43
|
+
:TaskToRun => "chef-client -L C:\\tmp\\",
|
44
44
|
:StartIn => "N/A",
|
45
45
|
:Comment => "N/A",
|
46
46
|
:ScheduledTaskState => "Enabled",
|
@@ -91,7 +91,7 @@ describe Chef::Provider::WindowsTask do
|
|
91
91
|
allow(provider).to receive(:load_task_hash).and_return(task_hash)
|
92
92
|
current_resource = provider.load_current_resource
|
93
93
|
expect(current_resource.exists).to be(true)
|
94
|
-
expect(current_resource.command).to eq("chef-client")
|
94
|
+
expect(current_resource.command).to eq("chef-client -L C:\\tmp\\")
|
95
95
|
expect(current_resource.user).to eq("SYSTEM")
|
96
96
|
expect(current_resource.run_level).to eq(:highest)
|
97
97
|
expect(current_resource.frequency).to eq(:minute)
|
@@ -110,6 +110,49 @@ describe Chef::Provider::WindowsTask do
|
|
110
110
|
expect(new_resource).not_to be_updated_by_last_action
|
111
111
|
end
|
112
112
|
|
113
|
+
it "sets the start_time in 24hr format while updating an existing task" do
|
114
|
+
# task_hash has start_time = "1:12:00 PM"
|
115
|
+
allow(provider).to receive(:load_task_hash).and_return(task_hash)
|
116
|
+
provider.load_current_resource
|
117
|
+
allow(provider).to receive(:task_need_update?).and_return(true)
|
118
|
+
allow(provider).to receive(:convert_system_date_to_mm_dd_yyyy).and_return("03/30/2017")
|
119
|
+
allow(provider).to receive(:run_schtasks)
|
120
|
+
provider.run_action(:create)
|
121
|
+
# start_time gets set in 24hr format for new_resource
|
122
|
+
expect(new_resource.start_time).to eq("13:12")
|
123
|
+
expect(new_resource).to be_updated_by_last_action
|
124
|
+
end
|
125
|
+
|
126
|
+
it "sets the start_day in mm/dd/yyyy format while updating an existing task" do
|
127
|
+
# start_day in yyyy-MM-dd format
|
128
|
+
task_hash[:StartDate] = "2017-03-30"
|
129
|
+
allow(provider).to receive(:load_task_hash).and_return(task_hash)
|
130
|
+
current_resource = provider.load_current_resource
|
131
|
+
allow(provider).to receive(:task_need_update?).and_return(true)
|
132
|
+
allow(provider).to receive(:convert_system_date_format_to_ruby_date_format).and_return("%Y-%m-%d")
|
133
|
+
allow(provider).to receive(:run_schtasks)
|
134
|
+
provider.run_action(:create)
|
135
|
+
# start_day gets set in mm/dd/yyyy format for new_resource
|
136
|
+
expect(new_resource.start_day).to eq("03/30/2017")
|
137
|
+
expect(new_resource).to be_updated_by_last_action
|
138
|
+
end
|
139
|
+
|
140
|
+
context "when start_day and start_time are N/A for frequency :on_logon" do
|
141
|
+
it "doesn't update the start_day and start_time of new_resource" do
|
142
|
+
task_hash[:on_logon] = true
|
143
|
+
task_hash[:StartDate] = "N/A"
|
144
|
+
task_hash[:StartTime] = "N/A"
|
145
|
+
allow(provider).to receive(:load_task_hash).and_return(task_hash)
|
146
|
+
current_resource = provider.load_current_resource
|
147
|
+
allow(provider).to receive(:task_need_update?).and_return(true)
|
148
|
+
allow(provider).to receive(:run_schtasks)
|
149
|
+
expect(provider).not_to receive(:convert_system_date_to_mm_dd_yyyy)
|
150
|
+
expect(DateTime).not_to receive(:parse)
|
151
|
+
expect(new_resource.start_day).to eq(nil)
|
152
|
+
expect(new_resource.start_time).to eq(nil)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
113
156
|
context "when task is not existing" do
|
114
157
|
before do
|
115
158
|
allow(provider).to receive(:load_task_hash)
|
@@ -285,7 +328,7 @@ describe Chef::Provider::WindowsTask do
|
|
285
328
|
before do
|
286
329
|
@task_action = "CREATE"
|
287
330
|
@options = { "F" => "", "SC" => :minute, "MO" => 15, "TR" => "chef-client", "RU" => "SYSTEM", "RL" => "HIGHEST" }
|
288
|
-
@cmd = "schtasks /CREATE /TN \"sample_task\" /F /SC \"minute\" /MO \"15\" /
|
331
|
+
@cmd = "schtasks /CREATE /TN \"sample_task\" /F /SC \"minute\" /MO \"15\" /RU \"SYSTEM\" /RL \"HIGHEST\" /TR \"chef-client \" "
|
289
332
|
end
|
290
333
|
|
291
334
|
it "forms the command properly from the given options" do
|
@@ -336,7 +379,7 @@ describe Chef::Provider::WindowsTask do
|
|
336
379
|
allow(provider).to receive(:get_system_short_date_format).and_return("MM/dd/yyyy")
|
337
380
|
provider.load_current_resource
|
338
381
|
|
339
|
-
new_resource.command "chef-client"
|
382
|
+
new_resource.command "chef-client -L C:\\tmp\\"
|
340
383
|
new_resource.run_level :highest
|
341
384
|
new_resource.frequency :minute
|
342
385
|
new_resource.frequency_modifier 15
|
@@ -379,6 +422,13 @@ describe Chef::Provider::WindowsTask do
|
|
379
422
|
expect(provider.send(:task_need_update?)).to be(true)
|
380
423
|
end
|
381
424
|
end
|
425
|
+
|
426
|
+
context "when command updated" do
|
427
|
+
it "return true" do
|
428
|
+
new_resource.command "chef-client"
|
429
|
+
expect(provider.send(:task_need_update?)).to be(true)
|
430
|
+
end
|
431
|
+
end
|
382
432
|
end
|
383
433
|
end
|
384
434
|
|
@@ -570,4 +620,98 @@ describe Chef::Provider::WindowsTask do
|
|
570
620
|
expect(provider.send(:frequency_modifier_allowed)).to be(false)
|
571
621
|
end
|
572
622
|
end
|
623
|
+
|
624
|
+
# In windows_task resource sec_to_dur method converts seconds to duration in format 60 == 'PT60S'
|
625
|
+
# random_delay_updated? method use the value return by sec_to_dur as input for comparison for new_resource.random_delay mocking the same here
|
626
|
+
describe "#random_delay_updated?" do
|
627
|
+
before do
|
628
|
+
new_resource.command "chef-client"
|
629
|
+
new_resource.run_level :highest
|
630
|
+
new_resource.frequency :minute
|
631
|
+
new_resource.frequency_modifier 15
|
632
|
+
new_resource.user "SYSTEM"
|
633
|
+
end
|
634
|
+
|
635
|
+
it "returns false if current_resource.random_delay = nil & random_delay is set to '0' seconds" do
|
636
|
+
task_hash[:random_delay] = nil
|
637
|
+
allow(provider).to receive(:load_task_hash).and_return(task_hash)
|
638
|
+
provider.load_current_resource
|
639
|
+
new_resource.random_delay = "PT0S"
|
640
|
+
expect(provider.send(:random_delay_updated?)).to be(false)
|
641
|
+
end
|
642
|
+
|
643
|
+
it "returns false if current_resource.random_delay = 'P7D' & random_delay is set to '604800' seconds " do
|
644
|
+
task_hash[:random_delay] = "P7D"
|
645
|
+
allow(provider).to receive(:load_task_hash).and_return(task_hash)
|
646
|
+
provider.load_current_resource
|
647
|
+
new_resource.random_delay = "PT604800S"
|
648
|
+
expect(provider.send(:random_delay_updated?)).to be(false)
|
649
|
+
end
|
650
|
+
|
651
|
+
it "returns false if current_resource.random_delay = 'P7DT1S' & random_delay is set to '604801' seconds" do
|
652
|
+
task_hash[:random_delay] = "P7DT1S"
|
653
|
+
allow(provider).to receive(:load_task_hash).and_return(task_hash)
|
654
|
+
provider.load_current_resource
|
655
|
+
new_resource.random_delay = "PT604801S"
|
656
|
+
expect(provider.send(:random_delay_updated?)).to be(false)
|
657
|
+
end
|
658
|
+
|
659
|
+
it "returns true if current_resource.random_delay = 'PT1S' & random_delay is set to '3600' seconds" do
|
660
|
+
task_hash[:random_delay] = "PT1S"
|
661
|
+
allow(provider).to receive(:load_task_hash).and_return(task_hash)
|
662
|
+
provider.load_current_resource
|
663
|
+
new_resource.random_delay = "PT3600S"
|
664
|
+
expect(provider.send(:random_delay_updated?)).to be(true)
|
665
|
+
end
|
666
|
+
|
667
|
+
it "returns false if current_resource.random_delay = 'P2Y1MT2H' & random_delay is set to '65707200' seconds" do
|
668
|
+
task_hash[:random_delay] = "P2Y1MT2H"
|
669
|
+
allow(provider).to receive(:load_task_hash).and_return(task_hash)
|
670
|
+
provider.load_current_resource
|
671
|
+
new_resource.random_delay = "PT65707200S"
|
672
|
+
expect(provider.send(:random_delay_updated?)).to be(false)
|
673
|
+
end
|
674
|
+
end
|
675
|
+
|
676
|
+
describe "#execution_time_limit_updated?" do
|
677
|
+
before do
|
678
|
+
new_resource.command "chef-client"
|
679
|
+
new_resource.run_level :highest
|
680
|
+
new_resource.frequency :minute
|
681
|
+
new_resource.frequency_modifier 15
|
682
|
+
new_resource.user "SYSTEM"
|
683
|
+
end
|
684
|
+
|
685
|
+
it "returns false if current_resource.execution_time_limit = 'P7D' & execution_time_limit is set to 604800 seconds " do
|
686
|
+
task_hash[:execution_time_limit] = "P7D"
|
687
|
+
allow(provider).to receive(:load_task_hash).and_return(task_hash)
|
688
|
+
provider.load_current_resource
|
689
|
+
new_resource.execution_time_limit = "PT604800S"
|
690
|
+
expect(provider.send(:execution_time_limit_updated?)).to be(false)
|
691
|
+
end
|
692
|
+
|
693
|
+
it "returns false if current_resource.execution_time_limit = 'P7DT1S' & execution_time_limit is set to 604801 seconds" do
|
694
|
+
task_hash[:execution_time_limit] = "P7DT1S"
|
695
|
+
allow(provider).to receive(:load_task_hash).and_return(task_hash)
|
696
|
+
provider.load_current_resource
|
697
|
+
new_resource.execution_time_limit = "PT604801S"
|
698
|
+
expect(provider.send(:execution_time_limit_updated?)).to be(false)
|
699
|
+
end
|
700
|
+
|
701
|
+
it "returns true if current_resource.execution_time_limit = 'PT1S' & execution_time_limit is set to '3600' seconds" do
|
702
|
+
task_hash[:execution_time_limit] = "PT1S"
|
703
|
+
allow(provider).to receive(:load_task_hash).and_return(task_hash)
|
704
|
+
provider.load_current_resource
|
705
|
+
new_resource.execution_time_limit = "PT3600S"
|
706
|
+
expect(provider.send(:execution_time_limit_updated?)).to be(true)
|
707
|
+
end
|
708
|
+
|
709
|
+
it "returns false if current_resource.execution_time_limit = 'P2Y1MT2H' & execution_time_limit is set to '65707200' seconds" do
|
710
|
+
task_hash[:execution_time_limit] = "P2Y1MT2H"
|
711
|
+
allow(provider).to receive(:load_task_hash).and_return(task_hash)
|
712
|
+
provider.load_current_resource
|
713
|
+
new_resource.execution_time_limit = "PT65707200S"
|
714
|
+
expect(provider.send(:execution_time_limit_updated?)).to be(false)
|
715
|
+
end
|
716
|
+
end
|
573
717
|
end
|
data/spec/unit/provider_spec.rb
CHANGED
@@ -197,7 +197,7 @@ describe Chef::Provider do
|
|
197
197
|
|
198
198
|
context "when using use_inline_resources" do
|
199
199
|
it "should log a deprecation warning" do
|
200
|
-
pending Chef::VERSION.start_with?("
|
200
|
+
pending Chef::VERSION.start_with?("14.1")
|
201
201
|
expect(Chef).to receive(:deprecated).with(:use_inline_resources, kind_of(String))
|
202
202
|
Class.new(described_class) { use_inline_resources }
|
203
203
|
end
|
@@ -31,7 +31,7 @@ describe Chef::Resource::AptPackage, "initialize" do
|
|
31
31
|
|
32
32
|
let(:resource) { Chef::Resource::AptPackage.new("foo") }
|
33
33
|
|
34
|
-
it "
|
34
|
+
it "supports default_release" do
|
35
35
|
resource.default_release("lenny-backports")
|
36
36
|
expect(resource.default_release).to eql("lenny-backports")
|
37
37
|
end
|
@@ -20,21 +20,19 @@ require "spec_helper"
|
|
20
20
|
|
21
21
|
describe Chef::Resource::Bash do
|
22
22
|
|
23
|
-
|
24
|
-
@resource = Chef::Resource::Bash.new("fakey_fakerton")
|
25
|
-
end
|
23
|
+
let(:resource) { Chef::Resource::Bash.new("fakey_fakerton") }
|
26
24
|
|
27
|
-
it "
|
28
|
-
expect(
|
29
|
-
expect(
|
25
|
+
it "creates a new Chef::Resource::Bash" do
|
26
|
+
expect(resource).to be_a_kind_of(Chef::Resource)
|
27
|
+
expect(resource).to be_a_kind_of(Chef::Resource::Bash)
|
30
28
|
end
|
31
29
|
|
32
|
-
it "
|
33
|
-
expect(
|
30
|
+
it "has a resource name of :bash" do
|
31
|
+
expect(resource.resource_name).to eql(:bash)
|
34
32
|
end
|
35
33
|
|
36
|
-
it "
|
37
|
-
expect(
|
34
|
+
it "has an interpreter of bash" do
|
35
|
+
expect(resource.interpreter).to eql("bash")
|
38
36
|
end
|
39
37
|
|
40
38
|
end
|
@@ -32,7 +32,25 @@ describe Chef::Resource::CabPackage do
|
|
32
32
|
expect(resource.resource_name).to eql(:cab_package)
|
33
33
|
end
|
34
34
|
|
35
|
-
it "
|
35
|
+
it "sets the default action as :install" do
|
36
|
+
expect(resource.action).to eql([:install])
|
37
|
+
end
|
38
|
+
|
39
|
+
it "coerces name property to package_name property" do
|
36
40
|
expect(resource.package_name).to eql("test_pkg")
|
37
41
|
end
|
42
|
+
|
43
|
+
it "coerces name property to a source property if source not provided" do
|
44
|
+
expect(resource.source).to end_with("test_pkg")
|
45
|
+
end
|
46
|
+
|
47
|
+
it "coerces name property to a source property if source not provided and package_name is" do
|
48
|
+
resource.package_name("package.cab")
|
49
|
+
expect(resource.source).to end_with("package.cab")
|
50
|
+
end
|
51
|
+
|
52
|
+
it "coerces source property if it does not looks like a path" do
|
53
|
+
resource.source("package.cab")
|
54
|
+
expect(resource.source).not_to eq("package.cab")
|
55
|
+
end
|
38
56
|
end
|
@@ -34,15 +34,15 @@ end
|
|
34
34
|
describe Chef::Resource::ChefGem, "gem_binary" do
|
35
35
|
let(:resource) { Chef::Resource::ChefGem.new("foo") }
|
36
36
|
|
37
|
-
it "
|
37
|
+
it "raises an exception when gem_binary is set" do
|
38
38
|
expect { resource.gem_binary("/lol/cats/gem") }.to raise_error(ArgumentError)
|
39
39
|
end
|
40
40
|
|
41
|
-
it "
|
41
|
+
it "sets the gem_binary based on computing it from RbConfig" do
|
42
42
|
expect(resource.gem_binary).to eql("#{RbConfig::CONFIG['bindir']}/gem")
|
43
43
|
end
|
44
44
|
|
45
|
-
it "
|
45
|
+
it "sets compile_time to false by default" do
|
46
46
|
expect(resource.compile_time).to be false
|
47
47
|
end
|
48
48
|
|
@@ -22,50 +22,50 @@ describe Chef::Resource::ChocolateyPackage do
|
|
22
22
|
|
23
23
|
let(:resource) { Chef::Resource::ChocolateyPackage.new("fakey_fakerton") }
|
24
24
|
|
25
|
-
it "
|
25
|
+
it "creates a new Chef::Resource::ChocolateyPackage" do
|
26
26
|
expect(resource).to be_a_kind_of(Chef::Resource)
|
27
27
|
expect(resource).to be_a_kind_of(Chef::Resource::Package)
|
28
28
|
expect(resource).to be_a_instance_of(Chef::Resource::ChocolateyPackage)
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
31
|
+
it "has a resource name of :python" do
|
32
32
|
expect(resource.resource_name).to eql(:chocolatey_package)
|
33
33
|
end
|
34
34
|
|
35
|
-
it "
|
35
|
+
it "coerces its name to a package_name array" do
|
36
36
|
expect(resource.package_name).to eql(["fakey_fakerton"])
|
37
37
|
end
|
38
38
|
|
39
|
-
it "the package_name setter
|
39
|
+
it "the package_name setter coerces to arrays" do
|
40
40
|
resource.package_name("git")
|
41
41
|
expect(resource.package_name).to eql(["git"])
|
42
42
|
end
|
43
43
|
|
44
|
-
it "the package_name setter
|
44
|
+
it "the package_name setter accepts arrays" do
|
45
45
|
resource.package_name(%w{git unzip})
|
46
46
|
expect(resource.package_name).to eql(%w{git unzip})
|
47
47
|
end
|
48
48
|
|
49
|
-
it "the name
|
49
|
+
it "the name accepts arrays" do
|
50
50
|
resource = Chef::Resource::ChocolateyPackage.new(%w{git unzip})
|
51
51
|
expect(resource.package_name).to eql(%w{git unzip})
|
52
52
|
end
|
53
53
|
|
54
|
-
it "the default version
|
54
|
+
it "the default version is nil" do
|
55
55
|
expect(resource.version).to eql(nil)
|
56
56
|
end
|
57
57
|
|
58
|
-
it "the version setter
|
58
|
+
it "the version setter coerces to arrays" do
|
59
59
|
resource.version("1.2.3")
|
60
60
|
expect(resource.version).to eql(["1.2.3"])
|
61
61
|
end
|
62
62
|
|
63
|
-
it "the version setter
|
63
|
+
it "the version setter accepts arrays" do
|
64
64
|
resource.version(["1.2.3", "4.5.6"])
|
65
65
|
expect(resource.version).to eql(["1.2.3", "4.5.6"])
|
66
66
|
end
|
67
67
|
|
68
|
-
it "the default returns
|
68
|
+
it "the default returns is 0" do
|
69
69
|
expect(resource.returns).to eql([0])
|
70
70
|
end
|
71
71
|
|