chef 11.14.2 → 11.14.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/lib/chef/application.rb +16 -8
  3. data/lib/chef/dsl/recipe.rb +14 -0
  4. data/lib/chef/exceptions.rb +1 -0
  5. data/lib/chef/provider/env/windows.rb +5 -9
  6. data/lib/chef/provider/group/dscl.rb +27 -9
  7. data/lib/chef/provider/package/rpm.rb +2 -2
  8. data/lib/chef/provider/user/dscl.rb +544 -157
  9. data/lib/chef/resource.rb +3 -0
  10. data/lib/chef/resource/freebsd_package.rb +10 -2
  11. data/lib/chef/resource/user.rb +18 -0
  12. data/lib/chef/resource_reporter.rb +7 -7
  13. data/lib/chef/role.rb +2 -2
  14. data/lib/chef/version.rb +1 -1
  15. data/spec/data/mac_users/10.7-8.plist.xml +559 -0
  16. data/spec/data/mac_users/10.7-8.shadow.xml +11 -0
  17. data/spec/data/mac_users/10.7.plist.xml +559 -0
  18. data/spec/data/mac_users/10.7.shadow.xml +11 -0
  19. data/spec/data/mac_users/10.8.plist.xml +559 -0
  20. data/spec/data/mac_users/10.8.shadow.xml +21 -0
  21. data/spec/data/mac_users/10.9.plist.xml +560 -0
  22. data/spec/data/mac_users/10.9.shadow.xml +21 -0
  23. data/spec/functional/resource/env_spec.rb +137 -0
  24. data/spec/functional/resource/user/dscl_spec.rb +198 -0
  25. data/spec/functional/resource/{user_spec.rb → user/useradd_spec.rb} +1 -1
  26. data/spec/support/lib/chef/resource/zen_follower.rb +46 -0
  27. data/spec/unit/application_spec.rb +32 -9
  28. data/spec/unit/provider/group/dscl_spec.rb +38 -1
  29. data/spec/unit/provider/package/rpm_spec.rb +12 -0
  30. data/spec/unit/provider/user/dscl_spec.rb +659 -264
  31. data/spec/unit/provider/user/useradd_spec.rb +1 -0
  32. data/spec/unit/recipe_spec.rb +41 -0
  33. data/spec/unit/resource_reporter_spec.rb +48 -0
  34. data/spec/unit/resource_spec.rb +9 -2
  35. data/spec/unit/role_spec.rb +6 -0
  36. metadata +28 -3
@@ -19,6 +19,7 @@
19
19
  #
20
20
 
21
21
  require 'spec_helper'
22
+ require 'chef/provider/user/useradd'
22
23
 
23
24
  describe Chef::Provider::User::Useradd do
24
25
 
@@ -182,7 +182,48 @@ describe Chef::Recipe do
182
182
  zm_resource # force let binding evaluation
183
183
  run_context.resource_collection.resources(:zen_master => "klopp").should == zm_resource
184
184
  end
185
+ end
186
+
187
+ describe "creating a resource with short name" do
188
+ # zen_follower resource has this:
189
+ # provides :follower, :on_platforms => ["zen"]
190
+ before do
191
+ node.stub(:[]) do |key|
192
+ case key
193
+ when :platform
194
+ :zen
195
+ when :platform_version
196
+ "1.0.0"
197
+ else
198
+ nil
199
+ end
200
+ end
201
+ end
202
+
203
+ let(:resource_follower) do
204
+ recipe.declare_resource(:follower, "srst") do
205
+ master "none"
206
+ end
207
+ end
185
208
 
209
+ it "defines the resource using the declaration name with short name" do
210
+ resource_follower
211
+ run_context.resource_collection.lookup("follower[srst]").should_not be_nil
212
+ end
213
+ end
214
+
215
+ describe "creating a resource with a long name" do
216
+ let(:resource_zn_follower) do
217
+ recipe.declare_resource(:zen_follower, "srst") do
218
+ master "none"
219
+ end
220
+ end
221
+
222
+
223
+ it "defines the resource using the declaration name with long name" do
224
+ resource_zn_follower
225
+ run_context.resource_collection.lookup("zen_follower[srst]").should_not be_nil
226
+ end
186
227
  end
