chef 11.14.0.alpha.4-x86-mingw32 → 11.14.0.rc.2-x86-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.
- data/CONTRIBUTING.md +0 -4
- data/README.md +1 -1
- data/distro/common/man/man1/chef-shell.1 +4 -4
- data/distro/common/man/man1/knife-bootstrap.1 +14 -11
- data/distro/common/man/man1/knife-client.1 +14 -11
- data/distro/common/man/man1/knife-configure.1 +7 -7
- data/distro/common/man/man1/knife-cookbook-site.1 +23 -23
- data/distro/common/man/man1/knife-cookbook.1 +23 -23
- data/distro/common/man/man1/knife-data-bag.1 +13 -13
- data/distro/common/man/man1/knife-delete.1 +9 -9
- data/distro/common/man/man1/knife-deps.1 +9 -9
- data/distro/common/man/man1/knife-diff.1 +10 -10
- data/distro/common/man/man1/knife-download.1 +9 -9
- data/distro/common/man/man1/knife-edit.1 +7 -7
- data/distro/common/man/man1/knife-environment.1 +10 -10
- data/distro/common/man/man1/knife-exec.1 +7 -7
- data/distro/common/man/man1/knife-index-rebuild.1 +1 -1
- data/distro/common/man/man1/knife-list.1 +12 -12
- data/distro/common/man/man1/knife-node.1 +12 -9
- data/distro/common/man/man1/knife-raw.1 +7 -7
- data/distro/common/man/man1/knife-recipe-list.1 +1 -1
- data/distro/common/man/man1/knife-role.1 +8 -8
- data/distro/common/man/man1/knife-search.1 +9 -9
- data/distro/common/man/man1/knife-serve.1 +109 -0
- data/distro/common/man/man1/knife-show.1 +8 -8
- data/distro/common/man/man1/knife-ssh.1 +9 -9
- data/distro/common/man/man1/knife-ssl-check.1 +9 -9
- data/distro/common/man/man1/knife-ssl-fetch.1 +10 -10
- data/distro/common/man/man1/knife-status.1 +9 -9
- data/distro/common/man/man1/knife-tag.1 +7 -7
- data/distro/common/man/man1/knife-upload.1 +10 -10
- data/distro/common/man/man1/knife-user.1 +9 -9
- data/distro/common/man/man1/knife-xargs.1 +7 -7
- data/distro/common/man/man1/knife.1 +118 -14
- data/distro/common/man/man8/chef-client.8 +13 -10
- data/distro/common/man/man8/chef-solo.8 +13 -14
- data/distro/common/markdown/man1/knife.mkd +1 -1
- data/lib/chef/application/knife.rb +1 -1
- data/lib/chef/application/windows_service.rb +0 -1
- data/lib/chef/chef_fs/file_system.rb +6 -2
- data/lib/chef/config.rb +3 -2
- data/lib/chef/config_fetcher.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +20 -14
- data/lib/chef/cookbook/synchronizer.rb +24 -13
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +3 -3
- data/lib/chef/encrypted_data_bag_item/encryptor.rb +2 -2
- data/lib/chef/exceptions.rb +1 -0
- data/lib/chef/file_content_management/deploy/mv_windows.rb +1 -1
- data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +1 -1
- data/lib/chef/http.rb +6 -1
- data/lib/chef/http/http_request.rb +9 -1
- data/lib/chef/http/simple.rb +2 -1
- data/lib/chef/json_compat.rb +5 -16
- data/lib/chef/knife/bootstrap.rb +2 -0
- data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
- data/lib/chef/knife/core/object_loader.rb +3 -1
- data/lib/chef/knife/ssh.rb +14 -7
- data/lib/chef/mixin/convert_to_class_name.rb +1 -0
- data/lib/chef/mixin/windows_architecture_helper.rb +24 -4
- data/lib/chef/platform/provider_mapping.rb +13 -0
- data/lib/chef/provider/env/windows.rb +3 -6
- data/lib/chef/provider/git.rb +1 -2
- data/lib/chef/provider/log.rb +15 -1
- data/lib/chef/provider/package/apt.rb +3 -3
- data/lib/chef/provider/package/dpkg.rb +35 -16
- data/lib/chef/provider/package/paludis.rb +91 -0
- data/lib/chef/provider/package/rpm.rb +3 -2
- data/lib/chef/provider/package/yum-dump.py +6 -6
- data/lib/chef/provider/package/yum.rb +2 -0
- data/lib/chef/provider/registry_key.rb +4 -5
- data/lib/chef/provider/remote_file/cache_control_data.rb +1 -1
- data/lib/chef/provider/service/solaris.rb +1 -1
- data/lib/chef/provider/service/upstart.rb +2 -1
- data/lib/chef/provider/service/windows.rb +37 -9
- data/lib/chef/provider/user/pw.rb +1 -1
- data/lib/chef/provider/user/useradd.rb +1 -1
- data/lib/chef/provider/windows_script.rb +2 -1
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource.rb +10 -0
- data/lib/chef/resource/file.rb +0 -9
- data/lib/chef/resource/package.rb +14 -4
- data/lib/chef/resource/paludis_package.rb +33 -0
- data/lib/chef/resource/registry_key.rb +62 -3
- data/lib/chef/resource/service.rb +21 -4
- data/lib/chef/resource_reporter.rb +10 -0
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/role.rb +14 -10
- data/lib/chef/shell.rb +8 -0
- data/lib/chef/shell/shell_session.rb +3 -3
- data/lib/chef/user.rb +12 -11
- data/lib/chef/util/selinux.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/version_constraint.rb +6 -5
- data/lib/chef/win32/api/process.rb +1 -0
- data/lib/chef/win32/api/system.rb +14 -0
- data/lib/chef/win32/error.rb +1 -1
- data/lib/chef/win32/security.rb +5 -5
- data/lib/chef/win32/version.rb +6 -2
- data/spec/data/trusted_certs/opscode.pem +57 -35
- data/spec/functional/application_spec.rb +2 -2
- data/spec/functional/resource/mount_spec.rb +3 -1
- data/spec/functional/shell_spec.rb +10 -0
- data/spec/functional/tiny_server_spec.rb +2 -2
- data/spec/support/chef_helpers.rb +1 -1
- data/spec/support/shared/functional/securable_resource.rb +11 -2
- data/spec/support/shared/functional/securable_resource_with_reporting.rb +13 -2
- data/spec/tiny_server.rb +1 -1
- data/spec/unit/config_spec.rb +5 -0
- data/spec/unit/cookbook/metadata_spec.rb +24 -0
- data/spec/unit/environment_spec.rb +6 -0
- data/spec/unit/http/http_request_spec.rb +91 -0
- data/spec/unit/http_spec.rb +23 -0
- data/spec/unit/knife/bootstrap_spec.rb +2 -2
- data/spec/unit/knife/ssh_spec.rb +7 -13
- data/spec/unit/knife_spec.rb +1 -1
- data/spec/unit/mixin/convert_to_class_name_spec.rb +4 -0
- data/spec/unit/provider/git_spec.rb +2 -2
- data/spec/unit/provider/log_spec.rb +18 -0
- data/spec/unit/provider/mount/solaris_spec.rb +3 -1
- data/spec/unit/provider/package/apt_spec.rb +85 -40
- data/spec/unit/provider/package/dpkg_spec.rb +24 -48
- data/spec/unit/provider/package/paludis_spec.rb +135 -0
- data/spec/unit/provider/package/rpm_spec.rb +40 -32
- data/spec/unit/provider/package/yum_spec.rb +11 -4
- data/spec/unit/provider/registry_key_spec.rb +67 -53
- data/spec/unit/provider/remote_file/cache_control_data_spec.rb +10 -1
- data/spec/unit/provider/service/solaris_smf_service_spec.rb +23 -2
- data/spec/unit/provider/service/upstart_service_spec.rb +7 -0
- data/spec/unit/provider/service/windows_spec.rb +72 -0
- data/spec/unit/provider/user/pw_spec.rb +21 -4
- data/spec/unit/provider/user/useradd_spec.rb +10 -0
- data/spec/unit/resource/package_spec.rb +26 -18
- data/spec/unit/resource/registry_key_spec.rb +28 -0
- data/spec/unit/resource/service_spec.rb +14 -0
- data/spec/unit/resource_reporter_spec.rb +37 -12
- data/spec/unit/resource_spec.rb +41 -6
- data/spec/unit/rest_spec.rb +2 -2
- data/spec/unit/role_spec.rb +46 -28
- data/spec/unit/shell/shell_session_spec.rb +42 -2
- data/spec/unit/shell_spec.rb +1 -1
- data/spec/unit/user_spec.rb +12 -0
- data/spec/unit/util/selinux_spec.rb +4 -4
- data/spec/unit/version_constraint_spec.rb +14 -2
- metadata +223 -167
- checksums.yaml +0 -7
@@ -125,6 +125,15 @@ describe Chef::Provider::RemoteFile::CacheControlData do
|
|
125
125
|
cache_control_data.etag.should be_nil
|
126
126
|
cache_control_data.mtime.should be_nil
|
127
127
|
end
|
128
|
+
|
129
|
+
context "and it still is valid JSON" do
|
130
|
+
let(:cache_json_data) { '' }
|
131
|
+
|
132
|
+
it "returns empty cache control data" do
|
133
|
+
cache_control_data.etag.should be_nil
|
134
|
+
cache_control_data.mtime.should be_nil
|
135
|
+
end
|
136
|
+
end
|
128
137
|
end
|
129
138
|
end
|
130
139
|
|
@@ -190,7 +199,7 @@ describe Chef::Provider::RemoteFile::CacheControlData do
|
|
190
199
|
it "truncates the file cache path to 102 characters" do
|
191
200
|
normalized_cache_path = cache_control_data.send('sanitized_cache_file_basename')
|
192
201
|
|
193
|
-
Chef::FileCache.should_receive(:store).with("remote_file/" + normalized_cache_path, cache_control_data.json_data)
|
202
|
+
Chef::FileCache.should_receive(:store).with("remote_file/" + normalized_cache_path, cache_control_data.json_data)
|
194
203
|
|
195
204
|
cache_control_data.save
|
196
205
|
|
@@ -66,7 +66,7 @@ describe Chef::Provider::Service::Solaris do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should call '/bin/svcs -l service_name'" do
|
69
|
-
@provider.should_receive(:shell_out!).with("/bin/svcs -l chef").and_return(@status)
|
69
|
+
@provider.should_receive(:shell_out!).with("/bin/svcs -l chef", {:returns=>[0, 1]}).and_return(@status)
|
70
70
|
@provider.load_current_resource
|
71
71
|
end
|
72
72
|
|
@@ -145,7 +145,7 @@ describe Chef::Provider::Service::Solaris do
|
|
145
145
|
end
|
146
146
|
|
147
147
|
it "should call svcadm disable -s chef for stop_service" do
|
148
|
-
@provider.should_receive(:shell_out!).with("/usr/sbin/svcadm disable -s chef")
|
148
|
+
@provider.should_receive(:shell_out!).with("/usr/sbin/svcadm disable -s chef").and_return(@status)
|
149
149
|
@provider.stop_service.should be_true
|
150
150
|
@current_resource.enabled.should be_false
|
151
151
|
end
|
@@ -164,5 +164,26 @@ describe Chef::Provider::Service::Solaris do
|
|
164
164
|
end
|
165
165
|
|
166
166
|
end
|
167
|
+
|
168
|
+
describe "when the service doesn't exist" do
|
169
|
+
before(:each) do
|
170
|
+
@stdout_string = ""
|
171
|
+
@status = double("Status", :exitstatus => 1, :stdout => @stdout)
|
172
|
+
@provider.current_resource = @current_resource
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should be marked not running" do
|
176
|
+
@provider.should_receive(:shell_out!).with("/bin/svcs -l chef", {:returns=>[0, 1]}).and_return(@status)
|
177
|
+
@provider.service_status
|
178
|
+
@current_resource.running.should be_false
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should be marked not enabled" do
|
182
|
+
@provider.should_receive(:shell_out!).with("/bin/svcs -l chef", {:returns=>[0, 1]}).and_return(@status)
|
183
|
+
@provider.service_status
|
184
|
+
@current_resource.enabled.should be_false
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
167
188
|
end
|
168
189
|
end
|
@@ -88,6 +88,13 @@ describe Chef::Provider::Service::Upstart do
|
|
88
88
|
@provider.load_current_resource
|
89
89
|
end
|
90
90
|
|
91
|
+
it "should not change the service name when parameters are specified" do
|
92
|
+
@new_resource.parameters({ "OSD_ID" => "2" })
|
93
|
+
@provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context)
|
94
|
+
@provider.current_resource = @current_resource
|
95
|
+
@new_resource.service_name.should == @current_resource.service_name
|
96
|
+
end
|
97
|
+
|
91
98
|
it "should run '/sbin/status rsyslog'" do
|
92
99
|
@provider.should_receive(:popen4).with("/sbin/status rsyslog").and_return(@status)
|
93
100
|
@provider.load_current_resource
|
@@ -92,8 +92,39 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
|
|
92
92
|
@provider.start_service
|
93
93
|
@new_resource.updated_by_last_action?.should be_false
|
94
94
|
end
|
95
|
+
|
96
|
+
it "should raise an error if the service is paused" do
|
97
|
+
Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
|
98
|
+
double("StatusStruct", :current_state => "paused"))
|
99
|
+
@provider.load_current_resource
|
100
|
+
Win32::Service.should_not_receive(:start).with(@new_resource.service_name)
|
101
|
+
expect { @provider.start_service }.to raise_error( Chef::Exceptions::Service )
|
102
|
+
@new_resource.updated_by_last_action?.should be_false
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should wait and continue if the service is in start_pending" do
|
106
|
+
Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
|
107
|
+
double("StatusStruct", :current_state => "start pending"),
|
108
|
+
double("StatusStruct", :current_state => "start pending"),
|
109
|
+
double("StatusStruct", :current_state => "running"))
|
110
|
+
@provider.load_current_resource
|
111
|
+
Win32::Service.should_not_receive(:start).with(@new_resource.service_name)
|
112
|
+
@provider.start_service
|
113
|
+
@new_resource.updated_by_last_action?.should be_false
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should fail if the service is in stop_pending" do
|
117
|
+
Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
|
118
|
+
double("StatusStruct", :current_state => "stop pending"))
|
119
|
+
@provider.load_current_resource
|
120
|
+
Win32::Service.should_not_receive(:start).with(@new_resource.service_name)
|
121
|
+
expect { @provider.start_service }.to raise_error( Chef::Exceptions::Service )
|
122
|
+
@new_resource.updated_by_last_action?.should be_false
|
123
|
+
end
|
124
|
+
|
95
125
|
end
|
96
126
|
|
127
|
+
|
97
128
|
describe Chef::Provider::Service::Windows, "stop_service" do
|
98
129
|
|
99
130
|
before(:each) do
|
@@ -130,6 +161,47 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do
|
|
130
161
|
@provider.stop_service
|
131
162
|
@new_resource.updated_by_last_action?.should be_false
|
132
163
|
end
|
164
|
+
|
165
|
+
it "should raise an error if the service is paused" do
|
166
|
+
Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
|
167
|
+
double("StatusStruct", :current_state => "paused"))
|
168
|
+
@provider.load_current_resource
|
169
|
+
Win32::Service.should_not_receive(:start).with(@new_resource.service_name)
|
170
|
+
expect { @provider.stop_service }.to raise_error( Chef::Exceptions::Service )
|
171
|
+
@new_resource.updated_by_last_action?.should be_false
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should wait and continue if the service is in stop_pending" do
|
175
|
+
Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
|
176
|
+
double("StatusStruct", :current_state => "stop pending"),
|
177
|
+
double("StatusStruct", :current_state => "stop pending"),
|
178
|
+
double("StatusStruct", :current_state => "stopped"))
|
179
|
+
@provider.load_current_resource
|
180
|
+
Win32::Service.should_not_receive(:stop).with(@new_resource.service_name)
|
181
|
+
@provider.stop_service
|
182
|
+
@new_resource.updated_by_last_action?.should be_false
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should fail if the service is in start_pending" do
|
186
|
+
Win32::Service.stub(:status).with(@new_resource.service_name).and_return(
|
187
|
+
double("StatusStruct", :current_state => "start pending"))
|
188
|
+
@provider.load_current_resource
|
189
|
+
Win32::Service.should_not_receive(:stop).with(@new_resource.service_name)
|
190
|
+
expect { @provider.stop_service }.to raise_error( Chef::Exceptions::Service )
|
191
|
+
@new_resource.updated_by_last_action?.should be_false
|
192
|
+
end
|
193
|
+
|
194
|
+
it "should pass custom timeout to the stop command if provided" do
|
195
|
+
Win32::Service.stub!(:status).with(@new_resource.service_name).and_return(
|
196
|
+
mock("StatusStruct", :current_state => "running"))
|
197
|
+
@new_resource.timeout 1
|
198
|
+
Win32::Service.should_receive(:stop).with(@new_resource.service_name)
|
199
|
+
Timeout.timeout(2) do
|
200
|
+
expect { @provider.stop_service }.to raise_error(Timeout::Error)
|
201
|
+
end
|
202
|
+
@new_resource.updated_by_last_action?.should be_false
|
203
|
+
end
|
204
|
+
|
133
205
|
end
|
134
206
|
|
135
207
|
describe Chef::Provider::Service::Windows, "restart_service" do
|
@@ -164,10 +164,27 @@ describe Chef::Provider::User::Pw do
|
|
164
164
|
@pid, @stdin, @stdout, @stderr = nil, nil, nil, nil
|
165
165
|
end
|
166
166
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
167
|
+
describe "and the new password has not been specified" do
|
168
|
+
before(:each) do
|
169
|
+
@new_resource.stub(:password).and_return(nil)
|
170
|
+
end
|
171
|
+
|
172
|
+
it "logs an appropriate message" do
|
173
|
+
Chef::Log.should_receive(:debug).with("user[adam] no change needed to password")
|
174
|
+
@provider.modify_password
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "and the new password has been specified" do
|
179
|
+
before(:each) do
|
180
|
+
@new_resource.stub(:password).and_return("abracadabra")
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should check for differences in password between the new and current resources" do
|
184
|
+
@current_resource.should_receive(:password)
|
185
|
+
@new_resource.should_receive(:password)
|
186
|
+
@provider.modify_password
|
187
|
+
end
|
171
188
|
end
|
172
189
|
|
173
190
|
describe "and the passwords are identical" do
|
@@ -37,4 +37,14 @@ describe Chef::Provider::User::Useradd do
|
|
37
37
|
}
|
38
38
|
|
39
39
|
include_examples "a useradd-based user provider", supported_useradd_options
|
40
|
+
|
41
|
+
describe "manage_user" do
|
42
|
+
# CHEF-5247: Chef::Provider::User::Solaris subclasses Chef::Provider::User::Useradd, but does not use usermod to change passwords.
|
43
|
+
# Thus, a call to Solaris#manage_user calls Solaris#manage_password and Useradd#manage_user, but the latter should be a no-op.
|
44
|
+
it "should not run the command if universal_options is an empty array" do
|
45
|
+
provider.stub(:universal_options).and_return([])
|
46
|
+
expect(provider).not_to receive(:shell_out!)
|
47
|
+
provider.manage_user
|
48
|
+
end
|
49
|
+
end
|
40
50
|
end
|
@@ -64,22 +64,30 @@ describe Chef::Resource::Package do
|
|
64
64
|
@resource.options.should eql("something")
|
65
65
|
end
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
67
|
+
describe "when it has a package_name and version" do
|
68
|
+
before do
|
69
|
+
@resource.package_name("tomcat")
|
70
|
+
@resource.version("10.9.8")
|
71
|
+
@resource.options("-al")
|
72
|
+
end
|
73
|
+
|
74
|
+
it "describes its state" do
|
75
|
+
state = @resource.state
|
76
|
+
state[:version].should == "10.9.8"
|
77
|
+
state[:options].should == "-al"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "returns the file path as its identity" do
|
81
|
+
@resource.identity.should == "tomcat"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# String, Integer
|
86
|
+
[ "600", 600 ].each do |val|
|
87
|
+
it "supports setting a timeout as a #{val.class}" do
|
88
|
+
@resource.timeout(val)
|
89
|
+
expect(@resource.timeout).to eql(val)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
85
93
|
end
|
@@ -89,6 +89,11 @@ describe Chef::Resource::RegistryKey, "values" do
|
|
89
89
|
@resource.values.should eql([ { :name => 'poosh', :type => :string, :data => 'carmen' } ])
|
90
90
|
end
|
91
91
|
|
92
|
+
it "should return checksummed data if the type is unsafe" do
|
93
|
+
@resource.values( { :name => 'poosh', :type => :binary, :data => 255.chr * 1 })
|
94
|
+
@resource.values.should eql([ { :name => 'poosh', :type => :binary, :data => "00594fd4f42ba43fc1ca0427a0576295" } ])
|
95
|
+
end
|
96
|
+
|
92
97
|
it "should throw an exception if the name field is missing" do
|
93
98
|
lambda { @resource.values [ { :type => :string, :data => 'carmen' } ] }.should raise_error(ArgumentError)
|
94
99
|
end
|
@@ -169,3 +174,26 @@ describe Chef::Resource::RegistryKey, "architecture" do
|
|
169
174
|
lambda { @resource.architecture(100) }.should raise_error(ArgumentError)
|
170
175
|
end
|
171
176
|
end
|
177
|
+
|
178
|
+
describe Chef::Resource::RegistryKey, ":unscrubbed_values" do
|
179
|
+
before(:each) do
|
180
|
+
@resource = Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius')
|
181
|
+
end
|
182
|
+
|
183
|
+
it "should return unsafe data as-is" do
|
184
|
+
key_values = [ { :name => 'poosh', :type => :binary, :data => 255.chr * 1 } ]
|
185
|
+
@resource.values(key_values)
|
186
|
+
@resource.unscrubbed_values.should eql(key_values)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe Chef::Resource::RegistryKey, "state" do
|
191
|
+
before(:each) do
|
192
|
+
@resource = Chef::Resource::RegistryKey.new('HKCU\Software\Raxicoricofallapatorius')
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should return scrubbed values" do
|
196
|
+
@resource.values([ { :name => 'poosh', :type => :binary, :data => 255.chr * 1 } ])
|
197
|
+
@resource.state.should eql( { :values => [{ :name => 'poosh', :type => :binary, :data => "00594fd4f42ba43fc1ca0427a0576295" }] } )
|
198
|
+
end
|
199
|
+
end
|
@@ -29,6 +29,20 @@ describe Chef::Resource::Service do
|
|
29
29
|
@resource.should be_a_kind_of(Chef::Resource)
|
30
30
|
@resource.should be_a_kind_of(Chef::Resource::Service)
|
31
31
|
end
|
32
|
+
|
33
|
+
it "should not set a provider unless node[:init_package] is defined as systemd" do
|
34
|
+
@resource.provider.should == nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should set the provider to Chef::Provider::Service::Systemd if node[:init_package] is systemd" do
|
38
|
+
node = Chef::Node.new
|
39
|
+
node.set[:init_package] = "systemd"
|
40
|
+
cookbook_collection = Chef::CookbookCollection.new([])
|
41
|
+
events = Chef::EventDispatch::Dispatcher.new
|
42
|
+
run_context = Chef::RunContext.new(node, cookbook_collection, events)
|
43
|
+
@resource = Chef::Resource::Service.new("chef", run_context)
|
44
|
+
@resource.provider.should == Chef::Provider::Service::Systemd
|
45
|
+
end
|
32
46
|
|
33
47
|
it "should set the service_name to the first argument to new" do
|
34
48
|
@resource.service_name.should eql("chef")
|
@@ -39,7 +39,8 @@ describe Chef::ResourceReporter do
|
|
39
39
|
@rest_client.stub(:post_rest).and_return(true)
|
40
40
|
@resource_reporter = Chef::ResourceReporter.new(@rest_client)
|
41
41
|
@new_resource = Chef::Resource::File.new("/tmp/a-file.txt")
|
42
|
-
@
|
42
|
+
@cookbook_name = "monkey"
|
43
|
+
@new_resource.cookbook_name = @cookbook_name
|
43
44
|
@cookbook_version = double("Cookbook::Version", :version => "1.2.3")
|
44
45
|
@new_resource.stub(:cookbook_version).and_return(@cookbook_version)
|
45
46
|
@current_resource = Chef::Resource::File.new("/tmp/a-file.txt")
|
@@ -316,8 +317,7 @@ describe Chef::ResourceReporter do
|
|
316
317
|
end
|
317
318
|
end
|
318
319
|
|
319
|
-
|
320
|
-
context "for a successful client run" do
|
320
|
+
shared_examples_for "a successful client run" do
|
321
321
|
before do
|
322
322
|
# TODO: add inputs to generate expected output.
|
323
323
|
|
@@ -349,10 +349,10 @@ describe Chef::ResourceReporter do
|
|
349
349
|
# "status" : "success"
|
350
350
|
# "data" : ""
|
351
351
|
# }
|
352
|
-
@resource_reporter.resource_action_start(
|
353
|
-
@resource_reporter.resource_current_state_loaded(
|
354
|
-
@resource_reporter.resource_updated(
|
355
|
-
@resource_reporter.resource_completed(
|
352
|
+
@resource_reporter.resource_action_start(new_resource, :create)
|
353
|
+
@resource_reporter.resource_current_state_loaded(new_resource, :create, current_resource)
|
354
|
+
@resource_reporter.resource_updated(new_resource, :create)
|
355
|
+
@resource_reporter.resource_completed(new_resource)
|
356
356
|
@run_status.stop_clock
|
357
357
|
@report = @resource_reporter.prepare_run_data
|
358
358
|
@first_update_report = @report["resources"].first
|
@@ -371,19 +371,19 @@ describe Chef::ResourceReporter do
|
|
371
371
|
end
|
372
372
|
|
373
373
|
it "includes an updated resource's initial state" do
|
374
|
-
@first_update_report["before"].should ==
|
374
|
+
@first_update_report["before"].should == current_resource.state
|
375
375
|
end
|
376
376
|
|
377
377
|
it "includes an updated resource's final state" do
|
378
|
-
@first_update_report["after"].should ==
|
378
|
+
@first_update_report["after"].should == new_resource.state
|
379
379
|
end
|
380
380
|
|
381
381
|
it "includes the resource's name" do
|
382
|
-
@first_update_report["name"].should ==
|
382
|
+
@first_update_report["name"].should == new_resource.name
|
383
383
|
end
|
384
384
|
|
385
385
|
it "includes the resource's id attribute" do
|
386
|
-
@first_update_report["id"].should ==
|
386
|
+
@first_update_report["id"].should == new_resource.identity
|
387
387
|
end
|
388
388
|
|
389
389
|
it "includes the elapsed time for the resource to converge" do
|
@@ -400,7 +400,7 @@ describe Chef::ResourceReporter do
|
|
400
400
|
|
401
401
|
it "includes the cookbook name of the resource" do
|
402
402
|
@first_update_report.should have_key("cookbook_name")
|
403
|
-
@first_update_report["cookbook_name"].should ==
|
403
|
+
@first_update_report["cookbook_name"].should == @cookbook_name
|
404
404
|
end
|
405
405
|
|
406
406
|
it "includes the cookbook version of the resource" do
|
@@ -430,6 +430,31 @@ describe Chef::ResourceReporter do
|
|
430
430
|
|
431
431
|
end
|
432
432
|
|
433
|
+
context "when the resource is a File" do
|
434
|
+
let(:new_resource) { @new_resource }
|
435
|
+
let(:current_resource) { @current_resource }
|
436
|
+
|
437
|
+
it_should_behave_like "a successful client run"
|
438
|
+
end
|
439
|
+
|
440
|
+
context "when the resource is a RegistryKey with binary data" do
|
441
|
+
let(:new_resource) do
|
442
|
+
resource = Chef::Resource::RegistryKey.new('Wubba\Lubba\Dub\Dubs')
|
443
|
+
resource.values([ { :name => 'rick', :type => :binary, :data => 255.chr * 1 } ])
|
444
|
+
resource.stub(:cookbook_name).and_return(@cookbook_name)
|
445
|
+
resource.stub(:cookbook_version).and_return(@cookbook_version)
|
446
|
+
resource
|
447
|
+
end
|
448
|
+
|
449
|
+
let(:current_resource) do
|
450
|
+
resource = Chef::Resource::RegistryKey.new('Wubba\Lubba\Dub\Dubs')
|
451
|
+
resource.values([ { :name => 'rick', :type => :binary, :data => 255.chr * 1 } ])
|
452
|
+
resource
|
453
|
+
end
|
454
|
+
|
455
|
+
it_should_behave_like "a successful client run"
|
456
|
+
end
|
457
|
+
|
433
458
|
context "for an unsuccessful run" do
|
434
459
|
|
435
460
|
before do
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -344,7 +344,8 @@ describe Chef::Resource do
|
|
344
344
|
expected_keys = [ :allowed_actions, :params, :provider, :updated,
|
345
345
|
:updated_by_last_action, :before, :supports,
|
346
346
|
:noop, :ignore_failure, :name, :source_line,
|
347
|
-
:action, :retries, :retry_delay, :elapsed_time,
|
347
|
+
:action, :retries, :retry_delay, :elapsed_time,
|
348
|
+
:guard_interpreter, :sensitive ]
|
348
349
|
(hash.keys - expected_keys).should == []
|
349
350
|
(expected_keys - hash.keys).should == []
|
350
351
|
hash[:name].should eql("funk")
|
@@ -559,12 +560,12 @@ describe Chef::Resource do
|
|
559
560
|
@resource.should_skip?(:purr).should be_false
|
560
561
|
end
|
561
562
|
|
562
|
-
it "should return false when
|
563
|
+
it "should return false when only_if is met" do
|
563
564
|
@resource.only_if { true }
|
564
565
|
@resource.should_skip?(:purr).should be_false
|
565
566
|
end
|
566
567
|
|
567
|
-
it "should return true when
|
568
|
+
it "should return true when only_if is not met" do
|
568
569
|
@resource.only_if { false }
|
569
570
|
@resource.should_skip?(:purr).should be_true
|
570
571
|
end
|
@@ -574,18 +575,18 @@ describe Chef::Resource do
|
|
574
575
|
@resource.should_skip?(:purr).should be_true
|
575
576
|
end
|
576
577
|
|
577
|
-
it "should return false when
|
578
|
+
it "should return false when not_if is not met" do
|
578
579
|
@resource.not_if { false }
|
579
580
|
@resource.should_skip?(:purr).should be_false
|
580
581
|
end
|
581
582
|
|
582
|
-
it "should return true when
|
583
|
+
it "should return true when only_if is met but also not_if is met" do
|
583
584
|
@resource.only_if { true }
|
584
585
|
@resource.not_if { true }
|
585
586
|
@resource.should_skip?(:purr).should be_true
|
586
587
|
end
|
587
588
|
|
588
|
-
it "should return true when one of multiple
|
589
|
+
it "should return true when one of multiple only_if's is not met" do
|
589
590
|
@resource.only_if { true }
|
590
591
|
@resource.only_if { false }
|
591
592
|
@resource.only_if { true }
|
@@ -781,6 +782,40 @@ describe Chef::Resource do
|
|
781
782
|
end
|
782
783
|
|
783
784
|
end
|
785
|
+
|
786
|
+
describe "resource sensitive attribute" do
|
787
|
+
|
788
|
+
before(:each) do
|
789
|
+
@resource_file = Chef::Resource::File.new("/nonexistent/CHEF-5098/file", @run_context)
|
790
|
+
@action = :create
|
791
|
+
end
|
792
|
+
|
793
|
+
def compiled_resource_data(resource, action, err)
|
794
|
+
error_inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(resource, action, err)
|
795
|
+
description = Chef::Formatters::ErrorDescription.new("test")
|
796
|
+
error_inspector.add_explanation(description)
|
797
|
+
Chef::Log.info("descrtiption: #{description.inspect},error_inspector: #{error_inspector}")
|
798
|
+
description.sections[1]["Compiled Resource:"]
|
799
|
+
end
|
800
|
+
|
801
|
+
it "set to false by default" do
|
802
|
+
@resource.sensitive.should be_false
|
803
|
+
end
|
804
|
+
|
805
|
+
it "when set to false should show compiled resource for failed resource" do
|
806
|
+
expect { @resource_file.run_action(@action) }.to raise_error { |err|
|
807
|
+
compiled_resource_data(@resource_file, @action, err).should match 'path "/nonexistent/CHEF-5098/file"'
|
808
|
+
}
|
809
|
+
end
|
810
|
+
|
811
|
+
it "when set to true should show compiled resource for failed resource" do
|
812
|
+
@resource_file.sensitive true
|
813
|
+
expect { @resource_file.run_action(@action) }.to raise_error { |err|
|
814
|
+
compiled_resource_data(@resource_file, @action, err).should eql("suppressed sensitive resource output")
|
815
|
+
}
|
816
|
+
end
|
817
|
+
|
818
|
+
end
|
784
819
|
end
|
785
820
|
|
786
821
|
describe Chef::Resource::Notification do
|