chef 13.0.118-universal-mingw32 → 13.1.31-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -27
  3. data/VERSION +1 -1
  4. data/acceptance/.bundle/config +2 -0
  5. data/acceptance/basics/test/integration/chef-current-install/serverspec/chef_client_spec.rb +1 -1
  6. data/acceptance/bin/aws.rb +17 -0
  7. data/acceptance/bin/berks +17 -0
  8. data/acceptance/bin/bundler +17 -0
  9. data/acceptance/bin/chef-acceptance +17 -0
  10. data/acceptance/bin/coderay +17 -0
  11. data/acceptance/bin/erubis +17 -0
  12. data/acceptance/bin/htmldiff +17 -0
  13. data/acceptance/bin/httpclient +17 -0
  14. data/acceptance/bin/inspec +17 -0
  15. data/acceptance/bin/kitchen +17 -0
  16. data/acceptance/bin/ldiff +17 -0
  17. data/acceptance/bin/nokogiri +17 -0
  18. data/acceptance/bin/pry +17 -0
  19. data/acceptance/bin/rake +17 -0
  20. data/acceptance/bin/rspec +17 -0
  21. data/acceptance/bin/rwinrm +17 -0
  22. data/acceptance/bin/rwinrmcp +17 -0
  23. data/acceptance/bin/safe_yaml +17 -0
  24. data/acceptance/bin/thor +17 -0
  25. data/acceptance/fips/.kitchen/fips-unit-functional-centos-6.yml +7 -0
  26. data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/action_set_name +1 -0
  27. data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/creator_uid +1 -0
  28. data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/id +1 -0
  29. data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/index_uuid +1 -0
  30. data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/private_key +27 -0
  31. data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/.vagrant/machines/default/virtualbox/synced_folders +1 -0
  32. data/acceptance/fips/.kitchen/kitchen-vagrant/kitchen-fips-fips-unit-functional-centos-6/Vagrantfile +11 -0
  33. data/acceptance/fips/.kitchen/logs/fips-integration-centos-6.log +0 -0
  34. data/acceptance/fips/.kitchen/logs/fips-integration-windows-2012r2.log +0 -0
  35. data/acceptance/fips/.kitchen/logs/fips-unit-functional-centos-6.log +80 -0
  36. data/acceptance/fips/.kitchen/logs/kitchen.log +4 -0
  37. data/chef.gemspec +1 -1
  38. data/lib/chef/application/client.rb +1 -1
  39. data/lib/chef/application/knife.rb +1 -1
  40. data/lib/chef/application/solo.rb +1 -0
  41. data/lib/chef/cookbook/remote_file_vendor.rb +1 -1
  42. data/lib/chef/cookbook/synchronizer.rb +20 -7
  43. data/lib/chef/cookbook_manifest.rb +8 -0
  44. data/lib/chef/deprecated.rb +10 -0
  45. data/lib/chef/knife/client_key_create.rb +3 -0
  46. data/lib/chef/knife/client_key_delete.rb +1 -0
  47. data/lib/chef/knife/client_key_edit.rb +1 -0
  48. data/lib/chef/knife/client_key_list.rb +1 -0
  49. data/lib/chef/knife/client_key_show.rb +1 -0
  50. data/lib/chef/knife/user_key_create.rb +1 -0
  51. data/lib/chef/knife/user_key_delete.rb +1 -0
  52. data/lib/chef/knife/user_key_edit.rb +1 -0
  53. data/lib/chef/knife/user_key_list.rb +1 -0
  54. data/lib/chef/knife/user_key_show.rb +1 -0
  55. data/lib/chef/local_mode.rb +1 -0
  56. data/lib/chef/mixin/which.rb +1 -1
  57. data/lib/chef/platform/service_helpers.rb +1 -1
  58. data/lib/chef/provider/apt_repository.rb +7 -4
  59. data/lib/chef/provider/execute.rb +1 -1
  60. data/lib/chef/provider/package/cab.rb +18 -13
  61. data/lib/chef/provider/package/msu.rb +2 -2
  62. data/lib/chef/provider/package/rubygems.rb +3 -5
  63. data/lib/chef/provider/user/aix.rb +1 -1
  64. data/lib/chef/provider/user/windows.rb +1 -1
  65. data/lib/chef/providers.rb +0 -1
  66. data/lib/chef/resource/breakpoint.rb +12 -0
  67. data/lib/chef/resource/env.rb +3 -35
  68. data/lib/chef/resource/route.rb +13 -107
  69. data/lib/chef/resource/service.rb +5 -5
  70. data/lib/chef/resource/user.rb +6 -4
  71. data/lib/chef/resource/windows_task.rb +3 -3
  72. data/lib/chef/run_context.rb +7 -0
  73. data/lib/chef/runner.rb +2 -1
  74. data/lib/chef/version.rb +1 -1
  75. data/spec/functional/resource/chocolatey_package_spec.rb +1 -8
  76. data/spec/functional/resource/registry_spec.rb +1 -1
  77. data/spec/functional/resource/user/useradd_spec.rb +1 -1
  78. data/spec/functional/resource/windows_task_spec.rb +459 -0
  79. data/spec/integration/client/client_spec.rb +32 -0
  80. data/spec/spec_helper.rb +2 -0
  81. data/spec/support/platform_helpers.rb +7 -0
  82. data/spec/support/shared/unit/provider/useradd_based_user_provider.rb +3 -3
  83. data/spec/unit/cookbook/synchronizer_spec.rb +5 -4
  84. data/spec/unit/cookbook_manifest_spec.rb +17 -2
  85. data/spec/unit/provider/env_spec.rb +2 -2
  86. data/spec/unit/provider/group/dscl_spec.rb +2 -2
  87. data/spec/unit/provider/group/pw_spec.rb +3 -3
  88. data/spec/unit/provider/group/usermod_spec.rb +6 -6
  89. data/spec/unit/provider/group/windows_spec.rb +3 -3
  90. data/spec/unit/provider/group_spec.rb +4 -4
  91. data/spec/unit/provider/http_request_spec.rb +1 -1
  92. data/spec/unit/provider/package/aix_spec.rb +2 -2
  93. data/spec/unit/provider/package/apt_spec.rb +2 -2
  94. data/spec/unit/provider/package/ips_spec.rb +2 -2
  95. data/spec/unit/provider/package/macports_spec.rb +4 -4
  96. data/spec/unit/provider/package/pacman_spec.rb +2 -2
  97. data/spec/unit/provider/package/rubygems_spec.rb +14 -11
  98. data/spec/unit/provider/package/yum_spec.rb +10 -10
  99. data/spec/unit/provider/route_spec.rb +7 -7
  100. data/spec/unit/provider/service/arch_service_spec.rb +6 -6
  101. data/spec/unit/provider/service/init_service_spec.rb +2 -2
  102. data/spec/unit/provider/service/invokercd_service_spec.rb +1 -1
  103. data/spec/unit/provider/service/simple_service_spec.rb +1 -1
  104. data/spec/unit/provider/service/upstart_service_spec.rb +5 -5
  105. data/spec/unit/provider/service_spec.rb +1 -1
  106. data/spec/unit/provider/user/aix_spec.rb +97 -0
  107. data/spec/unit/provider/user/pw_spec.rb +5 -5
  108. data/spec/unit/provider/user_spec.rb +1 -1
  109. data/spec/unit/provider_resolver_spec.rb +11 -11
  110. data/spec/unit/resource/breakpoint_spec.rb +28 -11
  111. data/spec/unit/resource/windows_task_spec.rb +2 -2
  112. data/spec/unit/runner_spec.rb +4 -0
  113. data/tasks/bin/run_external_test +20 -42
  114. data/tasks/bundle.rb +0 -8
  115. data/tasks/changelog.rb +5 -1
  116. data/tasks/dependencies.rb +4 -2
  117. metadata +80 -19
  118. data/acceptance/fips/.acceptance/acceptance-cookbook/.gitignore +0 -2
  119. data/acceptance/fips/.acceptance/acceptance-cookbook/metadata.rb +0 -2
  120. data/acceptance/fips/.acceptance/acceptance-cookbook/recipes/destroy.rb +0 -1
  121. data/acceptance/fips/.acceptance/acceptance-cookbook/recipes/provision.rb +0 -1
  122. data/acceptance/fips/.acceptance/acceptance-cookbook/recipes/verify.rb +0 -1
  123. data/acceptance/fips/.kitchen.yml +0 -8
  124. data/acceptance/fips/test/integration/fips-integration/serverspec/Gemfile +0 -9
  125. data/acceptance/fips/test/integration/fips-integration/serverspec/fips-integration_spec.rb +0 -52
  126. data/acceptance/fips/test/integration/fips-unit-functional/serverspec/Gemfile +0 -7
  127. data/acceptance/fips/test/integration/fips-unit-functional/serverspec/fips-unit-functional_spec.rb +0 -56
  128. data/lib/chef/provider/breakpoint.rb +0 -38
  129. data/spec/unit/provider/breakpoint_spec.rb +0 -53
  130. data/tasks/bin/create-override-gemfile +0 -110
  131. data/tasks/gemfile_util.rb +0 -390