187
228
 
188
229
  describe "when attempting to create a resource of an invalid type" do
@@ -21,6 +21,7 @@
21
21
 
22
22
  require File.expand_path("../../spec_helper", __FILE__)
23
23
  require 'chef/resource_reporter'
24
+ require 'socket'
24
25
 
25
26
  describe Chef::ResourceReporter do
26
27
  before(:all) do
@@ -707,5 +708,52 @@ describe Chef::ResourceReporter do
707
708
  @resource_reporter.run_completed(@node)
708
709
  end
709
710
  end
711
+
712
+ context "when data report post is enabled and the server response fails" do
713
+ before do
714
+ @enable_reporting_url_fatals = Chef::Config[:enable_reporting_url_fatals]
715
+ Chef::Config[:enable_reporting_url_fatals] = true
716
+ # this call doesn't matter for this context
717
+ @rest_client.stub(:create_url)
718
+ end
719
+
720
+ after do
721
+ Chef::Config[:enable_reporting_url_fatals] = @enable_reporting_url_fatals
722
+ end
723
+
724
+ it "should log 4xx errors" do
725
+ response = Net::HTTPClientError.new("forbidden", "403", "Forbidden")
726
+ error = Net::HTTPServerException.new("403 message", response)
727
+ @rest_client.stub(:raw_http_request).and_raise(error)
728
+ Chef::Log.should_receive(:error).with(/403/)
729
+
730
+ @resource_reporter.post_reporting_data
731
+ end
732
+
733
+ it "should log error 5xx errors" do
734
+ response = Net::HTTPServerError.new("internal error", "500", "Internal Server Error")
735
+ error = Net::HTTPFatalError.new("500 message", response)
736
+ @rest_client.stub(:raw_http_request).and_raise(error)
737
+ Chef::Log.should_receive(:error).with(/500/)
738
+
739
+ @resource_reporter.post_reporting_data
740
+ end
741
+
742
+ it "should log if a socket error happens" do
743
+ @rest_client.stub(:raw_http_request).and_raise(SocketError.new("test socket error"))
744
+ Chef::Log.should_receive(:error).with(/test socket error/)
745
+
746
+ @resource_reporter.post_reporting_data
747
+
748
+ end
749
+
750
+ it "should raise if an unkwown error happens" do
751
+ @rest_client.stub(:raw_http_request).and_raise(Exception.new)
752
+
753
+ lambda {
754
+ @resource_reporter.post_reporting_data
755
+ }.should raise_error(Exception)
756
+ end
757
+ end
710
758
  end
711
759
  end
@@ -344,7 +344,7 @@ 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
348
  :guard_interpreter, :sensitive ]
349
349
  (hash.keys - expected_keys).should == []
350
350
  (expected_keys - hash.keys).should == []
@@ -527,6 +527,13 @@ describe Chef::Resource do
527
527
  snitch_var2.should be_false
528
528
  end
529
529
 
530
+ it "reports 0 elapsed time if actual elapsed time is < 0" do
531
+ expected = Time.now
532
+ Time.stub(:now).and_return(expected, expected - 1)
533
+ @resource.run_action(:purr)
534
+ @resource.elapsed_time.should == 0
535
+ end
536
+
530
537
  describe "guard_interpreter attribute" do
531
538
  let(:resource) { @resource }
532
539
 
@@ -788,7 +795,7 @@ describe Chef::Resource do
788
795
  before(:each) do
789
796
  @resource_file = Chef::Resource::File.new("/nonexistent/CHEF-5098/file", @run_context)
790
797
  @action = :create
791
- end
798
+ end
792
799
 
793
800
  def compiled_resource_data(resource, action, err)
794
801
  error_inspector = Chef::Formatters::ErrorInspectors::ResourceFailureInspector.new(resource, action, err)
@@ -296,6 +296,12 @@ EOR
296
296
  File.should_not_receive(:exists?)
297
297
  lambda {@role.class.from_disk("lolcat")}.should raise_error(Chef::Exceptions::DuplicateRole)
298
298
  end
