chef 15.4.45-universal-mingw32 → 15.5.9-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 +4 -4
- data/Gemfile +5 -3
- data/Rakefile +5 -3
- data/chef.gemspec +2 -1
- data/ext/win32-eventlog/Rakefile +9 -1
- data/ext/win32-eventlog/{chef-log.man → chef-log.man.erb} +4 -4
- data/lib/chef/application.rb +2 -2
- data/lib/chef/application/client.rb +1 -1
- data/lib/chef/application/knife.rb +1 -0
- data/lib/chef/application/solo.rb +1 -1
- data/lib/chef/chef_class.rb +1 -6
- data/lib/chef/chef_fs.rb +1 -1
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/chef_server/versioned_cookbooks_dir.rb +2 -2
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_dir.rb +7 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +4 -3
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +3 -3
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_versioned_cookbook_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +3 -3
- data/lib/chef/chef_fs/knife.rb +1 -1
- data/lib/chef/chef_fs/path_utils.rb +2 -2
- data/lib/chef/client.rb +4 -5
- data/lib/chef/config.rb +3 -2
- data/lib/chef/cookbook/chefignore.rb +16 -11
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/syntax_check.rb +5 -3
- data/lib/chef/cookbook_loader.rb +3 -3
- data/lib/chef/cookbook_uploader.rb +1 -1
- data/lib/chef/data_collector.rb +2 -2
- data/lib/chef/data_collector/run_end_message.rb +1 -0
- data/lib/chef/deprecated.rb +4 -0
- data/lib/chef/dsl/core.rb +1 -1
- data/lib/chef/dsl/platform_introspection.rb +9 -18
- data/lib/chef/event_loggers/windows_eventlog.rb +1 -1
- data/lib/chef/file_content_management/deploy.rb +3 -3
- data/lib/chef/file_content_management/deploy/mv_windows.rb +2 -2
- data/lib/chef/file_content_management/tempfile.rb +1 -1
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +2 -2
- data/lib/chef/http.rb +1 -1
- data/lib/chef/http/socketless_chef_zero_client.rb +1 -1
- data/lib/chef/knife.rb +4 -3
- data/lib/chef/knife/config_get.rb +2 -1
- data/lib/chef/knife/configure.rb +1 -1
- data/lib/chef/knife/cookbook_metadata_from_file.rb +6 -0
- data/lib/chef/knife/core/generic_presenter.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +1 -1
- data/lib/chef/knife/ssh.rb +6 -0
- data/lib/chef/local_mode.rb +1 -1
- data/lib/chef/mash.rb +21 -232
- data/lib/chef/mixin/file_class.rb +2 -2
- data/lib/chef/mixin/lazy_module_include.rb +1 -1
- data/lib/chef/mixin/path_sanity.rb +3 -39
- data/lib/chef/mixin/securable.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +4 -5
- data/lib/chef/mixin/template.rb +1 -1
- data/lib/chef/mixin/user_context.rb +3 -3
- data/lib/chef/mixin/which.rb +10 -38
- data/lib/chef/mixin/windows_architecture_helper.rb +6 -6
- data/lib/chef/mixin/windows_env_helper.rb +5 -5
- data/lib/chef/node/attribute.rb +2 -2
- data/lib/chef/node_map.rb +17 -4
- data/lib/chef/platform/query_helpers.rb +4 -2
- data/lib/chef/platform/rebooter.rb +1 -1
- data/lib/chef/platform/service_helpers.rb +14 -85
- data/lib/chef/provider.rb +2 -0
- data/lib/chef/provider/file.rb +2 -2
- data/lib/chef/provider/ifconfig/redhat.rb +1 -1
- data/lib/chef/provider/link.rb +3 -3
- data/lib/chef/provider/mount/solaris.rb +1 -1
- data/lib/chef/provider/package/yum.rb +1 -1
- data/lib/chef/provider/registry_key.rb +1 -1
- data/lib/chef/provider/remote_directory.rb +3 -3
- data/lib/chef/provider/remote_file/fetcher.rb +2 -2
- data/lib/chef/provider/remote_file/local_file.rb +1 -1
- data/lib/chef/provider/script.rb +3 -3
- data/lib/chef/provider/service.rb +5 -2
- data/lib/chef/provider/service/arch.rb +1 -1
- data/lib/chef/provider/service/debian.rb +4 -4
- data/lib/chef/provider/service/init.rb +1 -1
- data/lib/chef/provider/service/insserv.rb +4 -4
- data/lib/chef/provider/service/invokercd.rb +4 -4
- data/lib/chef/provider/service/redhat.rb +4 -4
- data/lib/chef/provider/service/systemd.rb +19 -3
- data/lib/chef/provider/service/upstart.rb +3 -3
- data/lib/chef/provider/subversion.rb +1 -1
- data/lib/chef/provider/systemd_unit.rb +26 -2
- data/lib/chef/provider/windows_path.rb +3 -3
- data/lib/chef/provider/windows_task.rb +4 -4
- data/lib/chef/resource.rb +1 -0
- data/lib/chef/resource/bash.rb +2 -0
- data/lib/chef/resource/batch.rb +2 -0
- data/lib/chef/resource/breakpoint.rb +3 -1
- data/lib/chef/resource/build_essential.rb +3 -3
- data/lib/chef/resource/chef_sleep.rb +70 -0
- data/lib/chef/resource/cookbook_file.rb +2 -1
- data/lib/chef/resource/csh.rb +2 -0
- data/lib/chef/resource/directory.rb +2 -0
- data/lib/chef/resource/dmg_package.rb +1 -1
- data/lib/chef/resource/dnf_package.rb +1 -1
- data/lib/chef/resource/execute.rb +2 -0
- data/lib/chef/resource/file.rb +2 -1
- data/lib/chef/resource/git.rb +2 -0
- data/lib/chef/resource/group.rb +1 -1
- data/lib/chef/resource/homebrew_package.rb +1 -1
- data/lib/chef/resource/http_request.rb +2 -0
- data/lib/chef/resource/ifconfig.rb +3 -1
- data/lib/chef/resource/ksh.rb +2 -0
- data/lib/chef/resource/link.rb +4 -2
- data/lib/chef/resource/locale.rb +1 -1
- data/lib/chef/resource/log.rb +2 -0
- data/lib/chef/resource/ohai.rb +2 -0
- data/lib/chef/resource/perl.rb +2 -0
- data/lib/chef/resource/python.rb +2 -0
- data/lib/chef/resource/reboot.rb +2 -0
- data/lib/chef/resource/registry_key.rb +2 -0
- data/lib/chef/resource/remote_directory.rb +3 -2
- data/lib/chef/resource/remote_file.rb +1 -0
- data/lib/chef/resource/ruby.rb +2 -0
- data/lib/chef/resource/ruby_block.rb +2 -0
- data/lib/chef/resource/scm.rb +2 -0
- data/lib/chef/resource/script.rb +2 -0
- data/lib/chef/resource/service.rb +9 -1
- data/lib/chef/resource/solaris_package.rb +1 -1
- data/lib/chef/resource/subversion.rb +2 -0
- data/lib/chef/resource/sudo.rb +1 -1
- data/lib/chef/resource/systemd_unit.rb +1 -0
- data/lib/chef/resource/template.rb +2 -0
- data/lib/chef/resource/user.rb +2 -0
- data/lib/chef/resource/user/aix_user.rb +2 -0
- data/lib/chef/resource/user/linux_user.rb +2 -0
- data/lib/chef/resource/user/pw_user.rb +2 -0
- data/lib/chef/resource/user/solaris_user.rb +2 -0
- data/lib/chef/resource/user/windows_user.rb +2 -0
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +1 -0
- data/lib/chef/resource/windows_ad_join.rb +1 -1
- data/lib/chef/resource/windows_env.rb +1 -1
- data/lib/chef/resource/windows_feature.rb +2 -2
- data/lib/chef/resource/windows_feature_powershell.rb +1 -1
- data/lib/chef/resource/windows_firewall_rule.rb +11 -6
- data/lib/chef/resource/windows_script.rb +3 -1
- data/lib/chef/resource/yum_package.rb +1 -1
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/run_context.rb +1 -1
- data/lib/chef/run_lock.rb +5 -5
- data/lib/chef/search/query.rb +0 -3
- data/lib/chef/train_transport.rb +3 -1
- data/lib/chef/util/powershell/ps_credential.rb +2 -2
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/util/windows/logon_session.rb +2 -2
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/eventlog.rb +2 -2
- data/spec/data/cookbooks/starter/chefignore +8 -0
- data/spec/data/cookbooks/starter/files/sample.txt +1 -0
- data/spec/data/cookbooks/starter/metadata.rb +2 -0
- data/spec/data/cookbooks/starter/recipes/default.rb +4 -0
- data/spec/functional/event_loggers/windows_eventlog_spec.rb +1 -1
- data/spec/functional/mixin/user_context_spec.rb +2 -2
- data/spec/functional/rebooter_spec.rb +1 -1
- data/spec/functional/resource/cookbook_file_spec.rb +2 -2
- data/spec/functional/resource/template_spec.rb +1 -1
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/crypto_spec.rb +1 -1
- data/spec/functional/win32/security_spec.rb +1 -1
- data/spec/functional/win32/service_manager_spec.rb +1 -1
- data/spec/functional/win32/sid_spec.rb +2 -2
- data/spec/functional/win32/version_info_spec.rb +1 -1
- data/spec/functional/win32/versions_spec.rb +1 -1
- data/spec/integration/knife/config_get_profile_spec.rb +2 -2
- data/spec/integration/knife/config_get_spec.rb +9 -2
- data/spec/integration/knife/config_list_profiles_spec.rb +2 -2
- data/spec/integration/knife/config_use_profile_spec.rb +2 -2
- data/spec/integration/knife/list_spec.rb +2 -2
- data/spec/integration/solo/solo_spec.rb +1 -1
- data/spec/support/matchers/leak.rb +1 -1
- data/spec/support/mock/platform.rb +1 -1
- data/spec/support/platform_helpers.rb +2 -0
- data/spec/support/shared/integration/integration_helper.rb +1 -1
- data/spec/support/shared/integration/knife_support.rb +1 -1
- data/spec/support/shared/unit/provider/file.rb +4 -4
- data/spec/unit/application/client_spec.rb +2 -2
- data/spec/unit/application/knife_spec.rb +17 -0
- data/spec/unit/application_spec.rb +1 -1
- data/spec/unit/chef_fs/file_pattern_spec.rb +2 -2
- data/spec/unit/chef_fs/path_util_spec.rb +3 -3
- data/spec/unit/client_spec.rb +2 -2
- data/spec/unit/cookbook/chefignore_spec.rb +31 -11
- data/spec/unit/cookbook/cookbook_version_loader_spec.rb +1 -1
- data/spec/unit/cookbook/syntax_check_spec.rb +2 -2
- data/spec/unit/cookbook_loader_spec.rb +2 -2
- data/spec/unit/cookbook_uploader_spec.rb +6 -1
- data/spec/unit/data_bag_spec.rb +2 -2
- data/spec/unit/data_collector_spec.rb +7 -0
- data/spec/unit/dsl/platform_introspection_spec.rb +31 -1
- data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +1 -1
- data/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +1 -1
- data/spec/unit/knife/cookbook_metadata_from_file_spec.rb +7 -0
- data/spec/unit/knife/cookbook_show_spec.rb +1 -1
- data/spec/unit/knife/core/gem_glob_loader_spec.rb +1 -1
- data/spec/unit/knife/core/hashed_command_loader_spec.rb +1 -1
- data/spec/unit/knife/core/subcommand_loader_spec.rb +1 -1
- data/spec/unit/knife/core/ui_spec.rb +2 -2
- data/spec/unit/knife/data_bag_from_file_spec.rb +2 -2
- data/spec/unit/knife/environment_from_file_spec.rb +2 -2
- data/spec/unit/knife/ssh_spec.rb +27 -17
- data/spec/unit/knife/status_spec.rb +1 -1
- data/spec/unit/knife/supermarket_install_spec.rb +1 -1
- data/spec/unit/mixin/path_sanity_spec.rb +3 -3
- data/spec/unit/mixin/shell_out_spec.rb +2 -3
- data/spec/unit/mixin/template_spec.rb +4 -4
- data/spec/unit/mixin/user_context_spec.rb +3 -3
- data/spec/unit/node_map_spec.rb +12 -12
- data/spec/unit/platform/query_helpers_spec.rb +9 -9
- data/spec/unit/provider/execute_spec.rb +1 -1
- data/spec/unit/provider/link_spec.rb +5 -5
- data/spec/unit/provider/package/openbsd_spec.rb +1 -1
- data/spec/unit/provider/package/smartos_spec.rb +1 -1
- data/spec/unit/provider/package/windows/exe_spec.rb +1 -1
- data/spec/unit/provider/package/windows_spec.rb +2 -2
- data/spec/unit/provider/remote_file/fetcher_spec.rb +2 -2
- data/spec/unit/provider/remote_file/local_file_spec.rb +1 -1
- data/spec/unit/provider/remote_file/network_file_spec.rb +1 -1
- data/spec/unit/provider/script_spec.rb +2 -2
- data/spec/unit/provider/service/systemd_service_spec.rb +26 -2
- data/spec/unit/provider/subversion_spec.rb +3 -3
- data/spec/unit/provider/systemd_unit_spec.rb +53 -4
- data/spec/unit/provider/user/dscl_spec.rb +1 -1
- data/spec/unit/provider_resolver_spec.rb +41 -61
- data/spec/unit/resource/chef_sleep_spec.rb +30 -0
- data/spec/unit/resource/cookbook_file_spec.rb +3 -3
- data/spec/unit/resource/remote_file_spec.rb +3 -3
- data/spec/unit/resource/windows_firewall_rule_spec.rb +69 -12
- data/spec/unit/role_spec.rb +2 -2
- data/spec/unit/shell_spec.rb +1 -1
- data/spec/unit/util/selinux_spec.rb +2 -2
- data/spec/unit/win32/error_spec.rb +1 -1
- data/spec/unit/win32/link_spec.rb +1 -1
- data/spec/unit/win32/security_spec.rb +1 -1
- data/spec/unit/windows_service_spec.rb +1 -1
- data/tasks/docs.rb +10 -2
- data/tasks/rspec.rb +8 -6
- metadata +33 -9
- data/lib/chef/mixin/train_helpers.rb +0 -60
- data/spec/unit/mash_spec.rb +0 -51
@@ -21,7 +21,7 @@ require "ostruct"
|
|
21
21
|
|
22
22
|
describe Chef::Provider::User::Dscl do
|
23
23
|
before do
|
24
|
-
allow(
|
24
|
+
allow(ChefUtils).to receive(:windows?) { false }
|
25
25
|
end
|
26
26
|
|
27
27
|
let(:shellcmdresult) { Struct.new(:stdout, :stderr, :exitstatus) }
|
@@ -35,9 +35,8 @@ describe Chef::ProviderResolver do
|
|
35
35
|
# Root the filesystem under a temp directory so Chef.path_to will point at it
|
36
36
|
when_the_repository "is empty" do
|
37
37
|
before do
|
38
|
-
allow(Chef).to receive(:
|
38
|
+
allow(Chef::Resource::DnfPackage).to receive(:which).with("dnf").and_return(nil)
|
39
39
|
end
|
40
|
-
|
41
40
|
let(:resource_name) { :service }
|
42
41
|
let(:provider) { nil }
|
43
42
|
let(:action) { :start }
|
@@ -145,51 +144,36 @@ describe Chef::ProviderResolver do
|
|
145
144
|
|
146
145
|
describe "resolving service resource" do
|
147
146
|
def stub_service_providers(*services)
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
when :redhat
|
159
|
-
file "sbin/chkconfig", ""
|
160
|
-
when :systemd
|
161
|
-
file "proc/1/comm", "systemd\n"
|
162
|
-
else
|
163
|
-
raise ArgumentError, service
|
164
|
-
end
|
147
|
+
allowed = %i{debianrcd invokercd insserv upstart redhatrcd systemd}
|
148
|
+
|
149
|
+
(allowed - services).each do |api|
|
150
|
+
allow(Chef::Provider::Service).to receive(:"#{api}?").and_return(false)
|
151
|
+
end
|
152
|
+
|
153
|
+
raise ArgumentError unless (services - allowed).empty?
|
154
|
+
|
155
|
+
services.each do |api|
|
156
|
+
allow(Chef::Provider::Service).to receive(:"#{api}?").and_return(true)
|
165
157
|
end
|
166
158
|
end
|
167
159
|
|
168
160
|
def stub_service_configs(*configs)
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
when :usr_local_etc_rcd
|
180
|
-
file "usr/local/etc/rc.d/#{service_name}", ""
|
181
|
-
when :systemd
|
182
|
-
file "proc/1/comm", "systemd\n"
|
183
|
-
file "etc/systemd/system/#{service_name}.service", ""
|
184
|
-
else
|
185
|
-
raise ArgumentError, config
|
186
|
-
end
|
161
|
+
allowed = %i{initd upstart xinetd systemd etc_rcd}
|
162
|
+
|
163
|
+
(allowed - configs).each do |type|
|
164
|
+
allow(Chef::Provider::Service).to receive(:service_script_exist?).with(type, service_name).and_return(false)
|
165
|
+
end
|
166
|
+
|
167
|
+
raise ArgumentError unless (configs - allowed).empty?
|
168
|
+
|
169
|
+
configs.each do |type|
|
170
|
+
allow(Chef::Provider::Service).to receive(:service_script_exist?).with(type, service_name).and_return(true)
|
187
171
|
end
|
188
172
|
end
|
189
173
|
|
190
174
|
shared_examples_for "an ubuntu platform with upstart, update-rc.d and systemd" do
|
191
175
|
before do
|
192
|
-
stub_service_providers(:
|
176
|
+
stub_service_providers(:debianrcd, :invokercd, :upstart, :systemd)
|
193
177
|
end
|
194
178
|
|
195
179
|
it "when both the SysV init and Systemd script exists, it returns a Service::Debian provider" do
|
@@ -213,12 +197,12 @@ describe Chef::ProviderResolver do
|
|
213
197
|
end
|
214
198
|
|
215
199
|
it "when only the SysV init script exists, it returns a Service::Systemd provider" do
|
216
|
-
stub_service_configs(:initd)
|
200
|
+
stub_service_configs(:initd, :systemd)
|
217
201
|
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
|
218
202
|
end
|
219
203
|
|
220
204
|
it "when both SysV and Upstart scripts exist, it returns a Service::Systemd provider" do
|
221
|
-
stub_service_configs(:initd, :upstart)
|
205
|
+
stub_service_configs(:initd, :systemd, :upstart)
|
222
206
|
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
|
223
207
|
end
|
224
208
|
|
@@ -235,7 +219,7 @@ describe Chef::ProviderResolver do
|
|
235
219
|
|
236
220
|
shared_examples_for "an ubuntu platform with upstart and update-rc.d" do
|
237
221
|
before do
|
238
|
-
stub_service_providers(:
|
222
|
+
stub_service_providers(:debianrcd, :invokercd, :upstart)
|
239
223
|
end
|
240
224
|
|
241
225
|
# needs to be handled by the highest priority init.d handler
|
@@ -362,7 +346,7 @@ describe Chef::ProviderResolver do
|
|
362
346
|
shared_examples_for "a debian platform using the insserv provider" do
|
363
347
|
context "with a default install" do
|
364
348
|
before do
|
365
|
-
stub_service_providers(:
|
349
|
+
stub_service_providers(:debianrcd, :invokercd, :insserv)
|
366
350
|
end
|
367
351
|
|
368
352
|
it "uses the Service::Insserv Provider to manage sysv init scripts" do
|
@@ -378,7 +362,7 @@ describe Chef::ProviderResolver do
|
|
378
362
|
|
379
363
|
context "when the user has installed upstart" do
|
380
364
|
before do
|
381
|
-
stub_service_providers(:
|
365
|
+
stub_service_providers(:debianrcd, :invokercd, :insserv, :upstart)
|
382
366
|
end
|
383
367
|
|
384
368
|
it "when only the SysV init script exists, it returns an Insserv provider" do
|
@@ -407,8 +391,8 @@ describe Chef::ProviderResolver do
|
|
407
391
|
it_behaves_like "an ubuntu platform with upstart, update-rc.d and systemd"
|
408
392
|
|
409
393
|
it "when the unit-files are missing and system-ctl list-unit-files returns an error" do
|
410
|
-
stub_service_providers(:
|
411
|
-
stub_service_configs(:initd, :upstart)
|
394
|
+
stub_service_providers(:debianrcd, :invokercd, :upstart, :systemd)
|
395
|
+
stub_service_configs(:initd, :upstart, :systemd)
|
412
396
|
mock_shellout_command("/bin/systemctl list-unit-files", exitstatus: 1)
|
413
397
|
expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
|
414
398
|
end
|
@@ -445,8 +429,8 @@ describe Chef::ProviderResolver do
|
|
445
429
|
|
446
430
|
it "always returns a Solaris provider" do
|
447
431
|
# no matter what we stub on the next two lines we should get a Solaris provider
|
448
|
-
stub_service_providers(:
|
449
|
-
stub_service_configs(:initd, :upstart, :xinetd, :
|
432
|
+
stub_service_providers(:debianrcd, :invokercd, :insserv, :upstart, :redhatrcd, :systemd)
|
433
|
+
stub_service_configs(:initd, :upstart, :xinetd, :systemd)
|
450
434
|
expect(resolved_provider).to eql(Chef::Provider::Service::Solaris)
|
451
435
|
end
|
452
436
|
end
|
@@ -460,8 +444,8 @@ describe Chef::ProviderResolver do
|
|
460
444
|
|
461
445
|
it "always returns a Windows provider" do
|
462
446
|
# no matter what we stub on the next two lines we should get a Windows provider
|
463
|
-
stub_service_providers(:
|
464
|
-
stub_service_configs(:initd, :upstart, :xinetd, :
|
447
|
+
stub_service_providers(:debianrcd, :invokercd, :insserv, :upstart, :redhatrcd, :systemd)
|
448
|
+
stub_service_configs(:initd, :upstart, :xinetd, :systemd)
|
465
449
|
expect(resolved_provider).to eql(Chef::Provider::Service::Windows)
|
466
450
|
end
|
467
451
|
end
|
@@ -475,8 +459,8 @@ describe Chef::ProviderResolver do
|
|
475
459
|
|
476
460
|
it "always returns a Macosx provider" do
|
477
461
|
# no matter what we stub on the next two lines we should get a Macosx provider
|
478
|
-
stub_service_providers(:
|
479
|
-
stub_service_configs(:initd, :upstart, :xinetd, :
|
462
|
+
stub_service_providers(:debianrcd, :invokercd, :insserv, :upstart, :redhatrcd, :systemd)
|
463
|
+
stub_service_configs(:initd, :upstart, :xinetd, :systemd)
|
480
464
|
expect(resolved_provider).to eql(Chef::Provider::Service::Macosx)
|
481
465
|
end
|
482
466
|
end
|
@@ -484,7 +468,6 @@ describe Chef::ProviderResolver do
|
|
484
468
|
on_platform "freebsd", os: "freebsd", platform_version: "10.3" do
|
485
469
|
it "returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
|
486
470
|
stub_service_providers
|
487
|
-
stub_service_configs(:usr_local_etc_rcd)
|
488
471
|
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
|
489
472
|
end
|
490
473
|
|
@@ -495,15 +478,14 @@ describe Chef::ProviderResolver do
|
|
495
478
|
end
|
496
479
|
|
497
480
|
it "always returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
|
498
|
-
|
499
|
-
|
500
|
-
stub_service_configs(:usr_local_etc_rcd, :initd, :upstart, :xinetd, :systemd)
|
481
|
+
stub_service_providers(:debianrcd, :invokercd, :insserv, :upstart, :redhatrcd, :systemd)
|
482
|
+
stub_service_configs(:initd, :upstart, :xinetd, :systemd)
|
501
483
|
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
|
502
484
|
end
|
503
485
|
|
504
486
|
it "always returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
|
505
487
|
# should only care about :etc_rcd stub in the service configs
|
506
|
-
stub_service_providers(:
|
488
|
+
stub_service_providers(:debianrcd, :invokercd, :insserv, :upstart, :redhatrcd, :systemd)
|
507
489
|
stub_service_configs(:etc_rcd, :initd, :upstart, :xinetd, :systemd)
|
508
490
|
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
|
509
491
|
end
|
@@ -518,7 +500,6 @@ describe Chef::ProviderResolver do
|
|
518
500
|
on_platform "netbsd", os: "netbsd", platform_version: "7.0.1" do
|
519
501
|
it "returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
|
520
502
|
stub_service_providers
|
521
|
-
stub_service_configs(:usr_local_etc_rcd)
|
522
503
|
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
|
523
504
|
end
|
524
505
|
|
@@ -529,15 +510,14 @@ describe Chef::ProviderResolver do
|
|
529
510
|
end
|
530
511
|
|
531
512
|
it "always returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
|
532
|
-
|
533
|
-
|
534
|
-
stub_service_configs(:usr_local_etc_rcd, :initd, :upstart, :xinetd, :systemd)
|
513
|
+
stub_service_providers(:debianrcd, :invokercd, :insserv, :upstart, :redhatrcd, :systemd)
|
514
|
+
stub_service_configs(:initd, :upstart, :xinetd, :systemd)
|
535
515
|
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
|
536
516
|
end
|
537
517
|
|
538
518
|
it "always returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do
|
539
519
|
# should only care about :etc_rcd stub in the service configs
|
540
|
-
stub_service_providers(:
|
520
|
+
stub_service_providers(:debianrcd, :invokercd, :insserv, :upstart, :redhatrcd, :systemd)
|
541
521
|
stub_service_configs(:etc_rcd, :initd, :upstart, :xinetd, :systemd)
|
542
522
|
expect(resolved_provider).to eql(Chef::Provider::Service::Freebsd)
|
543
523
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: 2019, Chef Software, Inc.
|
3
|
+
# License:: Apache License, Version 2.0
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
require "spec_helper"
|
19
|
+
|
20
|
+
describe Chef::Resource::ChefSleep do
|
21
|
+
let(:resource) { Chef::Resource::ChefSleep.new("30") }
|
22
|
+
|
23
|
+
it "sets the default action as :sleep" do
|
24
|
+
expect(resource.action).to eql([:sleep])
|
25
|
+
end
|
26
|
+
|
27
|
+
it "sleep is the name property and it coerces to an Integer" do
|
28
|
+
expect(resource.seconds).to eql(30)
|
29
|
+
end
|
30
|
+
end
|
@@ -53,7 +53,7 @@ describe Chef::Resource::CookbookFile do
|
|
53
53
|
|
54
54
|
describe "when it has a backup number, group, mode, owner, source, checksum, and cookbook on nix or path, rights, deny_rights, checksum on windows" do
|
55
55
|
before do
|
56
|
-
if
|
56
|
+
if ChefUtils.windows?
|
57
57
|
resource.path("C:/temp/origin/file.txt")
|
58
58
|
resource.rights(:read, "Everyone")
|
59
59
|
resource.deny_rights(:full_control, "Clumsy_Sam")
|
@@ -70,7 +70,7 @@ describe Chef::Resource::CookbookFile do
|
|
70
70
|
|
71
71
|
it "describes the state" do
|
72
72
|
state = resource.state_for_resource_reporter
|
73
|
-
if
|
73
|
+
if ChefUtils.windows?
|
74
74
|
puts state
|
75
75
|
expect(state[:rights]).to eq([{ permissions: :read, principals: "Everyone" }])
|
76
76
|
expect(state[:deny_rights]).to eq([{ permissions: :full_control, principals: "Clumsy_Sam" }])
|
@@ -83,7 +83,7 @@ describe Chef::Resource::CookbookFile do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
it "returns the path as its identity" do
|
86
|
-
if
|
86
|
+
if ChefUtils.windows?
|
87
87
|
expect(resource.identity).to eq("C:/temp/origin/file.txt")
|
88
88
|
else
|
89
89
|
expect(resource.identity).to eq("/tmp/origin/file.txt")
|
@@ -181,7 +181,7 @@ describe Chef::Resource::RemoteFile do
|
|
181
181
|
|
182
182
|
describe "when it has group, mode, owner, source, and checksum" do
|
183
183
|
before do
|
184
|
-
if
|
184
|
+
if ChefUtils.windows?
|
185
185
|
resource.path("C:/temp/origin/file.txt")
|
186
186
|
resource.rights(:read, "Everyone")
|
187
187
|
resource.deny_rights(:full_control, "Clumsy_Sam")
|
@@ -197,7 +197,7 @@ describe Chef::Resource::RemoteFile do
|
|
197
197
|
|
198
198
|
it "describes its state" do
|
199
199
|
state = resource.state_for_resource_reporter
|
200
|
-
if
|
200
|
+
if ChefUtils.windows?
|
201
201
|
puts state
|
202
202
|
expect(state[:rights]).to eq([{ permissions: :read, principals: "Everyone" }])
|
203
203
|
expect(state[:deny_rights]).to eq([{ permissions: :full_control, principals: "Clumsy_Sam" }])
|
@@ -210,7 +210,7 @@ describe Chef::Resource::RemoteFile do
|
|
210
210
|
end
|
211
211
|
|
212
212
|
it "returns the path as its identity" do
|
213
|
-
if
|
213
|
+
if ChefUtils.windows?
|
214
214
|
expect(resource.identity).to eq("C:/temp/origin/file.txt")
|
215
215
|
else
|
216
216
|
expect(resource.identity).to eq("/this/path/")
|
@@ -141,20 +141,32 @@ describe Chef::Resource::WindowsFirewallRule do
|
|
141
141
|
|
142
142
|
it "the profile property accepts :public, :private, :domain, :any and :notapplicable" do
|
143
143
|
resource.profile(:public)
|
144
|
-
expect(resource.profile).to eql(:public)
|
144
|
+
expect(resource.profile).to eql([:public])
|
145
145
|
resource.profile(:private)
|
146
|
-
expect(resource.profile).to eql(:private)
|
146
|
+
expect(resource.profile).to eql([:private])
|
147
147
|
resource.profile(:domain)
|
148
|
-
expect(resource.profile).to eql(:domain)
|
148
|
+
expect(resource.profile).to eql([:domain])
|
149
149
|
resource.profile(:any)
|
150
|
-
expect(resource.profile).to eql(:any)
|
150
|
+
expect(resource.profile).to eql([:any])
|
151
151
|
resource.profile(:notapplicable)
|
152
|
-
expect(resource.profile).to eql(:notapplicable)
|
152
|
+
expect(resource.profile).to eql([:notapplicable])
|
153
|
+
end
|
154
|
+
|
155
|
+
it "the profile property raises on any unknown values" do
|
156
|
+
expect { resource.profile(:other) }.to raise_error(Chef::Exceptions::ValidationFailed)
|
157
|
+
expect { resource.profile(%i{public other}) }.to raise_error(Chef::Exceptions::ValidationFailed)
|
153
158
|
end
|
154
159
|
|
155
160
|
it "the profile property coerces strings to symbols" do
|
156
161
|
resource.profile("Public")
|
157
|
-
expect(resource.profile).to eql(:public)
|
162
|
+
expect(resource.profile).to eql([:public])
|
163
|
+
resource.profile([:private, "Public"])
|
164
|
+
expect(resource.profile).to eql(%i{private public})
|
165
|
+
end
|
166
|
+
|
167
|
+
it "the profile property supports multiple profiles" do
|
168
|
+
resource.profile(%w{Private Public})
|
169
|
+
expect(resource.profile).to eql(%i{private public})
|
158
170
|
end
|
159
171
|
|
160
172
|
it "the program property accepts strings" do
|
@@ -237,7 +249,17 @@ describe Chef::Resource::WindowsFirewallRule do
|
|
237
249
|
|
238
250
|
it "sets LocalPort" do
|
239
251
|
resource.local_port("80")
|
240
|
-
expect(provider.firewall_command("New")).to eql("New-NetFirewallRule -Name 'test_rule' -DisplayName 'test_rule' -Description 'Firewall rule' -LocalPort 80 -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
252
|
+
expect(provider.firewall_command("New")).to eql("New-NetFirewallRule -Name 'test_rule' -DisplayName 'test_rule' -Description 'Firewall rule' -LocalPort '80' -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
253
|
+
end
|
254
|
+
|
255
|
+
it "sets LocalPort with int" do
|
256
|
+
resource.local_port(80)
|
257
|
+
expect(provider.firewall_command("New")).to eql("New-NetFirewallRule -Name 'test_rule' -DisplayName 'test_rule' -Description 'Firewall rule' -LocalPort '80' -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
258
|
+
end
|
259
|
+
|
260
|
+
it "sets multiple LocalPorts" do
|
261
|
+
resource.local_port(%w{80 RPC})
|
262
|
+
expect(provider.firewall_command("New")).to eql("New-NetFirewallRule -Name 'test_rule' -DisplayName 'test_rule' -Description 'Firewall rule' -LocalPort '80', 'RPC' -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
241
263
|
end
|
242
264
|
|
243
265
|
it "sets RemoteAddress" do
|
@@ -247,7 +269,17 @@ describe Chef::Resource::WindowsFirewallRule do
|
|
247
269
|
|
248
270
|
it "sets RemotePort" do
|
249
271
|
resource.remote_port("443")
|
250
|
-
expect(provider.firewall_command("New")).to eql("New-NetFirewallRule -Name 'test_rule' -DisplayName 'test_rule' -Description 'Firewall rule' -RemotePort 443 -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
272
|
+
expect(provider.firewall_command("New")).to eql("New-NetFirewallRule -Name 'test_rule' -DisplayName 'test_rule' -Description 'Firewall rule' -RemotePort '443' -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
273
|
+
end
|
274
|
+
|
275
|
+
it "sets RemotePort with int" do
|
276
|
+
resource.remote_port(443)
|
277
|
+
expect(provider.firewall_command("New")).to eql("New-NetFirewallRule -Name 'test_rule' -DisplayName 'test_rule' -Description 'Firewall rule' -RemotePort '443' -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
278
|
+
end
|
279
|
+
|
280
|
+
it "sets multiple RemotePorts" do
|
281
|
+
resource.remote_port(%w{443 445})
|
282
|
+
expect(provider.firewall_command("New")).to eql("New-NetFirewallRule -Name 'test_rule' -DisplayName 'test_rule' -Description 'Firewall rule' -RemotePort '443', '445' -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
251
283
|
end
|
252
284
|
|
253
285
|
it "sets Direction" do
|
@@ -270,6 +302,11 @@ describe Chef::Resource::WindowsFirewallRule do
|
|
270
302
|
expect(provider.firewall_command("New")).to eql("New-NetFirewallRule -Name 'test_rule' -DisplayName 'test_rule' -Description 'Firewall rule' -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'private' -InterfaceType 'any' -Enabled 'true'")
|
271
303
|
end
|
272
304
|
|
305
|
+
it "sets multiple Profiles (must be comma-plus-space delimited for PowerShell to treat as an array)" do
|
306
|
+
resource.profile(%i{private public})
|
307
|
+
expect(provider.firewall_command("New")).to eql("New-NetFirewallRule -Name 'test_rule' -DisplayName 'test_rule' -Description 'Firewall rule' -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'private', 'public' -InterfaceType 'any' -Enabled 'true'")
|
308
|
+
end
|
309
|
+
|
273
310
|
it "sets Program" do
|
274
311
|
resource.program("C:/calc.exe")
|
275
312
|
expect(provider.firewall_command("New")).to eql("New-NetFirewallRule -Name 'test_rule' -DisplayName 'test_rule' -Description 'Firewall rule' -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -Program 'C:/calc.exe' -InterfaceType 'any' -Enabled 'true'")
|
@@ -305,7 +342,7 @@ describe Chef::Resource::WindowsFirewallRule do
|
|
305
342
|
resource.service("SomeService")
|
306
343
|
resource.interface_type(:remoteaccess)
|
307
344
|
resource.enabled(false)
|
308
|
-
expect(provider.firewall_command("New")).to eql("New-NetFirewallRule -Name 'test_rule_the_second' -DisplayName 'test_rule_the_second' -Description 'some other rule' -LocalAddress '192.168.40.40' -LocalPort 80 -RemoteAddress '8.8.4.4' -RemotePort 8081 -Direction 'outbound' -Protocol 'UDP' -Action 'notconfigured' -Profile 'domain' -Program '%WINDIR%\\System32\\lsass.exe' -Service 'SomeService' -InterfaceType 'remoteaccess' -Enabled 'false'")
|
345
|
+
expect(provider.firewall_command("New")).to eql("New-NetFirewallRule -Name 'test_rule_the_second' -DisplayName 'test_rule_the_second' -Description 'some other rule' -LocalAddress '192.168.40.40' -LocalPort '80' -RemoteAddress '8.8.4.4' -RemotePort '8081' -Direction 'outbound' -Protocol 'UDP' -Action 'notconfigured' -Profile 'domain' -Program '%WINDIR%\\System32\\lsass.exe' -Service 'SomeService' -InterfaceType 'remoteaccess' -Enabled 'false'")
|
309
346
|
end
|
310
347
|
end
|
311
348
|
|
@@ -326,7 +363,17 @@ describe Chef::Resource::WindowsFirewallRule do
|
|
326
363
|
|
327
364
|
it "sets LocalPort" do
|
328
365
|
resource.local_port("80")
|
329
|
-
expect(provider.firewall_command("Set")).to eql("Set-NetFirewallRule -Name 'test_rule' -Description 'Firewall rule' -LocalPort 80 -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
366
|
+
expect(provider.firewall_command("Set")).to eql("Set-NetFirewallRule -Name 'test_rule' -Description 'Firewall rule' -LocalPort '80' -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
367
|
+
end
|
368
|
+
|
369
|
+
it "sets LocalPort with int" do
|
370
|
+
resource.local_port(80)
|
371
|
+
expect(provider.firewall_command("Set")).to eql("Set-NetFirewallRule -Name 'test_rule' -Description 'Firewall rule' -LocalPort '80' -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
372
|
+
end
|
373
|
+
|
374
|
+
it "sets multiple LocalPorts (must be comma-plus-space delimited for PowerShell to treat as an array)" do
|
375
|
+
resource.local_port(%w{80 8080})
|
376
|
+
expect(provider.firewall_command("Set")).to eql("Set-NetFirewallRule -Name 'test_rule' -Description 'Firewall rule' -LocalPort '80', '8080' -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
330
377
|
end
|
331
378
|
|
332
379
|
it "sets RemoteAddress" do
|
@@ -336,7 +383,17 @@ describe Chef::Resource::WindowsFirewallRule do
|
|
336
383
|
|
337
384
|
it "sets RemotePort" do
|
338
385
|
resource.remote_port("443")
|
339
|
-
expect(provider.firewall_command("Set")).to eql("Set-NetFirewallRule -Name 'test_rule' -Description 'Firewall rule' -RemotePort 443 -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
386
|
+
expect(provider.firewall_command("Set")).to eql("Set-NetFirewallRule -Name 'test_rule' -Description 'Firewall rule' -RemotePort '443' -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
387
|
+
end
|
388
|
+
|
389
|
+
it "sets RemotePort with int" do
|
390
|
+
resource.remote_port(443)
|
391
|
+
expect(provider.firewall_command("Set")).to eql("Set-NetFirewallRule -Name 'test_rule' -Description 'Firewall rule' -RemotePort '443' -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
392
|
+
end
|
393
|
+
|
394
|
+
it "sets multiple RemotePorts (must be comma-plus-space delimited for PowerShell to treat as an array)" do
|
395
|
+
resource.remote_port(%w{443 445})
|
396
|
+
expect(provider.firewall_command("Set")).to eql("Set-NetFirewallRule -Name 'test_rule' -Description 'Firewall rule' -RemotePort '443', '445' -Direction 'inbound' -Protocol 'TCP' -Action 'allow' -Profile 'any' -InterfaceType 'any' -Enabled 'true'")
|
340
397
|
end
|
341
398
|
|
342
399
|
it "sets Direction" do
|
@@ -394,7 +451,7 @@ describe Chef::Resource::WindowsFirewallRule do
|
|
394
451
|
resource.service("SomeService")
|
395
452
|
resource.interface_type(:remoteaccess)
|
396
453
|
resource.enabled(false)
|
397
|
-
expect(provider.firewall_command("Set")).to eql("Set-NetFirewallRule -Name 'test_rule_the_second' -Description 'some other rule' -LocalAddress '192.168.40.40' -LocalPort 80 -RemoteAddress '8.8.4.4' -RemotePort 8081 -Direction 'outbound' -Protocol 'UDP' -Action 'notconfigured' -Profile 'domain' -Program '%WINDIR%\\System32\\lsass.exe' -Service 'SomeService' -InterfaceType 'remoteaccess' -Enabled 'false'")
|
454
|
+
expect(provider.firewall_command("Set")).to eql("Set-NetFirewallRule -Name 'test_rule_the_second' -Description 'some other rule' -LocalAddress '192.168.40.40' -LocalPort '80' -RemoteAddress '8.8.4.4' -RemotePort '8081' -Direction 'outbound' -Protocol 'UDP' -Action 'notconfigured' -Profile 'domain' -Program '%WINDIR%\\System32\\lsass.exe' -Service 'SomeService' -InterfaceType 'remoteaccess' -Enabled 'false'")
|
398
455
|
end
|
399
456
|
end
|
400
457
|
end
|