@@ -527,7 +527,7 @@ describe Chef::Provider::Package::Yum do
527
527
  end
528
528
 
529
529
  it "should run yum localinstall if given a path to an rpm" do
530
- allow(@new_resource).to receive(:source).and_return("/tmp/emacs-21.4-20.el5.i386.rpm")
530
+ @new_resource.source("/tmp/emacs-21.4-20.el5.i386.rpm")
531
531
  expect(@provider).to receive(:yum_command).with(
532
532
  "-d0 -e0 -y localinstall /tmp/emacs-21.4-20.el5.i386.rpm"
533
533
  )
@@ -546,7 +546,7 @@ describe Chef::Provider::Package::Yum do
546
546
  end
547
547
 
548
548
  it "should run yum install with the package name, version and arch" do
549
- allow(@new_resource).to receive(:arch).and_return("i386")
549
+ @new_resource.arch("i386")
550
550
  allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1)
551
551
  @provider.load_current_resource
552
552
  expect(@provider).to receive(:yum_command).with(
@@ -584,7 +584,7 @@ describe Chef::Provider::Package::Yum do
584
584
  end
585
585
 
586
586
  it "should raise an exception if candidate version is older than the installed version and allow_downgrade is false" do
587
- allow(@new_resource).to receive(:allow_downgrade).and_return(false)
587
+ @new_resource.allow_downgrade(false)
588
588
  @yum_cache = double(
589
589
  "Chef::Provider::Yum::YumCache",
590
590
  :reload_installed => true,
@@ -627,7 +627,7 @@ describe Chef::Provider::Package::Yum do
627
627
  end
628
628
 
629
629
  it "should run yum downgrade if candidate version is older than the installed version and allow_downgrade is true" do
630
- allow(@new_resource).to receive(:allow_downgrade).and_return(true)
630
+ @new_resource.allow_downgrade(true)
631
631
  @yum_cache = double(
632
632
  "Chef::Provider::Yum::YumCache",
633
633
  :reload_installed => true,
@@ -651,7 +651,7 @@ describe Chef::Provider::Package::Yum do
651
651
  end
652
652
 
653
653
  it "should run yum install then flush the cache if :after is true" do
654
- allow(@new_resource).to receive(:flush_cache).and_return({ :after => true, :before => false })
654
+ @new_resource.flush_cache({ :after => true, :before => false })
655
655
  @provider.load_current_resource
656
656
  allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1)
657
657
  expect(@provider).to receive(:yum_command).with(
@@ -662,7 +662,7 @@ describe Chef::Provider::Package::Yum do
662
662
  end
663
663
 
664
664
  it "should run yum install then not flush the cache if :after is false" do
665
- allow(@new_resource).to receive(:flush_cache).and_return({ :after => false, :before => false })
665
+ @new_resource.flush_cache({ :after => false, :before => false })
666
666
  @provider.load_current_resource
667
667
  allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1)
668
668
  expect(@provider).to receive(:yum_command).with(
@@ -758,7 +758,7 @@ describe Chef::Provider::Package::Yum do
758
758
  end
759
759
 
760
760
  it "should run yum remove with the package name and arch" do
761
- allow(@new_resource).to receive(:arch).and_return("x86_64")
761
+ @new_resource.arch("x86_64")
762
762
  expect(@provider).to receive(:yum_command).with(
763
763
  "-d0 -e0 -y remove emacs-1.0.x86_64"
764
764
  )
@@ -2145,8 +2145,8 @@ describe "Chef::Provider::Package::Yum - Multi" do
2145
2145
 
2146
2146
  describe "when evaluating the correctness of the resource" do
2147
2147
  it "raises an error if the array lengths of package name, arch, and version do not match up" do
2148
- allow(@new_resource).to receive(:version).and_return(["1.1"])
2149
- allow(@new_resource).to receive(:arch).and_return(%w{x86_64 i386 i686})
2148
+ @new_resource.version(["1.1"])
2149
+ @new_resource.arch(%w{x86_64 i386 i686})
2150
2150
  expect { @provider.check_resource_semantics! }.to raise_error(Chef::Exceptions::InvalidResourceSpecification)
2151
2151
  end
2152
2152
  end
@@ -2245,7 +2245,7 @@ describe "Chef::Provider::Package::Yum - Multi" do
2245
2245
 
2246
2246
  it "should run yum install with the package name, version and arch" do
2247
2247
  @provider.load_current_resource
2248
- allow(@new_resource).to receive(:arch).and_return(%w{i386 i386})
2248
+ @new_resource.arch(%w{i386 i386})
2249
2249
  allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1)
2250
2250
  expect(@provider).to receive(:yum_command).with(
2251
2251
  "-d0 -e0 -y install cups-1.2.4-11.19.el5.i386 vim-1.0.i386"
@@ -144,12 +144,12 @@ describe Chef::Provider::Route do
144
144
 
145
145
  describe Chef::Provider::Route, "generate_command for action_add" do
146
146
  it "should include a netmask when a one is specified" do
147
- allow(@new_resource).to receive(:netmask).and_return("255.255.0.0")
147
+ @new_resource.netmask("255.255.0.0")
148
148
  expect(@provider.generate_command(:add).join(" ")).to match(/\/\d{1,2}/)
149
149
  end
150
150
 
151
151
  it "should not include a netmask when a one is specified" do
152
- allow(@new_resource).to receive(:netmask).and_return(nil)
152
+ @new_resource.netmask(nil)
153
153
  expect(@provider.generate_command(:add).join(" ")).not_to match(/\/\d{1,2}/)
154
154
  end
155
155
 
@@ -158,19 +158,19 @@ describe Chef::Provider::Route do
158
158
  end
159
159
 
160
160
  it "should not include ' via $gateway ' when a gateway is not specified" do
161
- allow(@new_resource).to receive(:gateway).and_return(nil)
161
+ @new_resource.gateway(nil)
162
162
  expect(@provider.generate_command(:add).join(" ")).not_to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}/)
163
163
  end
164
164
  end
165
165
 
166
166
  describe Chef::Provider::Route, "generate_command for action_delete" do
167
167
  it "should include a netmask when a one is specified" do
168
- allow(@new_resource).to receive(:netmask).and_return("255.255.0.0")
168
+ @new_resource.netmask("255.255.0.0")
169
169
  expect(@provider.generate_command(:delete).join(" ")).to match(/\/\d{1,2}/)
170
170
  end
171
171
 
172
172
  it "should not include a netmask when a one is specified" do
173
- allow(@new_resource).to receive(:netmask).and_return(nil)
173
+ @new_resource.netmask(nil)
174
174
  expect(@provider.generate_command(:delete).join(" ")).not_to match(/\/\d{1,2}/)
175
175
  end
176
176
 
@@ -179,14 +179,14 @@ describe Chef::Provider::Route do
179
179
  end
180
180
 
181
181
  it "should not include ' via $gateway ' when a gateway is not specified" do
182
- allow(@new_resource).to receive(:gateway).and_return(nil)
182
+ @new_resource.gateway(nil)
183
183
  expect(@provider.generate_command(:delete).join(" ")).not_to match(/\svia\s#{Regexp.escape(@new_resource.gateway.to_s)}/)
184
184
  end
185
185
  end
186
186
 
187
187
  describe Chef::Provider::Route, "config_file_contents for action_add" do
188
188
  it "should include a netmask when a one is specified" do
189
- allow(@new_resource).to receive(:netmask).and_return("255.255.0.0")
189
+ @new_resource.netmask("255.255.0.0")
190
190
  expect(@provider.config_file_contents(:add, target: @new_resource.target, netmask: @new_resource.netmask)).to match(/\/\d{1,2}.*\n$/)
191
191
  end
192
192
 
@@ -221,7 +221,7 @@ RUNNING_PS
221
221
  # end
222
222
 
223
223
  it "should call the start command if one is specified" do
224
- allow(@new_resource).to receive(:start_command).and_return("/etc/rc.d/chef startyousillysally")
224
+ @new_resource.start_command("/etc/rc.d/chef startyousillysally")
225
225
  expect(@provider).to receive(:shell_out_with_systems_locale!).with("/etc/rc.d/chef startyousillysally")
226
226
  @provider.start_service()
227
227
  end
@@ -247,7 +247,7 @@ RUNNING_PS
247
247
  # end
248
248
 
249
249
  it "should call the stop command if one is specified" do
250
- allow(@new_resource).to receive(:stop_command).and_return("/etc/rc.d/chef itoldyoutostop")
250
+ @new_resource.stop_command("/etc/rc.d/chef itoldyoutostop")
251
251
  expect(@provider).to receive(:shell_out_with_systems_locale!).with("/etc/rc.d/chef itoldyoutostop")
252
252
  @provider.stop_service()
253
253
  end
@@ -274,13 +274,13 @@ RUNNING_PS
274
274
  # end
275
275
 
276
276
  it "should call 'restart' on the service_name if the resource supports it" do
277
- allow(@new_resource).to receive(:supports).and_return({ :restart => true })
277
+ @new_resource.supports({ :restart => true })
278
278
  expect(@provider).to receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} restart")
279
279
  @provider.restart_service()
280
280
  end
281
281
 
282
282
  it "should call the restart_command if one has been specified" do
283
- allow(@new_resource).to receive(:restart_command).and_return("/etc/rc.d/chef restartinafire")
283
+ @new_resource.restart_command("/etc/rc.d/chef restartinafire")
284
284
  expect(@provider).to receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} restartinafire")
