chef 10.16.6 → 10.18.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/distro/common/html/chef-client.8.html +4 -4
  2. data/distro/common/html/chef-expander.8.html +4 -4
  3. data/distro/common/html/chef-expanderctl.8.html +4 -4
  4. data/distro/common/html/chef-server-webui.8.html +4 -4
  5. data/distro/common/html/chef-server.8.html +4 -4
  6. data/distro/common/html/chef-solo.8.html +4 -4
  7. data/distro/common/html/chef-solr.8.html +4 -4
  8. data/distro/common/html/knife-bootstrap.1.html +4 -4
  9. data/distro/common/html/knife-client.1.html +4 -4
  10. data/distro/common/html/knife-configure.1.html +4 -4
  11. data/distro/common/html/knife-cookbook-site.1.html +4 -4
  12. data/distro/common/html/knife-cookbook.1.html +4 -4
  13. data/distro/common/html/knife-data-bag.1.html +4 -4
  14. data/distro/common/html/knife-environment.1.html +4 -4
  15. data/distro/common/html/knife-exec.1.html +4 -4
  16. data/distro/common/html/knife-index.1.html +4 -4
  17. data/distro/common/html/knife-node.1.html +4 -4
  18. data/distro/common/html/knife-role.1.html +4 -4
  19. data/distro/common/html/knife-search.1.html +4 -4
  20. data/distro/common/html/knife-ssh.1.html +4 -4
  21. data/distro/common/html/knife-status.1.html +4 -4
  22. data/distro/common/html/knife-tag.1.html +4 -4
  23. data/distro/common/html/knife.1.html +4 -4
  24. data/distro/common/html/shef.1.html +4 -4
  25. data/distro/common/man/man1/knife-bootstrap.1 +1 -1
  26. data/distro/common/man/man1/knife-client.1 +1 -1
  27. data/distro/common/man/man1/knife-configure.1 +1 -1
  28. data/distro/common/man/man1/knife-cookbook-site.1 +1 -1
  29. data/distro/common/man/man1/knife-cookbook.1 +1 -1
  30. data/distro/common/man/man1/knife-data-bag.1 +1 -1
  31. data/distro/common/man/man1/knife-environment.1 +1 -1
  32. data/distro/common/man/man1/knife-exec.1 +1 -1
  33. data/distro/common/man/man1/knife-index.1 +1 -1
  34. data/distro/common/man/man1/knife-node.1 +1 -1
  35. data/distro/common/man/man1/knife-role.1 +1 -1
  36. data/distro/common/man/man1/knife-search.1 +1 -1
  37. data/distro/common/man/man1/knife-ssh.1 +1 -1
  38. data/distro/common/man/man1/knife-status.1 +1 -1
  39. data/distro/common/man/man1/knife-tag.1 +1 -1
  40. data/distro/common/man/man1/knife.1 +1 -1
  41. data/distro/common/man/man1/shef.1 +1 -1
  42. data/distro/common/man/man8/chef-client.8 +1 -1
  43. data/distro/common/man/man8/chef-expander.8 +1 -1
  44. data/distro/common/man/man8/chef-expanderctl.8 +1 -1
  45. data/distro/common/man/man8/chef-server-webui.8 +1 -1
  46. data/distro/common/man/man8/chef-server.8 +1 -1
  47. data/distro/common/man/man8/chef-solo.8 +1 -1
  48. data/distro/common/man/man8/chef-solr.8 +1 -1
  49. data/lib/chef/api_client.rb +22 -0
  50. data/lib/chef/cookbook/chefignore.rb +1 -1
  51. data/lib/chef/cookbook/cookbook_version_loader.rb +1 -3
  52. data/lib/chef/encrypted_data_bag_item.rb +135 -6
  53. data/lib/chef/formatters/doc.rb +2 -2
  54. data/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb +1 -0
  55. data/lib/chef/knife/bootstrap/archlinux-gems.erb +6 -19
  56. data/lib/chef/knife/bootstrap/centos5-gems.erb +15 -24
  57. data/lib/chef/knife/bootstrap/chef-full.erb +9 -22
  58. data/lib/chef/knife/bootstrap/fedora13-gems.erb +5 -19
  59. data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +4 -16
  60. data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +7 -24
  61. data/lib/chef/knife/bootstrap/ubuntu12.04-gems.erb +5 -19
  62. data/lib/chef/knife/bootstrap.rb +3 -3
  63. data/lib/chef/knife/client_reregister.rb +5 -4
  64. data/lib/chef/knife/cookbook_create.rb +178 -28
  65. data/lib/chef/knife/cookbook_site_install.rb +1 -1
  66. data/lib/chef/knife/core/bootstrap_context.rb +2 -2
  67. data/lib/chef/knife/ssh.rb +31 -15
  68. data/lib/chef/mixin/recipe_definition_dsl_core.rb +1 -1
  69. data/lib/chef/platform.rb +8 -0
  70. data/lib/chef/provider/log.rb +1 -1
  71. data/lib/chef/provider/package/yum-dump.py +20 -0
  72. data/lib/chef/provider/package/yum.rb +41 -0
  73. data/lib/chef/resource/log.rb +10 -1
  74. data/lib/chef/resource.rb +3 -2
  75. data/lib/chef/rest.rb +10 -5
  76. data/lib/chef/version.rb +1 -1
  77. data/spec/data/cookbooks/chefignore +2 -0
  78. data/spec/functional/knife/ssh_spec.rb +59 -1
  79. data/spec/stress/win32/security_spec.rb +4 -4
  80. data/spec/support/matchers/leak.rb +1 -1
  81. data/spec/unit/api_client_spec.rb +90 -17
  82. data/spec/unit/cookbook/chefignore_spec.rb +2 -1
  83. data/spec/unit/encrypted_data_bag_item_spec.rb +177 -6
  84. data/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +20 -0
  85. data/spec/unit/knife/bootstrap_spec.rb +69 -28
  86. data/spec/unit/knife/client_reregister_spec.rb +23 -22
  87. data/spec/unit/knife/cookbook_site_install_spec.rb +12 -2
  88. data/spec/unit/knife/core/bootstrap_context_spec.rb +7 -0
  89. data/spec/unit/knife/data_bag_create_spec.rb +5 -0
  90. data/spec/unit/knife/data_bag_edit_spec.rb +13 -0
  91. data/spec/unit/knife/data_bag_from_file_spec.rb +15 -1
  92. data/spec/unit/knife/ssh_spec.rb +93 -1
  93. data/spec/unit/provider/package/yum_spec.rb +79 -11
  94. data/spec/unit/resource/log_spec.rb +9 -0
  95. metadata +854 -850
