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