285
285
  @provider.restart_service()
286
286
  end
@@ -309,13 +309,13 @@ RUNNING_PS
309
309
  # end
310
310
 
311
311
  it "should call 'reload' on the service if it supports it" do
312
- allow(@new_resource).to receive(:supports).and_return({ :reload => true })
312
+ @new_resource.supports({ :reload => true })
313
313
  expect(@provider).to receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} reload")
314
314
  @provider.reload_service()
315
315
  end
316
316
 
317
317
  it "should should run the user specified reload command if one is specified and the service doesn't support reload" do
318
- allow(@new_resource).to receive(:reload_command).and_return("/etc/rc.d/chef lollerpants")
318
+ @new_resource.reload_command("/etc/rc.d/chef lollerpants")
319
319
  expect(@provider).to receive(:shell_out_with_systems_locale!).with("/etc/rc.d/#{@new_resource.service_name} lollerpants")
320
320
  @provider.reload_service()
321
321
  end
@@ -83,7 +83,7 @@ PS
83
83
 
84
84
  describe "when a status command has been specified" do
85
85
  before do
86
- allow(@new_resource).to receive(:status_command).and_return("/etc/init.d/chefhasmonkeypants status")
86
+ @new_resource.status_command("/etc/init.d/chefhasmonkeypants status")
87
87
  end