@@ -60,7 +60,6 @@ describe Chef::Knife::CookbookSiteInstall do
60
60
 
61
61
 
62
62
  describe "run" do
63
-
64
63
  it "should return an error if a cookbook name is not provided" do
65
64
  @knife.name_args = []
66
65
  @knife.ui.should_receive(:error).with("Please specify a cookbook to download and install.")
@@ -91,7 +90,6 @@ describe Chef::Knife::CookbookSiteInstall do
91
90
  lambda { @knife.run }.should raise_error(SystemExit)
92
91
  end
93
92
 
94
-
95
93
  it "should install the specified version if second argument is a three-digit version" do
96
94
  @knife.name_args = ["getting-started", "0.1.0"]
97
95
  @knife.config[:no_deps] = true
@@ -134,5 +132,17 @@ describe Chef::Knife::CookbookSiteInstall do
134
132
  @repo.should_not_receive(:reset_to_default_state)
135
133
  @knife.run
136
134
  end
135
+
136
+ it "should not raise an error if cookbook_path is a string" do
137
+ @knife.config[:cookbook_path] = @install_path
138
+ @knife.config[:no_deps] = true
139
+ @knife.name_args = ["getting-started"]
140
+ upstream_file = File.join(@install_path, "getting-started.tar.gz")
141
+ @knife.should_receive(:download_cookbook_to).with(upstream_file)
142
+ @knife.should_receive(:extract_cookbook).with(upstream_file, "0.3.0")
143
+ @knife.should_receive(:clear_existing_files).with(File.join(@install_path, "getting-started"))
144
+ @repo.should_receive(:merge_updates_from).with("getting-started", "0.3.0")
145
+ lambda { @knife.run }.should_not raise_error
146
+ end
137
147
  end
138
148
  end
@@ -56,6 +56,13 @@ describe Chef::Knife::Core::BootstrapContext do
56
56
  @context.validation_key.should == IO.read(File.join(CHEF_SPEC_DATA, 'ssl', 'private_key.pem'))
57
57
  end
58
58
 
