chef 12.4.0.rc.0-universal-mingw32 → 12.4.0.rc.2-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +12 -1
- data/lib/chef/api_client.rb +130 -26
- data/lib/chef/application.rb +0 -1
- data/lib/chef/application/client.rb +8 -19
- data/lib/chef/audit/audit_reporter.rb +12 -7
- data/lib/chef/audit/logger.rb +36 -0
- data/lib/chef/audit/runner.rb +4 -2
- data/lib/chef/chef_class.rb +62 -11
- data/lib/chef/client.rb +587 -207
- data/lib/chef/config.rb +0 -1
- data/lib/chef/dsl/recipe.rb +45 -56
- data/lib/chef/dsl/resources.rb +3 -2
- data/lib/chef/event_dispatch/base.rb +7 -2
- data/lib/chef/exceptions.rb +4 -1
- data/lib/chef/file_content_management/deploy/mv_windows.rb +16 -6
- data/lib/chef/formatters/doc.rb +15 -7
- data/lib/chef/formatters/error_inspectors/api_error_formatting.rb +10 -7
- data/lib/chef/guard_interpreter/default_guard_interpreter.rb +2 -0
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +4 -1
- data/lib/chef/http/authenticator.rb +7 -2
- data/lib/chef/knife.rb +16 -4
- data/lib/chef/knife/client_create.rb +55 -31
- data/lib/chef/knife/core/generic_presenter.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +1 -1
- data/lib/chef/knife/osc_user_create.rb +97 -0
- data/lib/chef/knife/osc_user_delete.rb +51 -0
- data/lib/chef/knife/osc_user_edit.rb +58 -0
- data/lib/chef/knife/osc_user_list.rb +47 -0
- data/lib/chef/knife/osc_user_reregister.rb +64 -0
- data/lib/chef/knife/osc_user_show.rb +54 -0
- data/lib/chef/knife/user_create.rb +95 -36
- data/lib/chef/knife/user_delete.rb +52 -2
- data/lib/chef/knife/user_edit.rb +37 -7
- data/lib/chef/knife/user_list.rb +3 -0
- data/lib/chef/knife/user_reregister.rb +39 -8
- data/lib/chef/knife/user_show.rb +30 -1
- data/lib/chef/mixin/api_version_request_handling.rb +66 -0
- data/lib/chef/mixin/convert_to_class_name.rb +10 -4
- data/lib/chef/mixin/deprecation.rb +24 -0
- data/lib/chef/mixin/powershell_out.rb +98 -0
- data/lib/chef/mixin/provides.rb +5 -18
- data/lib/chef/mixin/uris.rb +11 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +5 -2
- data/lib/chef/mixin/windows_env_helper.rb +11 -2
- data/lib/chef/node_map.rb +130 -75
- data/lib/chef/osc_user.rb +194 -0
- data/lib/chef/platform/provider_mapping.rb +2 -269
- data/lib/chef/platform/provider_priority_map.rb +6 -69
- data/lib/chef/platform/query_helpers.rb +5 -0
- data/lib/chef/platform/resource_priority_map.rb +12 -15
- data/lib/chef/policy_builder/policyfile.rb +1 -0
- data/lib/chef/provider.rb +19 -0
- data/lib/chef/provider/directory.rb +3 -0
- data/lib/chef/provider/dsc_resource.rb +8 -1
- data/lib/chef/provider/file.rb +1 -0
- data/lib/chef/provider/group/aix.rb +1 -0
- data/lib/chef/provider/group/dscl.rb +1 -1
- data/lib/chef/provider/group/gpasswd.rb +1 -0
- data/lib/chef/provider/group/groupmod.rb +1 -1
- data/lib/chef/provider/group/pw.rb +1 -0
- data/lib/chef/provider/group/suse.rb +2 -0
- data/lib/chef/provider/group/usermod.rb +2 -1
- data/lib/chef/provider/group/windows.rb +1 -1
- data/lib/chef/provider/ifconfig.rb +2 -0
- data/lib/chef/provider/ifconfig/aix.rb +1 -0
- data/lib/chef/provider/ifconfig/debian.rb +2 -0
- data/lib/chef/provider/ifconfig/redhat.rb +1 -0
- data/lib/chef/provider/lwrp_base.rb +4 -0
- data/lib/chef/provider/mount.rb +0 -1
- data/lib/chef/provider/mount/aix.rb +1 -0
- data/lib/chef/provider/mount/mount.rb +2 -0
- data/lib/chef/provider/mount/solaris.rb +2 -0
- data/lib/chef/provider/package.rb +55 -0
- data/lib/chef/provider/package/aix.rb +7 -7
- data/lib/chef/provider/package/apt.rb +3 -3
- data/lib/chef/provider/package/dpkg.rb +4 -4
- data/lib/chef/provider/package/easy_install.rb +5 -5
- data/lib/chef/provider/package/freebsd/base.rb +2 -2
- data/lib/chef/provider/package/freebsd/pkg.rb +6 -6
- data/lib/chef/provider/package/freebsd/pkgng.rb +5 -5
- data/lib/chef/provider/package/freebsd/port.rb +4 -4
- data/lib/chef/provider/package/homebrew.rb +2 -2
- data/lib/chef/provider/package/ips.rb +4 -4
- data/lib/chef/provider/package/macports.rb +5 -6
- data/lib/chef/provider/package/openbsd.rb +4 -5
- data/lib/chef/provider/package/pacman.rb +4 -4
- data/lib/chef/provider/package/portage.rb +2 -0
- data/lib/chef/provider/package/rpm.rb +7 -8
- data/lib/chef/provider/package/rubygems.rb +5 -12
- data/lib/chef/provider/package/smartos.rb +4 -4
- data/lib/chef/provider/package/solaris.rb +7 -7
- data/lib/chef/provider/package/windows/msi.rb +1 -1
- data/lib/chef/provider/package/yum.rb +4 -6
- data/lib/chef/provider/package/zypper.rb +16 -14
- data/lib/chef/provider/powershell_script.rb +129 -47
- data/lib/chef/provider/remote_file/content.rb +4 -1
- data/lib/chef/provider/remote_file/local_file.rb +10 -4
- data/lib/chef/provider/service.rb +44 -0
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/init.rb +1 -0
- data/lib/chef/provider/service/macosx.rb +1 -1
- data/lib/chef/provider/service/windows.rb +0 -1
- data/lib/chef/provider/user.rb +1 -1
- data/lib/chef/provider/user/aix.rb +3 -2
- data/lib/chef/provider/user/pw.rb +1 -0
- data/lib/chef/provider/user/solaris.rb +2 -0
- data/lib/chef/provider/user/useradd.rb +1 -0
- data/lib/chef/provider_resolver.rb +87 -134
- data/lib/chef/resource.rb +274 -68
- data/lib/chef/resource/apt_package.rb +0 -2
- data/lib/chef/resource/bash.rb +0 -2
- data/lib/chef/resource/batch.rb +1 -1
- data/lib/chef/resource/bff_package.rb +0 -7
- data/lib/chef/resource/breakpoint.rb +3 -6
- data/lib/chef/resource/chef_gem.rb +0 -3
- data/lib/chef/resource/cookbook_file.rb +1 -3
- data/lib/chef/resource/cron.rb +2 -4
- data/lib/chef/resource/csh.rb +0 -2
- data/lib/chef/resource/deploy.rb +9 -6
- data/lib/chef/resource/deploy_revision.rb +0 -14
- data/lib/chef/resource/directory.rb +2 -4
- data/lib/chef/resource/dpkg_package.rb +0 -5
- data/lib/chef/resource/dsc_resource.rb +2 -3
- data/lib/chef/resource/dsc_script.rb +2 -3
- data/lib/chef/resource/easy_install_package.rb +0 -7
- data/lib/chef/resource/env.rb +3 -3
- data/lib/chef/resource/erl_call.rb +2 -5
- data/lib/chef/resource/execute.rb +2 -4
- data/lib/chef/resource/file.rb +2 -4
- data/lib/chef/resource/freebsd_package.rb +0 -5
- data/lib/chef/resource/gem_package.rb +0 -3
- data/lib/chef/resource/git.rb +0 -3
- data/lib/chef/resource/group.rb +2 -4
- data/lib/chef/resource/homebrew_package.rb +0 -2
- data/lib/chef/resource/http_request.rb +3 -4
- data/lib/chef/resource/ifconfig.rb +3 -4
- data/lib/chef/resource/ips_package.rb +2 -2
- data/lib/chef/resource/link.rb +3 -5
- data/lib/chef/resource/log.rb +2 -4
- data/lib/chef/resource/lwrp_base.rb +10 -61
- data/lib/chef/resource/macosx_service.rb +1 -2
- data/lib/chef/resource/macports_package.rb +0 -7
- data/lib/chef/resource/mdadm.rb +2 -5
- data/lib/chef/resource/mount.rb +2 -4
- data/lib/chef/resource/ohai.rb +2 -4
- data/lib/chef/resource/openbsd_package.rb +0 -6
- data/lib/chef/resource/package.rb +9 -6
- data/lib/chef/resource/pacman_package.rb +0 -7
- data/lib/chef/resource/paludis_package.rb +2 -3
- data/lib/chef/resource/perl.rb +0 -3
- data/lib/chef/resource/portage_package.rb +0 -3
- data/lib/chef/resource/powershell_script.rb +1 -2
- data/lib/chef/resource/python.rb +0 -3
- data/lib/chef/resource/reboot.rb +1 -3
- data/lib/chef/resource/registry_key.rb +3 -5
- data/lib/chef/resource/remote_directory.rb +3 -5
- data/lib/chef/resource/remote_file.rb +4 -5
- data/lib/chef/resource/route.rb +3 -5
- data/lib/chef/resource/rpm_package.rb +0 -2
- data/lib/chef/resource/ruby.rb +0 -4
- data/lib/chef/resource/ruby_block.rb +2 -4
- data/lib/chef/resource/scm.rb +3 -5
- data/lib/chef/resource/script.rb +0 -3
- data/lib/chef/resource/service.rb +3 -5
- data/lib/chef/resource/smartos_package.rb +0 -9
- data/lib/chef/resource/solaris_package.rb +0 -10
- data/lib/chef/resource/subversion.rb +1 -3
- data/lib/chef/resource/template.rb +0 -4
- data/lib/chef/resource/timestamped_deploy.rb +0 -4
- data/lib/chef/resource/user.rb +2 -5
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -7
- data/lib/chef/resource/windows_package.rb +3 -3
- data/lib/chef/resource/windows_script.rb +2 -2
- data/lib/chef/resource/windows_service.rb +3 -3
- data/lib/chef/resource/yum_package.rb +0 -3
- data/lib/chef/resource/zypper_package.rb +27 -0
- data/lib/chef/resource_builder.rb +7 -0
- data/lib/chef/resource_reporter.rb +1 -1
- data/lib/chef/resource_resolver.rb +108 -62
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/rest.rb +1 -0
- data/lib/chef/server_api.rb +2 -0
- data/lib/chef/user.rb +193 -42
- data/lib/chef/util/backup.rb +9 -1
- data/lib/chef/util/path_helper.rb +0 -1
- data/lib/chef/version.rb +1 -1
- data/spec/functional/audit/runner_spec.rb +22 -42
- data/spec/functional/mixin/powershell_out_spec.rb +43 -0
- data/spec/functional/resource/execute_spec.rb +9 -2
- data/spec/functional/resource/file_spec.rb +25 -0
- data/spec/functional/resource/group_spec.rb +5 -0
- data/spec/functional/resource/link_spec.rb +5 -11
- data/spec/functional/resource/powershell_spec.rb +40 -5
- data/spec/functional/resource/user/useradd_spec.rb +10 -18
- data/spec/integration/recipes/lwrp_spec.rb +57 -0
- data/spec/integration/recipes/provider_choice.rb +2 -7
- data/spec/integration/recipes/recipe_dsl_spec.rb +517 -19
- data/spec/spec_helper.rb +1 -1
- data/spec/support/lib/chef/provider/openldap_includer.rb +29 -0
- data/spec/support/lib/chef/resource/cat.rb +0 -2
- data/spec/support/lib/chef/resource/one_two_three_four.rb +0 -6
- data/spec/support/lib/chef/resource/openldap_includer.rb +27 -0
- data/spec/support/lib/chef/resource/with_state.rb +0 -9
- data/spec/support/lib/chef/resource/zen_follower.rb +0 -6
- data/spec/support/lib/chef/resource/zen_master.rb +1 -6
- data/spec/support/shared/context/client.rb +277 -0
- data/spec/support/shared/examples/client.rb +53 -0
- data/spec/support/shared/functional/file_resource.rb +0 -4
- data/spec/support/shared/functional/securable_resource.rb +0 -24
- data/spec/support/shared/functional/securable_resource_with_reporting.rb +4 -4
- data/spec/support/shared/functional/windows_script.rb +1 -1
- data/spec/support/shared/unit/api_versioning.rb +77 -0
- data/spec/support/shared/unit/knife_shared.rb +40 -0
- data/spec/support/shared/unit/user_and_client_shared.rb +115 -0
- data/spec/unit/api_client_spec.rb +189 -14
- data/spec/unit/application/client_spec.rb +0 -5
- data/spec/unit/audit/audit_reporter_spec.rb +58 -14
- data/spec/unit/audit/logger_spec.rb +42 -0
- data/spec/unit/audit/runner_spec.rb +2 -2
- data/spec/unit/chef_fs/file_pattern_spec.rb +3 -15
- data/spec/unit/client_spec.rb +58 -374
- data/spec/unit/cookbook_spec.rb +0 -9
- data/spec/unit/cookbook_version_spec.rb +0 -20
- data/spec/unit/deprecation_spec.rb +55 -0
- data/spec/unit/dsl/resources_spec.rb +85 -0
- data/spec/unit/exceptions_spec.rb +2 -2
- data/spec/unit/file_content_management/deploy/mv_windows_spec.rb +60 -0
- data/spec/unit/formatters/doc_spec.rb +46 -0
- data/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +12 -10
- data/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +8 -0
- data/spec/unit/http/authenticator_spec.rb +11 -2
- data/spec/unit/knife/client_create_spec.rb +122 -51
- data/spec/unit/knife/core/subcommand_loader_spec.rb +19 -3
- data/spec/unit/knife/core/ui_spec.rb +14 -0
- data/spec/unit/knife/osc_user_create_spec.rb +93 -0
- data/spec/unit/knife/osc_user_delete_spec.rb +44 -0
- data/spec/unit/knife/osc_user_edit_spec.rb +52 -0
- data/spec/unit/knife/osc_user_list_spec.rb +37 -0
- data/spec/unit/knife/osc_user_reregister_spec.rb +58 -0
- data/spec/unit/knife/osc_user_show_spec.rb +46 -0
- data/spec/unit/knife/user_create_spec.rb +177 -51
- data/spec/unit/knife/user_delete_spec.rb +34 -8
- data/spec/unit/knife/user_edit_spec.rb +31 -12
- data/spec/unit/knife/user_list_spec.rb +7 -3
- data/spec/unit/knife/user_reregister_spec.rb +38 -17
- data/spec/unit/knife/user_show_spec.rb +35 -11
- data/spec/unit/knife_spec.rb +10 -4
- data/spec/unit/lwrp_spec.rb +228 -54
- data/spec/unit/mixin/api_version_request_handling_spec.rb +127 -0
- data/spec/unit/mixin/command_spec.rb +1 -2
- data/spec/unit/mixin/powershell_out_spec.rb +70 -0
- data/spec/unit/mixin/uris_spec.rb +23 -11
- data/spec/unit/node_map_spec.rb +4 -1
- data/spec/unit/osc_user_spec.rb +276 -0
- data/spec/unit/platform_spec.rb +0 -60
- data/spec/unit/provider/deploy_spec.rb +1 -1
- data/spec/unit/provider/directory_spec.rb +199 -135
- data/spec/unit/provider/ifconfig/debian_spec.rb +0 -10
- data/spec/unit/provider/package/aix_spec.rb +16 -16
- data/spec/unit/provider/package/dpkg_spec.rb +2 -2
- data/spec/unit/provider/package/freebsd/pkg_spec.rb +13 -13
- data/spec/unit/provider/package/freebsd/pkgng_spec.rb +9 -9
- data/spec/unit/provider/package/freebsd/port_spec.rb +7 -7
- data/spec/unit/provider/package/ips_spec.rb +22 -22
- data/spec/unit/provider/package/macports_spec.rb +10 -10
- data/spec/unit/provider/package/openbsd_spec.rb +4 -26
- data/spec/unit/provider/package/pacman_spec.rb +5 -5
- data/spec/unit/provider/package/rpm_spec.rb +14 -14
- data/spec/unit/provider/package/rubygems_spec.rb +10 -44
- data/spec/unit/provider/package/smartos_spec.rb +4 -4
- data/spec/unit/provider/package/solaris_spec.rb +11 -11
- data/spec/unit/provider/package/zypper_spec.rb +125 -90
- data/spec/unit/provider/package_spec.rb +34 -0
- data/spec/unit/provider/powershell_spec.rb +53 -11
- data/spec/unit/provider/remote_directory_spec.rb +2 -2
- data/spec/unit/provider/remote_file/local_file_spec.rb +25 -6
- data/spec/unit/provider/service/freebsd_service_spec.rb +0 -12
- data/spec/unit/provider/user_spec.rb +3 -3
- data/spec/unit/provider_resolver_spec.rb +463 -327
- data/spec/unit/recipe_spec.rb +42 -15
- data/spec/unit/resource/breakpoint_spec.rb +1 -1
- data/spec/unit/resource/erl_call_spec.rb +1 -1
- data/spec/unit/resource/file_spec.rb +1 -1
- data/spec/unit/resource/ifconfig_spec.rb +10 -6
- data/spec/unit/resource/remote_file_spec.rb +5 -0
- data/spec/unit/resource/route_spec.rb +1 -1
- data/spec/unit/resource/ruby_block_spec.rb +2 -2
- data/spec/unit/resource/template_spec.rb +1 -1
- data/spec/unit/resource/timestamped_deploy_spec.rb +1 -2
- data/spec/unit/resource/windows_service_spec.rb +1 -1
- data/spec/unit/resource_spec.rb +99 -13
- data/spec/unit/rest_spec.rb +5 -5
- data/spec/unit/run_context_spec.rb +41 -0
- data/spec/unit/runner_spec.rb +2 -2
- data/spec/unit/user_spec.rb +406 -93
- data/tasks/maintainers.rb +69 -0
- metadata +37 -4
data/spec/unit/platform_spec.rb
CHANGED
@@ -18,29 +18,6 @@
|
|
18
18
|
|
19
19
|
require 'spec_helper'
|
20
20
|
|
21
|
-
describe "Chef::Platform supports" do
|
22
|
-
[
|
23
|
-
:freebsd,
|
24
|
-
:ubuntu,
|
25
|
-
:debian,
|
26
|
-
:centos,
|
27
|
-
:fedora,
|
28
|
-
:suse,
|
29
|
-
:opensuse,
|
30
|
-
:redhat,
|
31
|
-
:oracle,
|
32
|
-
:gentoo,
|
33
|
-
:arch,
|
34
|
-
:solaris,
|
35
|
-
:gcel,
|
36
|
-
:ibm_powerkvm
|
37
|
-
].each do |platform|
|
38
|
-
it "#{platform}" do
|
39
|
-
expect(Chef::Platform.platforms).to have_key(platform)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
21
|
describe Chef::Platform do
|
45
22
|
|
46
23
|
context "while testing with fake data" do
|
@@ -261,41 +238,4 @@ describe Chef::Platform do
|
|
261
238
|
|
262
239
|
end
|
263
240
|
|
264
|
-
context "while testing the configured platform data" do
|
265
|
-
|
266
|
-
it "should use the solaris package provider on Solaris <11" do
|
267
|
-
pmap = Chef::Platform.find("Solaris2", "5.9")
|
268
|
-
expect(pmap[:package]).to eql(Chef::Provider::Package::Solaris)
|
269
|
-
end
|
270
|
-
|
271
|
-
it "should use the IPS package provider on Solaris 11" do
|
272
|
-
pmap = Chef::Platform.find("Solaris2", "5.11")
|
273
|
-
expect(pmap[:package]).to eql(Chef::Provider::Package::Ips)
|
274
|
-
end
|
275
|
-
|
276
|
-
it "should use the Redhat service provider on SLES11" do
|
277
|
-
1.upto(3) do |sp|
|
278
|
-
pmap = Chef::Platform.find("SUSE", "11.#{sp}")
|
279
|
-
expect(pmap[:service]).to eql(Chef::Provider::Service::Redhat)
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
it "should use the Systemd service provider on SLES12" do
|
284
|
-
pmap = Chef::Platform.find("SUSE", "12.0")
|
285
|
-
expect(pmap[:service]).to eql(Chef::Provider::Service::Systemd)
|
286
|
-
end
|
287
|
-
|
288
|
-
it "should use the SUSE group provider on SLES11" do
|
289
|
-
1.upto(3) do |sp|
|
290
|
-
pmap = Chef::Platform.find("SUSE", "11.#{sp}")
|
291
|
-
expect(pmap[:group]).to eql(Chef::Provider::Group::Suse)
|
292
|
-
end
|
293
|
-
end
|
294
|
-
|
295
|
-
it "should use the Gpasswd group provider on SLES12" do
|
296
|
-
pmap = Chef::Platform.find("SUSE", "12.0")
|
297
|
-
expect(pmap[:group]).to eql(Chef::Provider::Group::Gpasswd)
|
298
|
-
end
|
299
|
-
end
|
300
|
-
|
301
241
|
end
|
@@ -622,7 +622,7 @@ describe Chef::Provider::Deploy do
|
|
622
622
|
|
623
623
|
gems = @provider.send(:gem_packages)
|
624
624
|
|
625
|
-
expect(gems.map { |g| g.action }).to eq([
|
625
|
+
expect(gems.map { |g| g.action }).to eq([:install])
|
626
626
|
expect(gems.map { |g| g.name }).to eq(%w{eventmachine})
|
627
627
|
expect(gems.map { |g| g.version }).to eq(%w{0.12.9})
|
628
628
|
end
|
@@ -16,173 +16,237 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'ostruct'
|
20
|
-
|
21
19
|
require 'spec_helper'
|
22
20
|
require 'tmpdir'
|
23
21
|
|
24
22
|
describe Chef::Provider::Directory do
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
let(:tmp_dir) { Dir.mktmpdir }
|
24
|
+
let(:new_resource) { Chef::Resource::Directory.new(tmp_dir) }
|
25
|
+
let(:node) { Chef::Node.new }
|
26
|
+
let(:events) { Chef::EventDispatch::Dispatcher.new }
|
27
|
+
let(:run_context) { Chef::RunContext.new(node, {}, events) }
|
28
|
+
let(:directory) { Chef::Provider::Directory.new(new_resource, run_context) }
|
29
|
+
|
30
|
+
describe "#load_current_resource" do
|
31
|
+
describe "scanning file security metadata"
|
32
|
+
describe "on unix", unix_only: true do
|
33
|
+
describe "when the directory exists" do
|
34
|
+
let(:dir_stat) { File::Stat.new(tmp_dir) }
|
35
|
+
let(:expected_uid) { dir_stat.uid }
|
36
|
+
let(:expected_gid) { dir_stat.gid }
|
37
|
+
let(:expected_mode) { "0%o" % ( dir_stat.mode & 007777 ) }
|
38
|
+
let(:expected_pwnam) { Etc.getpwuid(expected_uid).name }
|
39
|
+
let(:expected_grnam) { Etc.getgrgid(expected_gid).name }
|
40
|
+
|
41
|
+
it "describes the access mode as a String of octal integers" do
|
42
|
+
directory.load_current_resource
|
43
|
+
expect(directory.current_resource.mode).to eq(expected_mode)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "when the new_resource.owner is numeric, describes the owner as a numeric uid" do
|
47
|
+
new_resource.owner(500)
|
48
|
+
directory.load_current_resource
|
49
|
+
expect(directory.current_resource.owner).to eql(expected_uid)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "when the new_resource.group is numeric, describes the group as a numeric gid" do
|
53
|
+
new_resource.group(500)
|
54
|
+
directory.load_current_resource
|
55
|
+
expect(directory.current_resource.group).to eql(expected_gid)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "when the new_resource.owner is a string, describes the owner as a string" do
|
59
|
+
new_resource.owner("foo")
|
60
|
+
directory.load_current_resource
|
61
|
+
expect(directory.current_resource.owner).to eql(expected_pwnam)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "when the new_resource.group is a string, describes the group as a string" do
|
65
|
+
new_resource.group("bar")
|
66
|
+
directory.load_current_resource
|
67
|
+
expect(directory.current_resource.group).to eql(expected_grnam)
|
68
|
+
end
|
69
|
+
end
|
31
70
|
end
|
32
|
-
@node = Chef::Node.new
|
33
|
-
@events = Chef::EventDispatch::Dispatcher.new
|
34
|
-
@run_context = Chef::RunContext.new(@node, {}, @events)
|
35
71
|
|
36
|
-
|
37
|
-
|
72
|
+
describe "on windows", windows_only: true do
|
73
|
+
describe "when the directory exists" do
|
74
|
+
it "the mode is always nil" do
|
75
|
+
directory.load_current_resource
|
76
|
+
expect(directory.current_resource.mode).to be nil
|
77
|
+
end
|
78
|
+
|
79
|
+
it "the owner is always nil" do
|
80
|
+
directory.load_current_resource
|
81
|
+
expect(directory.current_resource.owner).to be nil
|
82
|
+
end
|
83
|
+
|
84
|
+
it "the group is always nil" do
|
85
|
+
directory.load_current_resource
|
86
|
+
expect(directory.current_resource.group).to be nil
|
87
|
+
end
|
88
|
+
|
89
|
+
it "rights are always nil (incorrectly)" do
|
90
|
+
directory.load_current_resource
|
91
|
+
expect(directory.current_resource.rights).to be nil
|
92
|
+
end
|
93
|
+
|
94
|
+
it "inherits is always nil (incorrectly)" do
|
95
|
+
directory.load_current_resource
|
96
|
+
expect(directory.current_resource.inherits).to be nil
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
38
100
|
|
101
|
+
describe "when the directory does not exist" do
|
102
|
+
before do
|
103
|
+
FileUtils.rmdir tmp_dir
|
104
|
+
end
|
39
105
|
|
40
|
-
|
41
|
-
|
106
|
+
it "sets the mode, group and owner to nil" do
|
107
|
+
directory.load_current_resource
|
108
|
+
expect(directory.current_resource.mode).to eq(nil)
|
109
|
+
expect(directory.current_resource.group).to eq(nil)
|
110
|
+
expect(directory.current_resource.owner).to eq(nil)
|
111
|
+
end
|
42
112
|
end
|
43
113
|
|
44
|
-
it "describes the directory's access rights" do
|
45
|
-
skip
|
46
|
-
end
|
47
114
|
end
|
48
115
|
|
49
|
-
describe "
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
116
|
+
describe "#define_resource_requirements" do
|
117
|
+
describe "on unix", unix_only: true do
|
118
|
+
it "raises an exception if the user does not exist" do
|
119
|
+
new_resource.owner("arglebargle_iv")
|
120
|
+
expect(Etc).to receive(:getpwnam).with("arglebargle_iv").and_raise(ArgumentError)
|
121
|
+
directory.action = :create
|
122
|
+
directory.load_current_resource
|
123
|
+
expect(directory.access_controls).to receive(:define_resource_requirements).and_call_original
|
124
|
+
directory.define_resource_requirements
|
125
|
+
expect { directory.process_resource_requirements }.to raise_error(ArgumentError)
|
126
|
+
end
|
60
127
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
128
|
+
it "raises an exception if the group does not exist" do
|
129
|
+
new_resource.group("arglebargle_iv")
|
130
|
+
expect(Etc).to receive(:getgrnam).with("arglebargle_iv").and_raise(ArgumentError)
|
131
|
+
directory.action = :create
|
132
|
+
directory.load_current_resource
|
133
|
+
expect(directory.access_controls).to receive(:define_resource_requirements).and_call_original
|
134
|
+
directory.define_resource_requirements
|
135
|
+
expect { directory.process_resource_requirements }.to raise_error(ArgumentError)
|
136
|
+
end
|
66
137
|
end
|
138
|
+
end
|
67
139
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
expect(
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
140
|
+
describe "#run_action(:create)" do
|
141
|
+
describe "when the directory exists" do
|
142
|
+
it "does not create the directory" do
|
143
|
+
expect(Dir).not_to receive(:mkdir).with(new_resource.path)
|
144
|
+
directory.run_action(:create)
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should not set the resource as updated" do
|
148
|
+
directory.run_action(:create)
|
149
|
+
expect(new_resource).not_to be_updated
|
76
150
|
end
|
77
151
|
end
|
78
152
|
|
79
|
-
|
153
|
+
describe "when the directory does not exist" do
|
154
|
+
before do
|
155
|
+
FileUtils.rmdir tmp_dir
|
156
|
+
end
|
157
|
+
|
158
|
+
it "creates the directory" do
|
159
|
+
directory.run_action(:create)
|
160
|
+
expect(File.exist?(tmp_dir)).to be true
|
161
|
+
end
|
162
|
+
|
163
|
+
it "sets the new resource as updated" do
|
164
|
+
directory.run_action(:create)
|
165
|
+
expect(new_resource).to be_updated
|
166
|
+
end
|
80
167
|
end
|
81
|
-
end
|
82
168
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
169
|
+
describe "when the parent directory does not exist" do
|
170
|
+
before do
|
171
|
+
new_resource.path "#{tmp_dir}/foobar"
|
172
|
+
FileUtils.rmdir tmp_dir
|
173
|
+
end
|
88
174
|
|
89
|
-
|
90
|
-
|
91
|
-
|
175
|
+
it "raises an exception when recursive is false" do
|
176
|
+
new_resource.recursive false
|
177
|
+
expect { directory.run_action(:create) }.to raise_error(Chef::Exceptions::EnclosingDirectoryDoesNotExist)
|
178
|
+
end
|
92
179
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
180
|
+
it "creates the directories when recursive is true" do
|
181
|
+
new_resource.recursive true
|
182
|
+
directory.run_action(:create)
|
183
|
+
expect(new_resource).to be_updated
|
184
|
+
expect(File.exist?("#{tmp_dir}/foobar")).to be true
|
185
|
+
end
|
98
186
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
187
|
+
it "raises an exception when the parent directory is a file and recursive is true" do
|
188
|
+
FileUtils.touch tmp_dir
|
189
|
+
new_resource.recursive true
|
190
|
+
expect { directory.run_action(:create) }.to raise_error
|
191
|
+
end
|
104
192
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
expect(File).to receive(:exists?).with('/path/to').ordered.and_return(false)
|
114
|
-
expect(File).to receive(:exists?).with('/path').ordered.and_return(true)
|
115
|
-
expect(Chef::FileAccessControl).to receive(:writable?).with('/path').ordered.and_return(true)
|
116
|
-
expect(File).to receive(:exists?).with(@new_resource.path).ordered.and_return(false)
|
117
|
-
|
118
|
-
expect(FileUtils).to receive(:mkdir_p).with(@new_resource.path).and_return(true)
|
119
|
-
expect(@directory).to receive(:do_acl_changes)
|
120
|
-
allow(@directory).to receive(:do_selinux)
|
121
|
-
@directory.run_action(:create)
|
122
|
-
expect(@new_resource).to be_updated
|
193
|
+
it "raises the right exception when the parent directory is a file and recursive is true" do
|
194
|
+
pending "this seems to return the wrong error" # FIXME
|
195
|
+
FileUtils.touch tmp_dir
|
196
|
+
new_resource.recursive true
|
197
|
+
expect { directory.run_action(:create) }.to raise_error(Chef::Exceptions::EnclosingDirectoryDoesNotExist)
|
198
|
+
end
|
199
|
+
end
|
123
200
|
end
|
124
201
|
|
202
|
+
describe "#run_action(:create)" do
|
203
|
+
describe "when the directory exists" do
|
204
|
+
it "deletes the directory" do
|
205
|
+
directory.run_action(:delete)
|
206
|
+
expect(File.exist?(tmp_dir)).to be false
|
207
|
+
end
|
125
208
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
end
|
209
|
+
it "sets the new resource as updated" do
|
210
|
+
directory.run_action(:delete)
|
211
|
+
expect(new_resource).to be_updated
|
212
|
+
end
|
213
|
+
end
|
132
214
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
stub_file_cstats
|
138
|
-
@new_resource.path "/tmp/foo"
|
139
|
-
expect(File).to receive(:directory?).at_least(:once).and_return(true)
|
140
|
-
expect(Chef::FileAccessControl).to receive(:writable?).with("/tmp").and_return(true)
|
141
|
-
expect(File).to receive(:exists?).at_least(:once).and_return(true)
|
142
|
-
expect(Dir).not_to receive(:mkdir).with(@new_resource.path)
|
143
|
-
expect(@directory).to receive(:do_acl_changes)
|
144
|
-
@directory.run_action(:create)
|
145
|
-
end
|
215
|
+
describe "when the directory does not exist" do
|
216
|
+
before do
|
217
|
+
FileUtils.rmdir tmp_dir
|
218
|
+
end
|
146
219
|
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
@directory.run_action(:delete)
|
152
|
-
end
|
220
|
+
it "does not delete the directory" do
|
221
|
+
expect(Dir).not_to receive(:delete).with(new_resource.path)
|
222
|
+
directory.run_action(:delete)
|
223
|
+
end
|
153
224
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
225
|
+
it "sets the new resource as updated" do
|
226
|
+
directory.run_action(:delete)
|
227
|
+
expect(new_resource).not_to be_updated
|
228
|
+
end
|
229
|
+
end
|
159
230
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
@directory.run_action(:delete)
|
165
|
-
expect(@directory.new_resource).not_to be_updated
|
166
|
-
end
|
231
|
+
describe "when the directory is not writable" do
|
232
|
+
before do
|
233
|
+
allow(Chef::FileAccessControl).to receive(:writable?).and_return(false)
|
234
|
+
end
|
167
235
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
236
|
+
it "cannot delete it and raises an exception" do
|
237
|
+
expect { directory.run_action(:delete) }.to raise_error(RuntimeError)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
describe "when the target directory is a file" do
|
242
|
+
before do
|
243
|
+
FileUtils.rmdir tmp_dir
|
244
|
+
FileUtils.touch tmp_dir
|
245
|
+
end
|
177
246
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
allow(cstats).to receive(:mode).and_return(0755)
|
183
|
-
# File.stat is called in:
|
184
|
-
# - Chef::Provider::File.load_current_resource_attrs
|
185
|
-
# - Chef::ScanAccessControl via Chef::Provider::File.setup_acl
|
186
|
-
allow(File).to receive(:stat).and_return(cstats)
|
247
|
+
it "cannot delete it and raises an exception" do
|
248
|
+
expect { directory.run_action(:delete) }.to raise_error(RuntimeError)
|
249
|
+
end
|
250
|
+
end
|
187
251
|
end
|
188
252
|
end
|