88
88
 
89
89
  it "should run the services status command if one has been specified" do
@@ -95,7 +95,7 @@ PS
95
95
 
96
96
  describe "when an init command has been specified" do
97
97
  before do
98
- allow(@new_resource).to receive(:init_command).and_return("/opt/chef-server/service/erchef")
98
+ @new_resource.init_command("/opt/chef-server/service/erchef")
99
99
  @provider = Chef::Provider::Service::Init.new(@new_resource, @run_context)
100
100
  end
101
101
 
@@ -83,7 +83,7 @@ PS
83
83
 
84
84
  describe "when a status command has been specified" do
85
85
  before do
86
- allow(@new_resource).to receive(:status_command).and_return("/usr/sbin/invoke-rc.d chefhasmonkeypants status")
86
+ @new_resource.status_command("/usr/sbin/invoke-rc.d chefhasmonkeypants status")
87
87
  end
88
88
 
89
89
  it "should run the services status command if one has been specified" do
@@ -106,7 +106,7 @@ NOMOCKINGSTRINGSPLZ
106
106
 
107
107
  describe "when starting the service" do
108
108
  it "should call the start command if one is specified" do
109
- allow(@new_resource).to receive(:start_command).and_return("#{@new_resource.start_command}")
109
+ @new_resource.start_command("#{@new_resource.start_command}")
110
110
  expect(@provider).to receive(:shell_out_with_systems_locale!).with("#{@new_resource.start_command}")