59
+ it "reads the validation key when it contains a ~" do
60
+ IO.should_receive(:read).with(File.expand_path("my.key", ENV['HOME']))
61
+ @chef_config = {:validation_key => '~/my.key'}
62
+ @context = Chef::Knife::Core::BootstrapContext.new(@config, @run_list, @chef_config)
63
+ @context.validation_key
64
+ end
65
+
59
66
  it "generates the config file data" do
60
67
  expected=<<-EXPECTED
61
68
  log_level :info
@@ -75,6 +75,11 @@ describe Chef::Knife::DataBagCreate do
75
75
  @knife.should_receive(:create_object).and_yield(@plain_data)
76
76
  data_bag_item = Chef::DataBagItem.from_hash(@enc_data)
77
77
  data_bag_item.data_bag("sudoing_admins")
78
+
79
+ # Random IV is used each time the data bag item is encrypted, so values
80
+ # will not be equal if we re-encrypt.
81
+ Chef::EncryptedDataBagItem.should_receive(:encrypt_data_bag_item).and_return(@enc_data)
82
+
78
83
  @rest.should_receive(:post_rest).with("data", {'name' => 'sudoing_admins'}).ordered
79
84
  @rest.should_receive(:post_rest).with("data/sudoing_admins", data_bag_item).ordered
80
85
  end
@@ -59,6 +59,19 @@ describe Chef::Knife::DataBagEdit do
59
59
  @enc_edited_data = Chef::EncryptedDataBagItem.encrypt_data_bag_item(@edited_data,
60
60
  @secret)
61
61
  Chef::DataBagItem.stub!(:load).with('bag_name', 'item_name').and_return(@enc_data)
62
+
63
+ # Random IV is used each time the data bag item is encrypted, so values
64
+ # will not be equal if we encrypt same value twice.
65
+ Chef::EncryptedDataBagItem.should_receive(:encrypt_data_bag_item).and_return(@enc_edited_data)
66
+
67
+ @secret_file = Tempfile.new("encrypted_data_bag_secret_file_test")
68
+ @secret_file.puts(@secret)
69
+ @secret_file.flush
70
+ end
71
+
72
+ after do
73
+ @secret_file.close
74
+ @secret_file.unlink
62
75
  end
63
76
 
64
77
  it "decrypts and encrypts via --secret" do
@@ -142,6 +142,19 @@ describe Chef::Knife::DataBagFromFile do
142
142
  @secret = "abc123SECRET"
143
143
  @enc_data = Chef::EncryptedDataBagItem.encrypt_data_bag_item(@plain_data,
144
144
  @secret)
145
+
146
+ # Random IV is used each time the data bag item is encrypted, so values
147
+ # will not be equal if we re-encrypt.
148
+ Chef::EncryptedDataBagItem.should_receive(:encrypt_data_bag_item).and_return(@enc_data)
149
+
150
+ @secret_file = Tempfile.new("encrypted_data_bag_secret_file_test")
151
+ @secret_file.puts(@secret)
152
+ @secret_file.flush
153
+ end
154
+
155
+ after do
156
+ @secret_file.close
157
+ @secret_file.unlink
145
158
  end
146
159
 
147
160
  it "encrypts values when given --secret" do
@@ -177,7 +190,8 @@ describe Chef::Knife::DataBagFromFile do
177
190
  it "prints help if given no arguments" do
178
191
  @knife.instance_variable_set(:@name_args, [])
179
192
  lambda { @knife.run }.should raise_error(SystemExit)
180
- @stdout.string.should match(/^knife data bag from file BAG FILE|FOLDER [FILE|FOLDER..] \(options\)/)
193
+ expected = 'knife data bag from file BAG FILE|FOLDER [FILE|FOLDER..] (options)'
194
+ @stdout.string.should include(expected)
181
195
  end
182
196
  end
183
197
 
@@ -197,5 +197,97 @@ describe Chef::Knife::Ssh do
197
197
  @knife.session.servers[0].user.should == "locutus"
198
198
  end
199
199
  end
200
- end
201
200
 