299
+
300
+ it "should not raise an exception if two files exist with a similar name" do
301
+ Dir.should_receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes/lolcat.rb", "#{Chef::Config[:role_path]}/super_lolcat.rb"])
302
+ File.should_not_receive(:exists?)
303
+ lambda {@role.class.from_disk("lolcat")}.should_not raise_error(Chef::Exceptions::DuplicateRole)
304
+ end
299
305
  end
300
306
 
301
307
  describe "when loading from disk and role_path is an array" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.14.2
4
+ version: 11.14.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-01 00:00:00.000000000 Z
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-config
@@ -258,6 +258,20 @@ dependencies:
258
258
  - - "~>"
259
259
  - !ruby/object:Gem::Version
260
260
  version: '0.9'
261
+ - !ruby/object:Gem::Dependency
262
+ name: plist
263
+ requirement: !ruby/object:Gem::Requirement
264
+ requirements:
265
+ - - "~>"
266
+ - !ruby/object:Gem::Version
267
+ version: 3.1.0
268
+ type: :runtime
269
+ prerelease: false
270
+ version_requirements: !ruby/object:Gem::Requirement
271
+ requirements:
272
+ - - "~>"
273
+ - !ruby/object:Gem::Version
274
+ version: 3.1.0
261
275
  - !ruby/object:Gem::Dependency
262
276
  name: rack
263
277
  requirement: !ruby/object:Gem::Requirement
@@ -1297,6 +1311,14 @@ files:
1297
1311
  - spec/data/lwrp_const_scoping/resources/conflict.rb
1298
1312
  - spec/data/lwrp_override/providers/buck_passer.rb
1299
1313
  - spec/data/lwrp_override/resources/foo.rb
1314
+ - spec/data/mac_users/10.7-8.plist.xml
1315
+ - spec/data/mac_users/10.7-8.shadow.xml
1316
+ - spec/data/mac_users/10.7.plist.xml
1317
+ - spec/data/mac_users/10.7.shadow.xml
1318
+ - spec/data/mac_users/10.8.plist.xml
1319
+ - spec/data/mac_users/10.8.shadow.xml
1320
+ - spec/data/mac_users/10.9.plist.xml
1321
+ - spec/data/mac_users/10.9.shadow.xml
1300
1322
  - spec/data/metadata/quick_start/metadata.rb
1301
1323
  - spec/data/nodes/default.rb
1302
1324
  - spec/data/nodes/test.example.com.rb
@@ -1419,6 +1441,7 @@ files:
1419
1441
  - spec/functional/resource/cron_spec.rb
1420
1442
  - spec/functional/resource/deploy_revision_spec.rb
1421
1443
  - spec/functional/resource/directory_spec.rb
1444
+ - spec/functional/resource/env_spec.rb
1422
1445
  - spec/functional/resource/file_spec.rb
1423
1446
  - spec/functional/resource/git_spec.rb
1424
1447
  - spec/functional/resource/group_spec.rb
@@ -1433,7 +1456,8 @@ files:
1433
1456
  - spec/functional/resource/remote_file_spec.rb
1434
1457
  - spec/functional/resource/rpm_spec.rb
1435
1458
  - spec/functional/resource/template_spec.rb
1436
- - spec/functional/resource/user_spec.rb
1459
+ - spec/functional/resource/user/dscl_spec.rb
1460
+ - spec/functional/resource/user/useradd_spec.rb
1437
1461
  - spec/functional/rest_spec.rb
1438
1462
  - spec/functional/run_lock_spec.rb
1439
1463
  - spec/functional/shell_spec.rb
@@ -1475,6 +1499,7 @@ files:
1475
1499
  - spec/support/lib/chef/resource/cat.rb
1476
1500
  - spec/support/lib/chef/resource/one_two_three_four.rb
1477
1501
  - spec/support/lib/chef/resource/with_state.rb
1502
+ - spec/support/lib/chef/resource/zen_follower.rb
1478
1503
  - spec/support/lib/chef/resource/zen_master.rb
1479
1504
  - spec/support/lib/library_load_order.rb
1480
1505
  - spec/support/matchers/leak.rb