111
111
  @provider.start_service()
112
112
  end
@@ -194,7 +194,7 @@ describe Chef::Provider::Service::Upstart do
194
194
 
195
195
  describe "when a status command has been specified" do
196
196
  before do
197
- allow(@new_resource).to receive(:status_command).and_return("/bin/chefhasmonkeypants status")
197
+ @new_resource.status_command("/bin/chefhasmonkeypants status")
198
198
  end
199
199
 
200
200
  it "should run the services status command if one has been specified" do
@@ -266,7 +266,7 @@ describe Chef::Provider::Service::Upstart do
266
266
 
267
267
  it "should call the start command if one is specified" do
268
268
  @provider.upstart_service_running = false
269
- allow(@new_resource).to receive(:start_command).and_return("/sbin/rsyslog startyousillysally")
269
+ @new_resource.start_command("/sbin/rsyslog startyousillysally")
270
270
  expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog startyousillysally")
271
271
  @provider.start_service()
272
272
  end
@@ -294,7 +294,7 @@ describe Chef::Provider::Service::Upstart do
294
294
 
295
295
  it "should call the restart command if one is specified" do
296
296
  allow(@current_resource).to receive(:running).and_return(true)
297
- allow(@new_resource).to receive(:restart_command).and_return("/sbin/rsyslog restartyousillysally")
297
+ @new_resource.restart_command("/sbin/rsyslog restartyousillysally")
298
298
  expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog restartyousillysally")