201
+ describe "#ssh_command" do
202
+ let(:execution_channel) { double(:execution_channel, :on_data => nil) }
203
+ let(:session_channel) { double(:session_channel, :request_pty => nil)}
204
+
205
+ let(:execution_channel2) { double(:execution_channel, :on_data => nil) }
206
+ let(:session_channel2) { double(:session_channel, :request_pty => nil)}
207
+
208
+ let(:session) { double(:session, :loop => nil) }
209
+
210
+ let(:command) { "false" }
211
+
212
+ before do
213
+ execution_channel.
214
+ should_receive(:on_request).
215
+ and_yield(nil, double(:data_stream, :read_long => exit_status))
216
+
217
+ session_channel.
218
+ should_receive(:exec).
219
+ with(command).
220
+ and_yield(execution_channel, true)
221
+
222
+ execution_channel2.
223
+ should_receive(:on_request).
224
+ and_yield(nil, double(:data_stream, :read_long => exit_status2))
225
+
226
+ session_channel2.
227
+ should_receive(:exec).
228
+ with(command).
229
+ and_yield(execution_channel2, true)
230
+
231
+ session.
232
+ should_receive(:open_channel).
233
+ and_yield(session_channel).
234
+ and_yield(session_channel2)
235
+ end
236
+
237
+ context "both connections return 0" do
238
+ let(:exit_status) { 0 }
239
+ let(:exit_status2) { 0 }
240
+
241
+ it "returns a 0 exit code" do
242
+ @knife.ssh_command(command, session).should == 0
243
+ end
244
+ end
245
+
246
+ context "the first connection returns 1 and the second returns 0" do
247
+ let(:exit_status) { 1 }
248
+ let(:exit_status2) { 0 }
249
+
250
+ it "returns a non-zero exit code" do
251
+ @knife.ssh_command(command, session).should == 1
252
+ end
253
+ end
254
+
255
+ context "the first connection returns 1 and the second returns 2" do
256
+ let(:exit_status) { 1 }
257
+ let(:exit_status2) { 2 }
258
+
259
+ it "returns a non-zero exit code" do
260
+ @knife.ssh_command(command, session).should == 2
261
+ end
262
+ end
263
+ end
264
+
265
+ describe "#run" do
266
+ before do
267
+ @query = Chef::Search::Query.new
268
+ @query.should_receive(:search).and_return([[@node_foo]])
269
+ Chef::Search::Query.stub!(:new).and_return(@query)
270
+ @knife.stub(:ssh_command).and_return(exit_code)
271
+ @knife.name_args = ['*:*', 'false']
272
+ @knife.config[:manual] = false
273
+ end
274
+
275
+ context "with an error" do
276
+ let(:exit_code) { 1 }
277
+
278
+ it "should exit with a non-zero exit code" do
279
+ @knife.should_receive(:exit).with(exit_code)
280
+ @knife.run
281
+ end
282
+ end
283
+
284
+ context "with no error" do
285
+ let(:exit_code) { 0 }
286
+
287
+ it "should not exit" do
288
+ @knife.should_not_receive(:exit)
289
+ @knife.run
290
+ end
291
+ end
292
+ end
293
+ end
@@ -34,7 +34,8 @@ describe Chef::Provider::Package::Yum do
34
34
  :package_available? => true,
35
35
  :version_available? => true,
36
36
  :allow_multi_install => [ "kernel" ],
37
- :package_repository => "base"
37
+ :package_repository => "base",
38
+ :disable_extra_repo_control => true
38
39
  )
39
40
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
40
41
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -92,6 +93,7 @@ describe Chef::Provider::Package::Yum do
92
93
  end
93
94
  end
94
95
  @yum_cache.stub!(:package_available?).and_return(true)
96
+ @yum_cache.stub!(:disable_extra_repo_control).and_return(true)
95
97
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
96
98
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
97
99
  @provider.load_current_resource
@@ -125,6 +127,7 @@ describe Chef::Provider::Package::Yum do
125
127
  nil
126
128
  end
127
129
  @yum_cache.stub!(:package_available?).and_return(true)
130
+ @yum_cache.stub!(:disable_extra_repo_control).and_return(true)
128
131
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
129
132
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
130
133
  # annoying side effect of the fun stub'ing above
@@ -155,6 +158,7 @@ describe Chef::Provider::Package::Yum do
155
158
  nil
156
159
  end
157
160
  @yum_cache.stub!(:package_available?).and_return(true)
161
+ @yum_cache.stub!(:disable_extra_repo_control).and_return(true)
158
162
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
159
163
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
160
164
  @provider.load_current_resource
@@ -189,6 +193,7 @@ describe Chef::Provider::Package::Yum do
189
193
  end
190
194
  end.and_return("something")
191
195
  @yum_cache.stub!(:package_available?).and_return(true)
196
+ @yum_cache.stub!(:disable_extra_repo_control).and_return(true)
192
197
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
193
198
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
194
199
  @provider.load_current_resource