299
299
  @provider.restart_service()
300
300
  end
@@ -316,7 +316,7 @@ describe Chef::Provider::Service::Upstart do
316
316
 
317
317
  it "should call the reload command if one is specified" do
318
318
  allow(@current_resource).to receive(:running).and_return(true)
319
- allow(@new_resource).to receive(:reload_command).and_return("/sbin/rsyslog reloadyousillysally")
319
+ @new_resource.reload_command("/sbin/rsyslog reloadyousillysally")
320
320
  expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog reloadyousillysally")
321
321
  @provider.reload_service()
322
322
  end
@@ -329,7 +329,7 @@ describe Chef::Provider::Service::Upstart do
329
329
 
330
330
  it "should call the stop command if one is specified" do
331
331
  @provider.upstart_service_running = true
332
- allow(@new_resource).to receive(:stop_command).and_return("/sbin/rsyslog stopyousillysally")
332
+ @new_resource.stop_command("/sbin/rsyslog stopyousillysally")
333
333
  expect(@provider).to receive(:shell_out_with_systems_locale!).with("/sbin/rsyslog stopyousillysally")
334
334
  @provider.stop_service()
335
335
  end
@@ -123,7 +123,7 @@ describe Chef::Provider::Service do
123
123
 
124
124
  it "should raise an exception if reload isn't supported" do
125
125
  @new_resource.supports(:reload => false)
126
- allow(@new_resource).to receive(:reload_command).and_return(false)
126
+ @new_resource.reload_command(false)
127
127
  expect { @provider.run_action(:reload) }.to raise_error(Chef::Exceptions::UnsupportedAction)
128
128
  end
129
129
 
@@ -0,0 +1,97 @@
1
+ # Copyright:: Copyright 2017, Chef Software Inc.
2
+ #
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "mixlib/shellout"
19
+ require "spec_helper"
20
+
21
+ describe Chef::Provider::User::Aix do
22
+
23
+ let(:shellcmdresult) do
24
+ Struct.new(:stdout, :stderr, :exitstatus)
25
+ end
26
+
27
+ let(:node) do
28
+ Chef::Node.new.tap do |node|
29
+ node.automatic["platform"] = "solaris2"
30
+ end
31
+ end
32
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
33
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
34
+ let(:new_resource) do
35
+ Chef::Resource::User::AixUser.new("adam", @run_context)
36
+ end
37
+ let(:current_resource) do
38
+ Chef::Resource::User::AixUser.new("adam", @run_context).tap do |cr|
39
+ cr.home "/home/adam"
40
+ end
41
+ end
42
+
43
+ subject(:provider) do
44
+ described_class.new(new_resource, run_context).tap do |p|
45
+ p.current_resource = current_resource
46
+ end
47
+ end
48
+
49
+ describe "when we set a password" do
50
+ before do
51
+ new_resource.password "Ostagazuzulum"
52
+ end
53
+
54
+ it "should call chpasswd correctly" do
55
+ expect(provider).to receive(:shell_out!).with("echo 'adam:Ostagazuzulum' | chpasswd -e").and_return true
56
+ provider.manage_user
57
+ end
58
+ end
59
+
60
+ describe "#create_user" do
61
+ context "with a system user" do
62
+ before { new_resource.system(true) }
63
+ it "should add the user to the system group" do
64
+ expect(provider).to receive(:shell_out!).with("useradd", "-g", "system", "adam")
65
+ provider.create_user
66
+ end
67
+ end
68
+
69
+ context "with manage_home" do
70
+ before do
71
+ new_resource.manage_home(true)
72
+ new_resource.home("/home/adam")
73
+ allow(provider).to receive(:updating_home?).and_return(true)
74
+ end
75
+
76
+ it "should create the home directory" do
77
+ allow(provider).to receive(:shell_out!).with("usermod", "-d", "/home/adam", "adam")
78
+ expect(FileUtils).to receive(:mkdir_p).and_return(true)
79
+ provider.manage_user
80
+ end
81
+
82
+ it "should move an existing home dir" do
83
+ allow(provider).to receive(:shell_out!).with("usermod", "-d", "/mnt/home/adam", "adam")
84
+ new_resource.home("/mnt/home/adam")
85
+ allow(File).to receive(:directory?).with("/home/adam").and_return(true)
86
+ expect(FileUtils).to receive(:mv).with("/home/adam", "/mnt/home/adam")
87
+ provider.manage_user
88
+ end
89
+
90
+ it "should not pass -m" do
91
+ allow(FileUtils).to receive(:mkdir_p).and_return(true)
92
+ expect(provider).to receive(:shell_out!).with("usermod", "-d", "/home/adam", "adam")
93
+ provider.manage_user
94
+ end
95
+ end
96
+ end
97
+ end
@@ -160,7 +160,7 @@ describe Chef::Provider::User::Pw do
160
160
 
161
161
  describe "and the new password has not been specified" do
162
162
  before(:each) do
163
- allow(@new_resource).to receive(:password).and_return(nil)
163
+ @new_resource.password(nil)
164
164
  end
165
165
 
166
166
  it "logs an appropriate message" do
@@ -170,19 +170,19 @@ describe Chef::Provider::User::Pw do
170
170
 
171
171
  describe "and the new password has been specified" do
172
172
  before(:each) do
173
- allow(@new_resource).to receive(:password).and_return("abracadabra")
173
+ @new_resource.password("abracadabra")
174
174
  end
175
175
 
176
176
  it "should check for differences in password between the new and current resources" do
177
177
  expect(@current_resource).to receive(:password)
178
- expect(@new_resource).to receive(:password)
178
+ expect(@new_resource).to receive(:password).and_call_original.at_least(:once)
179
179
  @provider.modify_password
180
180
  end
181
181
  end
182
182
 
183
183
  describe "and the passwords are identical" do
184
184
  before(:each) do
185
- allow(@new_resource).to receive(:password).and_return("abracadabra")
185
+ @new_resource.password("abracadabra")
186
186
  allow(@current_resource).to receive(:password).and_return("abracadabra")
187
187
  end
188
188
 
@@ -193,7 +193,7 @@ describe Chef::Provider::User::Pw do
193
193
 
194
194
  describe "and the passwords are different" do
195
195
  before(:each) do
196
- allow(@new_resource).to receive(:password).and_return("abracadabra")
196
+ @new_resource.password("abracadabra")
197
197
  allow(@current_resource).to receive(:password).and_return("sesame")
198
198
  end
199
199
 
@@ -129,7 +129,7 @@ describe Chef::Provider::User do
129
129
  end
130
130
 
131
131
  it "shouldn't try and convert the group gid if none has been supplied" do