@@ -209,6 +214,24 @@ describe Chef::Provider::Package::Yum do
209
214
  @provider.load_current_resource
210
215
  end
211
216
 
217
+ it "should detect --enablerepo or --disablerepo when passed among options, collect them preserving order and notify the yum cache" do
218
+ @new_resource.stub!(:options).and_return("--stuff --enablerepo=foo --otherthings --disablerepo=a,b,c --enablerepo=bar")
219
+ @yum_cache.should_receive(:enable_extra_repo_control).with("--enablerepo=foo --disablerepo=a,b,c --enablerepo=bar")
220
+ @provider.load_current_resource
221
+ end
222
+
223
+ it "should let the yum cache know extra repos are disabled if --enablerepo or --disablerepo aren't among options" do
224
+ @new_resource.stub!(:options).and_return("--stuff --otherthings")
225
+ @yum_cache.should_receive(:disable_extra_repo_control)
226
+ @provider.load_current_resource
227
+ end
228
+
229
+ it "should let the yum cache know extra repos are disabled if options aren't set" do
230
+ @new_resource.stub!(:options).and_return(nil)
231
+ @yum_cache.should_receive(:disable_extra_repo_control)
232
+ @provider.load_current_resource
233
+ end
234
+
212
235
  it "should search provides if package name can't be found then set package_name to match" do
213
236
  @yum_cache = mock(
214
237
  'Chef::Provider::Yum::YumCache',
@@ -217,7 +240,8 @@ describe Chef::Provider::Package::Yum do
217
240
  :installed_version => "1.2.4-11.18.el5",
218
241
  :candidate_version => "1.2.4-11.18.el5",
219
242
  :package_available? => false,
220
- :version_available? => true
243
+ :version_available? => true,
244
+ :disable_extra_repo_control => true
221
245
  )
222
246
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
223
247
  pkg = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "1.2.4-11.18.el5", "x86_64", [])
@@ -235,7 +259,8 @@ describe Chef::Provider::Package::Yum do
235
259
  :installed_version => "1.2.4-11.18.el5",
236
260
  :candidate_version => "1.2.4-11.18.el5",
237
261
  :package_available? => false,
238
- :version_available? => true
262
+ :version_available? => true,
263
+ :disable_extra_repo_control => true
239
264
  )
240
265
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
241
266
  pkg_x = Chef::Provider::Package::Yum::RPMPackage.new("test-package-x", "1.2.4-11.18.el5", "x86_64", [])
@@ -255,7 +280,8 @@ describe Chef::Provider::Package::Yum do
255
280
  :installed_version => "1.2.4-11.18.el5",
256
281
  :candidate_version => "1.2.4-11.18.el5",
257
282
  :package_available? => false,
258
- :version_available? => true
283
+ :version_available? => true,
284
+ :disable_extra_repo_control => true
259
285
  )
260
286
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
261
287
  @yum_cache.should_receive(:packages_from_require).twice.and_return([])
@@ -272,7 +298,8 @@ describe Chef::Provider::Package::Yum do
272
298
  :installed_version => "1.2.4-11.18.el5",
273
299
  :candidate_version => "1.2.4-11.18.el5",
274
300
  :package_available? => false,
275
- :version_available? => true
301
+ :version_available? => true,
302
+ :disable_extra_repo_control => true
276
303
  )
277
304
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
278
305
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -295,7 +322,8 @@ describe Chef::Provider::Package::Yum do
295
322
  :installed_version => "1.2.4-11.18.el5",
296
323
  :candidate_version => "1.2.4-11.18.el5",
297
324
  :package_available? => false,
298
- :version_available? => true
325
+ :version_available? => true,
326
+ :disable_extra_repo_control => true
299
327
  )
300
328
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
301
329
  @yum_cache.should_receive(:packages_from_require).twice.and_return([])
@@ -363,7 +391,8 @@ describe Chef::Provider::Package::Yum do
363
391
  :installed_version => "1.2.4-11.18.el5",
364
392
  :candidate_version => "1.2.4-11.18.el5_2.3",
365
393
  :package_available? => true,
366
- :version_available? => nil
394
+ :version_available? => nil,
395
+ :disable_extra_repo_control => true
367
396
  )
368
397
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
369
398
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -380,7 +409,8 @@ describe Chef::Provider::Package::Yum do
380
409
  :candidate_version => "1.2.4-11.15.el5",
381
410
  :package_available? => true,
382
411
  :version_available? => true,
383
- :allow_multi_install => [ "kernel" ]
412
+ :allow_multi_install => [ "kernel" ],
413
+ :disable_extra_repo_control => true
384
414
  )
385
415
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
386
416
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -398,7 +428,8 @@ describe Chef::Provider::Package::Yum do
398
428
  :package_available? => true,
399
429
  :version_available? => true,
400
430
  :allow_multi_install => [ "cups" ],
401
- :package_repository => "base"
431
+ :package_repository => "base",
432
+ :disable_extra_repo_control => true
402
433
  )
403
434
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
404
435
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -420,7 +451,8 @@ describe Chef::Provider::Package::Yum do
420
451
  :package_available? => true,
421
452
  :version_available? => true,
422
453
  :allow_multi_install => [],
423
- :package_repository => "base"
454
+ :package_repository => "base",
455
+ :disable_extra_repo_control => true
424
456
  )
425
457
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
426
458
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -485,7 +517,8 @@ describe Chef::Provider::Package::Yum do
485
517
  :candidate_version => "1.2.4-11.15.el5",
486
518
  :package_available? => true,
487
519
  :version_available? => true,
488
- :allow_multi_install => [ "kernel" ]
520
+ :allow_multi_install => [ "kernel" ],
521
+ :disable_extra_repo_control => true
489
522
  )
490
523
  Chef::Provider::Package::Yum::YumCache.stub!(:instance).and_return(@yum_cache)
491
524
  @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context)
@@ -1609,6 +1642,12 @@ EOF
1609
1642
  @yc.refresh
1610
1643
  end
1611
1644
 
1645
+ it "should pass extra_repo_control args to yum-dump.py" do
1646
+ @yc.enable_extra_repo_control("--enablerepo=foo --disablerepo=bar")
1647
+ @yc.should_receive(:popen4).with(%r{^/usr/bin/python .*/yum-dump.py --options --installed-provides --enablerepo=foo --disablerepo=bar$}, :waitlast=>true)
1648
+ @yc.refresh
1649
+ end
1650
+
1612
1651
  it "should warn about invalid data with too many separators" do
1613
1652
  @yc.stub!(:popen4).and_yield(@pid, @stdin, @stdout_bad_separators, @stderr).and_return(@status)
1614
1653
  Chef::Log.should_receive(:warn).exactly(3).times.with(%r{Problem parsing})
@@ -1788,4 +1827,33 @@ EOF
1788
1827
  end
1789
1828
  end
1790
1829
 
1830
+ describe "enable_extra_repo_control" do
1831
+ it "should set @extra_repo_control to arg" do
1832
+ @yc.enable_extra_repo_control("--enablerepo=test")
1833
+ @yc.extra_repo_control.should be == "--enablerepo=test"
1834
+ end
1835
+
1836
+ it "should call reload once when set to flag cache for update" do
1837
+ @yc.should_receive(:reload).once
1838
+ @yc.enable_extra_repo_control("--enablerepo=test")
1839
+ @yc.enable_extra_repo_control("--enablerepo=test")
1840
+ end
1841
+ end
1842
+
1843
+ describe "disable_extra_repo_control" do
1844
+ it "should set @extra_repo_control to nil" do
1845
+ @yc.enable_extra_repo_control("--enablerepo=test")
1846
+ @yc.disable_extra_repo_control
1847
+ @yc.extra_repo_control.should be == nil
1848
+ end
1849
+
1850
+ it "should call reload once when cleared to flag cache for update" do
1851
+ @yc.should_receive(:reload).once
1852
+ @yc.enable_extra_repo_control("--enablerepo=test")
1853
+ @yc.should_receive(:reload).once
1854
+ @yc.disable_extra_repo_control
1855
+ @yc.disable_extra_repo_control
1856
+ end
1857
+ end
1858
+
1791
1859
  end
@@ -38,6 +38,15 @@ describe Chef::Resource::Log do
38
38
  it "should allow you to set a log string" do
39
39
  @resource.name.should == @log_str
40
40
  end
41
+
42
+ it "should set the message to the first argument to new" do
43
+ @resource.message.should == @log_str
44
+ end
45
+
46
+ it "should accept a string for the log message" do
47
+ @resource.message "this is different"
48
+ @resource.message.should == "this is different"
49
+ end
41
50
 
42
51
  it "should accept a vaild level option" do
43
52
  @resource.level :debug