132
- allow(@new_resource).to receive(:gid).and_return(nil)
132
+ @new_resource.gid(false)
133
133
  expect(@provider).not_to receive(:convert_group_name)
134
134
  @provider.load_current_resource
135
135
  end
@@ -192,34 +192,34 @@ describe Chef::ProviderResolver do
192
192
  stub_service_providers(:debian, :invokercd, :upstart, :systemd)
193
193
  end
194
194
 
195
- it "when only the SysV init script exists, it returns a Service::Debian provider" do
195
+ it "when both the SysV init and Systemd script exists, it returns a Service::Debian provider" do
196
196
  stub_service_configs(:initd, :systemd)
197
197
  expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
198
198
  end
199
199
 
200
- it "when both SysV and Upstart scripts exist, it returns a Service::Upstart provider" do
200
+ it "when SysV, Upstart, and Systemd scripts exist, it returns a Service::Systemd provider" do
201
201
  stub_service_configs(:initd, :upstart, :systemd)
202
202
  expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
203
203
  end
204
204
 
205
- it "when only the Upstart script exists, it returns a Service::Upstart provider" do
205
+ it "when both the Upstart and Systemd scripts exists, it returns a Service::Systemd provider" do
206
206
  stub_service_configs(:upstart, :systemd)
207
207
  expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
208
208
  end
209
209
 
210
- it "when both do not exist, it calls the old style provider resolver and returns a Debian Provider" do
210
+ it "when both do not exist, it calls the old style provider resolver and returns a Systemd Provider" do
211
211
  stub_service_configs(:systemd)
212
212
  expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
213
213
  end
214
214
 
215
- it "when only the SysV init script exists, it returns a Service::Debian provider" do
215
+ it "when only the SysV init script exists, it returns a Service::Systemd provider" do
216
216
  stub_service_configs(:initd)
217
- expect(resolved_provider).to eql(Chef::Provider::Service::Debian)
217
+ expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
218
218
  end
219
219
 
220
- it "when both SysV and Upstart scripts exist, it returns a Service::Upstart provider" do
220
+ it "when both SysV and Upstart scripts exist, it returns a Service::Systemd provider" do
221
221
  stub_service_configs(:initd, :upstart)
222
- expect(resolved_provider).to eql(Chef::Provider::Service::Upstart)
222
+ expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
223
223
  end
224
224
 
225
225
  it "when only the Upstart script exists, it returns a Service::Upstart provider" do
@@ -227,7 +227,7 @@ describe Chef::ProviderResolver do
227
227
  expect(resolved_provider).to eql(Chef::Provider::Service::Upstart)
228
228
  end
229
229
 
230
- it "when both do not exist, it calls the old style provider resolver and returns a Debian Provider" do
230
+ it "when both do not exist, it calls the old style provider resolver and returns a Systemd Provider" do
231
231
  stub_service_configs
232
232
  expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
233
233
  end
@@ -410,7 +410,7 @@ describe Chef::ProviderResolver do
410
410
  stub_service_providers(:debian, :invokercd, :upstart, :systemd)
411
411
  stub_service_configs(:initd, :upstart)
412
412
  mock_shellout_command("/bin/systemctl list-unit-files", exitstatus: 1)
413
- expect(resolved_provider).to eql(Chef::Provider::Service::Upstart)
413
+ expect(resolved_provider).to eql(Chef::Provider::Service::Systemd)
414
414
  end
415
415
  end
416
416
 
@@ -554,7 +554,7 @@ describe Chef::ProviderResolver do
554
554
  PROVIDERS =
555
555
  {
556
556
  bash: [ Chef::Resource::Bash, Chef::Provider::Script ],
557
- breakpoint: [ Chef::Resource::Breakpoint, Chef::Provider::Breakpoint ],
557
+ breakpoint: [ Chef::Resource::Breakpoint, Chef::Resource::Breakpoint.action_class ],
558
558
  chef_gem: [ Chef::Resource::ChefGem, Chef::Provider::Package::Rubygems ],
559
559
  cookbook_file: [ Chef::Resource::CookbookFile, Chef::Provider::CookbookFile ],
560
560
  csh: [ Chef::Resource::Csh, Chef::Provider::Script ],