test-kitchen 1.4.2 → 1.5.0

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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.travis.yml +29 -33
  4. data/CHANGELOG.md +86 -2
  5. data/CONTRIBUTING.md +17 -0
  6. data/Gemfile.proxy_tests +5 -0
  7. data/MAINTAINERS.md +24 -0
  8. data/features/kitchen_driver_discover_command.feature +6 -0
  9. data/features/kitchen_init_command.feature +55 -7
  10. data/features/step_definitions/gem_steps.rb +12 -4
  11. data/features/step_definitions/git_steps.rb +1 -1
  12. data/features/step_definitions/output_steps.rb +1 -1
  13. data/features/support/env.rb +13 -9
  14. data/lib/kitchen/cli.rb +46 -5
  15. data/lib/kitchen/command/driver_discover.rb +8 -0
  16. data/lib/kitchen/command.rb +1 -0
  17. data/lib/kitchen/config.rb +4 -0
  18. data/lib/kitchen/configurable.rb +32 -0
  19. data/lib/kitchen/driver/ssh_base.rb +18 -4
  20. data/lib/kitchen/generator/driver_create.rb +2 -2
  21. data/lib/kitchen/generator/init.rb +4 -4
  22. data/lib/kitchen/instance.rb +7 -0
  23. data/lib/kitchen/lazy_hash.rb +20 -0
  24. data/lib/kitchen/logger.rb +4 -7
  25. data/lib/kitchen/provisioner/base.rb +16 -1
  26. data/lib/kitchen/provisioner/chef_base.rb +43 -98
  27. data/lib/kitchen/provisioner/chef_solo.rb +7 -4
  28. data/lib/kitchen/provisioner/chef_zero.rb +12 -5
  29. data/lib/kitchen/ssh.rb +1 -1
  30. data/lib/kitchen/transport/base.rb +7 -0
  31. data/lib/kitchen/transport/ssh.rb +13 -6
  32. data/lib/kitchen/transport/winrm.rb +168 -50
  33. data/lib/kitchen/verifier/base.rb +18 -1
  34. data/lib/kitchen/verifier/busser.rb +12 -5
  35. data/lib/kitchen/verifier/shell.rb +101 -0
  36. data/lib/kitchen/version.rb +1 -2
  37. data/spec/kitchen/collection_spec.rb +1 -1
  38. data/spec/kitchen/configurable_spec.rb +211 -2
  39. data/spec/kitchen/driver/ssh_base_spec.rb +131 -8
  40. data/spec/kitchen/lazy_hash_spec.rb +27 -0
  41. data/spec/kitchen/logger_spec.rb +10 -0
  42. data/spec/kitchen/provisioner/base_spec.rb +25 -0
  43. data/spec/kitchen/provisioner/chef_base_spec.rb +133 -252
  44. data/spec/kitchen/provisioner/chef_solo_spec.rb +30 -0
  45. data/spec/kitchen/provisioner/chef_zero_spec.rb +27 -2
  46. data/spec/kitchen/provisioner/shell_spec.rb +60 -12
  47. data/spec/kitchen/ssh_spec.rb +1 -1
  48. data/spec/kitchen/transport/ssh_spec.rb +2 -1
  49. data/spec/kitchen/transport/winrm_spec.rb +228 -48
  50. data/spec/kitchen/verifier/base_spec.rb +26 -0
  51. data/spec/kitchen/verifier/busser_spec.rb +69 -3
  52. data/spec/kitchen/verifier/shell_spec.rb +157 -0
  53. data/support/busser_install_command.sh +1 -2
  54. data/support/chef_base_install_command.ps1 +19 -12
  55. data/templates/driver/README.md.erb +1 -1
  56. data/test-kitchen.gemspec +12 -3
  57. metadata +106 -10
@@ -119,15 +119,27 @@ describe Kitchen::Provisioner::Shell do
119
119
  ])
120
120
  end
121
121
 
122
- it "exports all http proxy variables when both are set" do
122
+ it "exports ftp_proxy & FTP_PROXY when :ftp_proxy is set" do
123
+ config[:ftp_proxy] = "ftp://proxy"
124
+
125
+ cmd.lines.to_a[1..2].must_equal([
126
+ %{ftp_proxy="ftp://proxy"; export ftp_proxy\n},
127
+ %{FTP_PROXY="ftp://proxy"; export FTP_PROXY\n}
128
+ ])
129
+ end
130
+
131
+ it "exports all proxy variables when all are set" do
123
132
  config[:http_proxy] = "http://proxy"
124
133
  config[:https_proxy] = "https://proxy"
134
+ config[:ftp_proxy] = "ftp://proxy"
125
135
 
126
- cmd.lines.to_a[1..4].must_equal([
136
+ cmd.lines.to_a[1..6].must_equal([
127
137
  %{http_proxy="http://proxy"; export http_proxy\n},
128
138
  %{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n},
129
139
  %{https_proxy="https://proxy"; export https_proxy\n},
130
- %{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n}
140
+ %{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n},
141
+ %{ftp_proxy="ftp://proxy"; export ftp_proxy\n},
142
+ %{FTP_PROXY="ftp://proxy"; export FTP_PROXY\n}
131
143
  ])
132
144
  end
133
145
 
@@ -184,15 +196,27 @@ describe Kitchen::Provisioner::Shell do
184
196
  ])
185
197
  end
186
198
 
187
- it "exports all http proxy variables when both are set" do
199
+ it "exports ftp_proxy & FTP_PROXY when :ftp_proxy is set" do
200
+ config[:ftp_proxy] = "ftp://proxy"
201
+
202
+ cmd.lines.to_a[0..1].must_equal([
203
+ %{$env:ftp_proxy = "ftp://proxy"\n},
204
+ %{$env:FTP_PROXY = "ftp://proxy"\n}
205
+ ])
206
+ end
207
+
208
+ it "exports all proxy variables when all are set" do
188
209
  config[:http_proxy] = "http://proxy"
189
210
  config[:https_proxy] = "https://proxy"
211
+ config[:ftp_proxy] = "ftp://proxy"
190
212
 
191
- cmd.lines.to_a[0..3].must_equal([
213
+ cmd.lines.to_a[0..5].must_equal([
192
214
  %{$env:http_proxy = "http://proxy"\n},
193
215
  %{$env:HTTP_PROXY = "http://proxy"\n},
194
216
  %{$env:https_proxy = "https://proxy"\n},
195
- %{$env:HTTPS_PROXY = "https://proxy"\n}
217
+ %{$env:HTTPS_PROXY = "https://proxy"\n},
218
+ %{$env:ftp_proxy = "ftp://proxy"\n},
219
+ %{$env:FTP_PROXY = "ftp://proxy"\n}
196
220
  ])
197
221
  end
198
222
 
@@ -253,15 +277,27 @@ describe Kitchen::Provisioner::Shell do
253
277
  ])
254
278
  end
255
279
 
256
- it "exports all http proxy variables when both are set" do
280
+ it "exports ftp_proxy & FTP_PROXY when :ftp_proxy is set" do
281
+ config[:ftp_proxy] = "ftp://proxy"
282
+
283
+ cmd.lines.to_a[1..2].must_equal([
284
+ %{ftp_proxy="ftp://proxy"; export ftp_proxy\n},
285
+ %{FTP_PROXY="ftp://proxy"; export FTP_PROXY\n}
286
+ ])
287
+ end
288
+
289
+ it "exports all proxy variables when all are set" do
257
290
  config[:http_proxy] = "http://proxy"
258
291
  config[:https_proxy] = "https://proxy"
292
+ config[:ftp_proxy] = "ftp://proxy"
259
293
 
260
- cmd.lines.to_a[1..4].must_equal([
294
+ cmd.lines.to_a[1..6].must_equal([
261
295
  %{http_proxy="http://proxy"; export http_proxy\n},
262
296
  %{HTTP_PROXY="http://proxy"; export HTTP_PROXY\n},
263
297
  %{https_proxy="https://proxy"; export https_proxy\n},
264
- %{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n}
298
+ %{HTTPS_PROXY="https://proxy"; export HTTPS_PROXY\n},
299
+ %{ftp_proxy="ftp://proxy"; export ftp_proxy\n},
300
+ %{FTP_PROXY="ftp://proxy"; export FTP_PROXY\n}
265
301
  ])
266
302
  end
267
303
 
@@ -306,15 +342,27 @@ describe Kitchen::Provisioner::Shell do
306
342
  ])
307
343
  end
308
344
 
309
- it "exports all http proxy variables when both are set" do
345
+ it "exports ftp_proxy & FTP_PROXY when :ftp_proxy is set" do
346
+ config[:ftp_proxy] = "ftp://proxy"
347
+
348
+ cmd.lines.to_a[0..1].must_equal([
349
+ %{$env:ftp_proxy = "ftp://proxy"\n},
350
+ %{$env:FTP_PROXY = "ftp://proxy"\n}
351
+ ])
352
+ end
353
+
354
+ it "exports all proxy variables when all are set" do
310
355
  config[:http_proxy] = "http://proxy"
311
356
  config[:https_proxy] = "https://proxy"
357
+ config[:ftp_proxy] = "ftp://proxy"
312
358
 
313
- cmd.lines.to_a[0..3].must_equal([
359
+ cmd.lines.to_a[0..5].must_equal([
314
360
  %{$env:http_proxy = "http://proxy"\n},
315
361
  %{$env:HTTP_PROXY = "http://proxy"\n},
316
362
  %{$env:https_proxy = "https://proxy"\n},
317
- %{$env:HTTPS_PROXY = "https://proxy"\n}
363
+ %{$env:HTTPS_PROXY = "https://proxy"\n},
364
+ %{$env:ftp_proxy = "ftp://proxy"\n},
365
+ %{$env:FTP_PROXY = "ftp://proxy"\n}
318
366
  ])
319
367
  end
320
368
 
@@ -138,7 +138,7 @@ describe Kitchen::SSH do
138
138
  [
139
139
  Errno::EACCES, Errno::EADDRINUSE, Errno::ECONNREFUSED,
140
140
  Errno::ECONNRESET, Errno::ENETUNREACH, Errno::EHOSTUNREACH,
141
- Net::SSH::Disconnect, Net::SSH::AuthenticationFailed
141
+ Net::SSH::Disconnect, Net::SSH::AuthenticationFailed, Net::SSH::ConnectionTimeout
142
142
  ].each do |klass|
143
143
  describe "raising #{klass}" do
144
144
 
@@ -668,7 +668,8 @@ describe Kitchen::Transport::Ssh::Connection do
668
668
  [
669
669
  Errno::EACCES, Errno::EADDRINUSE, Errno::ECONNREFUSED, Errno::ETIMEDOUT,
670
670
  Errno::ECONNRESET, Errno::ENETUNREACH, Errno::EHOSTUNREACH,
671
- Net::SSH::Disconnect, Net::SSH::AuthenticationFailed, Timeout::Error
671
+ Net::SSH::Disconnect, Net::SSH::AuthenticationFailed, Net::SSH::ConnectionTimeout,
672
+ Timeout::Error
672
673
  ].each do |klass|
673
674
  describe "raising #{klass}" do
674
675
 
@@ -24,8 +24,29 @@ require "winrm/transport/command_executor"
24
24
  require "winrm/transport/shell_closer"
25
25
  require "winrm/transport/file_transporter"
26
26
 
27
+ module Kitchen
28
+
29
+ module Transport
30
+
31
+ class WinRMConnectionDummy < Kitchen::Transport::Winrm::Connection
32
+
33
+ attr_reader :saved_command, :remote_path, :local_path
34
+
35
+ def upload(locals, remote)
36
+ @saved_command = IO.read(locals)
37
+ @local_path = locals
38
+ @remote_path = remote
39
+ end
40
+ end
41
+ end
42
+ end
43
+
27
44
  describe Kitchen::Transport::Winrm do
28
45
 
46
+ before do
47
+ RbConfig::CONFIG.stubs(:[]).with("host_os").returns("blah")
48
+ end
49
+
29
50
  let(:logged_output) { StringIO.new }
30
51
  let(:logger) { Logger.new(logged_output) }
31
52
  let(:config) { Hash.new }
@@ -36,7 +57,11 @@ describe Kitchen::Transport::Winrm do
36
57
  end
37
58
 
38
59
  let(:transport) do
39
- Kitchen::Transport::Winrm.new(config).finalize_config!(instance)
60
+ t = Kitchen::Transport::Winrm.new(config)
61
+ # :load_winrm_s! is not cross-platform safe
62
+ # and gets initialized too early in the pipeline
63
+ t.stubs(:load_winrm_s!)
64
+ t.finalize_config!(instance)
40
65
  end
41
66
 
42
67
  it "provisioner api_version is 1" do
@@ -81,6 +106,10 @@ describe Kitchen::Transport::Winrm do
81
106
  it "sets :max_wait_until_ready to 600 by default" do
82
107
  transport[:max_wait_until_ready].must_equal 600
83
108
  end
109
+
110
+ it "sets :winrm_transport to :plaintext" do
111
+ transport[:winrm_transport].must_equal :plaintext
112
+ end
84
113
  end
85
114
 
86
115
  describe "#connection" do
@@ -148,9 +177,10 @@ describe Kitchen::Transport::Winrm do
148
177
  it "sets :endpoint from data in config" do
149
178
  config[:hostname] = "host_from_config"
150
179
  config[:port] = "port_from_config"
180
+ config[:winrm_transport] = "ssl"
151
181
 
152
182
  klass.expects(:new).with do |hash|
153
- hash[:endpoint] == "http://host_from_config:port_from_config/wsman"
183
+ hash[:endpoint] == "https://host_from_config:port_from_config/wsman"
154
184
  end
155
185
 
156
186
  make_connection
@@ -161,9 +191,10 @@ describe Kitchen::Transport::Winrm do
161
191
  config[:hostname] = "host_from_config"
162
192
  state[:port] = "port_from_state"
163
193
  config[:port] = "port_from_config"
194
+ config[:winrm_transport] = "ssl"
164
195
 
165
196
  klass.expects(:new).with do |hash|
166
- hash[:endpoint] == "http://host_from_state:port_from_state/wsman"
197
+ hash[:endpoint] == "https://host_from_state:port_from_state/wsman"
167
198
  end
168
199
 
169
200
  make_connection
@@ -295,6 +326,55 @@ describe Kitchen::Transport::Winrm do
295
326
  make_connection
296
327
  end
297
328
 
329
+ it "sets :winrm_transport from config data" do
330
+ config[:winrm_transport] = "ssl"
331
+
332
+ klass.expects(:new).with do |hash|
333
+ hash[:winrm_transport] == :ssl
334
+ end
335
+
336
+ make_connection
337
+ end
338
+
339
+ describe "when sspinegotiate is set in config" do
340
+ before do
341
+ config[:winrm_transport] = "sspinegotiate"
342
+ end
343
+
344
+ describe "for Windows workstations" do
345
+ before do
346
+ RbConfig::CONFIG.stubs(:[]).with("host_os").returns("mingw32")
347
+ end
348
+
349
+ it "sets :winrm_transport to sspinegotiate on Windows" do
350
+
351
+ klass.expects(:new).with do |hash|
352
+ hash[:winrm_transport] == :sspinegotiate &&
353
+ hash[:disable_sspi] == false &&
354
+ hash[:basic_auth_only] == false
355
+ end
356
+
357
+ make_connection
358
+ end
359
+ end
360
+
361
+ describe "for non-Windows workstations" do
362
+ before do
363
+ RbConfig::CONFIG.stubs(:[]).with("host_os").returns("darwin14")
364
+ end
365
+
366
+ it "sets :winrm_transport to plaintext" do
367
+ klass.expects(:new).with do |hash|
368
+ hash[:winrm_transport] == :plaintext &&
369
+ hash[:disable_sspi] == true &&
370
+ hash[:basic_auth_only] == true
371
+ end
372
+
373
+ make_connection
374
+ end
375
+ end
376
+ end
377
+
298
378
  it "returns the same connection when called again with same state" do
299
379
  first_connection = make_connection(state)
300
380
  second_connection = make_connection(state)
@@ -358,66 +438,133 @@ describe Kitchen::Transport::Winrm do
358
438
  end
359
439
 
360
440
  describe "#load_needed_dependencies" do
441
+ describe "winrm-transport" do
442
+ before do
443
+ # force loading of winrm-transport to get the version constant
444
+ require "winrm/transport/version"
445
+ end
361
446
 
362
- before do
363
- # force loading of winrm-transport to get the version constant
364
- require "winrm/transport/version"
365
- end
447
+ it "logs a message to debug that code will be loaded" do
448
+ transport.stubs(:require)
449
+ transport
366
450
 
367
- it "logs a message to debug that code will be loaded" do
368
- transport
451
+ logged_output.string.must_match debug_line_with(
452
+ "Winrm Transport requested, loading WinRM::Transport gem")
453
+ end
369
454
 
370
- logged_output.string.must_match debug_line_with(
371
- "Winrm Transport requested, loading WinRM::Transport gem")
372
- end
455
+ it "logs a message to debug when library is initially loaded" do
456
+ transport = Kitchen::Transport::Winrm.new(config)
457
+ transport.stubs(:require)
458
+ transport.stubs(:execute_block).returns(true)
373
459
 
374
- it "logs a message to debug when library is initially loaded" do
375
- transport = Kitchen::Transport::Winrm.new(config)
376
- transport.stubs(:require)
377
- transport.stubs(:require).with("winrm/transport/version").returns(true)
378
- transport.finalize_config!(instance)
460
+ transport.finalize_config!(instance)
379
461
 
380
- logged_output.string.must_match(
381
- %r{^D, .* : WinRM::Transport [^\s]+ library loaded$}
382
- )
383
- end
462
+ logged_output.string.must_match(
463
+ /WinRM::Transport library loaded/
464
+ )
465
+ end
384
466
 
385
- it "logs a message to debug when library is previously loaded" do
386
- transport = Kitchen::Transport::Winrm.new(config)
387
- transport.stubs(:require)
388
- transport.stubs(:require).with("winrm/transport/version").returns(false)
389
- transport.finalize_config!(instance)
467
+ it "logs a message to debug when library is previously loaded" do
468
+ transport = Kitchen::Transport::Winrm.new(config)
469
+ transport.stubs(:require)
470
+ transport.stubs(:execute_block).returns(false)
390
471
 
391
- logged_output.string.must_match(
392
- %r{^D, .* : WinRM::Transport [^\s]+ previously loaded$}
393
- )
472
+ transport.finalize_config!(instance)
473
+
474
+ logged_output.string.must_match(
475
+ /WinRM::Transport previously loaded/
476
+ )
477
+ end
478
+
479
+ it "logs a message to fatal when libraries cannot be loaded" do
480
+ transport = Kitchen::Transport::Winrm.new(config)
481
+ transport.stubs(:require)
482
+ transport.stubs(:execute_block).raises(LoadError, "uh oh")
483
+ begin
484
+ transport.finalize_config!(instance)
485
+ rescue # rubocop:disable Lint/HandleExceptions
486
+ # we are interested in the log output, not this exception
487
+ end
488
+
489
+ logged_output.string.must_match fatal_line_with(
490
+ "The `winrm-transport` gem is missing and must be installed")
491
+ end
492
+
493
+ it "raises a UserError when libraries cannot be loaded" do
494
+ transport = Kitchen::Transport::Winrm.new(config)
495
+ transport.stubs(:require)
496
+ transport.stubs(:execute_block).raises(LoadError, "uh oh")
497
+
498
+ err = proc {
499
+ transport.finalize_config!(instance)
500
+ }.must_raise Kitchen::UserError
501
+ err.message.must_match(/^Could not load or activate winrm-transport\. /)
502
+ end
394
503
  end
395
504
 
396
- it "logs a message to fatal when libraries cannot be loaded" do
397
- transport = Kitchen::Transport::Winrm.new(config)
398
- transport.stubs(:require)
399
- transport.stubs(:require).with("winrm/transport/version").
400
- raises(LoadError, "uh oh")
401
- begin
505
+ describe "winrm-s" do
506
+ before do
507
+ RbConfig::CONFIG.stubs(:[]).with("host_os").returns("mingw32")
508
+ end
509
+
510
+ it "logs a message to debug that code will be loaded" do
511
+ transport = Kitchen::Transport::Winrm.new(config)
512
+ transport.stubs(:load_winrm_transport!)
513
+ transport.stubs(:require)
402
514
  transport.finalize_config!(instance)
403
- rescue # rubocop:disable Lint/HandleExceptions
404
- # we are interested in the log output, not this exception
515
+
516
+ logged_output.string.must_match debug_line_with(
517
+ "The winrm-s gem is being loaded")
405
518
  end
406
519
 
407
- logged_output.string.must_match fatal_line_with(
408
- "The `winrm-transport' gem is missing and must be installed")
409
- end
520
+ it "logs a message to debug when library is initially loaded" do
521
+ transport = Kitchen::Transport::Winrm.new(config)
522
+ transport.stubs(:load_winrm_transport!)
523
+ transport.stubs(:execute_block).returns(true)
410
524
 
411
- it "raises a UserError when libraries cannot be loaded" do
412
- transport = Kitchen::Transport::Winrm.new(config)
413
- transport.stubs(:require)
414
- transport.stubs(:require).with("winrm/transport/version").
415
- raises(LoadError, "uh oh")
525
+ transport.finalize_config!(instance)
526
+
527
+ logged_output.string.must_match(
528
+ /winrm-s is loaded/
529
+ )
530
+ end
531
+
532
+ it "logs a message to debug when library is previously loaded" do
533
+ transport = Kitchen::Transport::Winrm.new(config)
534
+ transport.stubs(:load_winrm_transport!)
535
+ transport.stubs(:execute_block).returns(false)
416
536
 
417
- err = proc {
418
537
  transport.finalize_config!(instance)
419
- }.must_raise Kitchen::UserError
420
- err.message.must_match(/^Could not load or activate WinRM::Transport /)
538
+
539
+ logged_output.string.must_match(
540
+ /winrm-s was already loaded/
541
+ )
542
+ end
543
+
544
+ it "logs a message to fatal when libraries cannot be loaded" do
545
+ transport = Kitchen::Transport::Winrm.new(config)
546
+ transport.stubs(:load_winrm_transport!)
547
+ transport.stubs(:execute_block).raises(LoadError, "uh oh")
548
+ begin
549
+ transport.finalize_config!(instance)
550
+ rescue # rubocop:disable Lint/HandleExceptions
551
+ # we are interested in the log output, not this exception
552
+ end
553
+
554
+ logged_output.string.must_match fatal_line_with(
555
+ "The `winrm-s` gem is missing and must be installed")
556
+ end
557
+
558
+ it "raises a UserError when libraries cannot be loaded" do
559
+ transport = Kitchen::Transport::Winrm.new(config)
560
+ transport.stubs(:load_winrm_transport!)
561
+ transport.stubs(:execute_block).raises(LoadError, "uh oh")
562
+
563
+ err = proc {
564
+ transport.finalize_config!(instance)
565
+ }.must_raise Kitchen::UserError
566
+ err.message.must_match(/^Could not load or activate winrm-s\. /)
567
+ end
421
568
  end
422
569
  end
423
570
 
@@ -576,6 +723,39 @@ describe Kitchen::Transport::Winrm::Connection do
576
723
  end
577
724
  end
578
725
 
726
+ describe "long command" do
727
+ let(:command) { %{Write-Host "#{"a" * 4000}"} }
728
+
729
+ let(:connection) do
730
+ Kitchen::Transport::WinRMConnectionDummy.new(options)
731
+ end
732
+
733
+ let(:response) do
734
+ o = WinRM::Output.new
735
+ o[:exitcode] = 0
736
+ o[:data].concat([
737
+ { :stdout => "ok\r\n" },
738
+ { :stderr => "congrats\r\n" }
739
+ ])
740
+ o
741
+ end
742
+
743
+ before do
744
+ executor.expects(:open).returns("shell-123")
745
+ executor.expects(:run_powershell_script).
746
+ with(%{& "$env:TEMP/kitchen/coolbeans-long_script.ps1"}).
747
+ yields("ok\n", nil).returns(response)
748
+ end
749
+
750
+ it "uploads the long command" do
751
+ with_fake_fs do
752
+ connection.execute(command)
753
+
754
+ connection.saved_command.must_equal command
755
+ end
756
+ end
757
+ end
758
+
579
759
  describe "for a failed command" do
580
760
 
581
761
  let(:response) do
@@ -17,6 +17,7 @@
17
17
  # limitations under the License.
18
18
 
19
19
  require_relative "../../spec_helper"
20
+ require_relative "../ssh_spec"
20
21
 
21
22
  require "logger"
22
23
  require "stringio"
@@ -139,6 +140,10 @@ describe Kitchen::Verifier::Base do
139
140
  it ":http_proxys defaults to nil" do
140
141
  verifier[:https_proxy].must_equal nil
141
142
  end
143
+
144
+ it ":ftp_proxy defaults to nil" do
145
+ verifier[:ftp_proxy].must_equal nil
146
+ end
142
147
  end
143
148
 
144
149
  describe "#call" do
@@ -333,4 +338,25 @@ describe Kitchen::Verifier::Base do
333
338
  end
334
339
  end
335
340
  end
341
+
342
+ describe "#prefix_command" do
343
+
344
+ describe "with :command_prefix set" do
345
+
346
+ before { config[:command_prefix] = "my_prefix" }
347
+
348
+ it "prepends the command with the prefix" do
349
+ verifier.send(:prefix_command, "my_command").must_equal("my_prefix my_command")
350
+ end
351
+ end
352
+
353
+ describe "with :command_prefix unset" do
354
+
355
+ before { config[:command_prefix] = nil }
356
+
357
+ it "returns an unaltered command" do
358
+ verifier.send(:prefix_command, "my_command").must_equal("my_command")
359
+ end
360
+ end
361
+ end
336
362
  end
@@ -101,7 +101,9 @@ describe Kitchen::Verifier::Busser do
101
101
 
102
102
  describe "for unix operating systems" do
103
103
 
104
- before { platform.stubs(:os_type).returns("unix") }
104
+ before {
105
+ platform.stubs(:os_type).returns("unix")
106
+ }
105
107
 
106
108
  it ":ruby_bindir defaults the an Omnibus Chef installation" do
107
109
  verifier[:ruby_bindir].must_equal "/opt/chef/embedded/bin"
@@ -210,6 +212,26 @@ describe Kitchen::Verifier::Busser do
210
212
 
211
213
  describe "with suite test files" do
212
214
 
215
+ describe "common behavior" do
216
+
217
+ before do
218
+ platform.stubs(:shell_type).returns("fake")
219
+ create_test_files
220
+ end
221
+
222
+ it "prefixs the whole command with the command_prefix if set" do
223
+ config[:command_prefix] = "my_prefix"
224
+
225
+ cmd.must_match(/\Amy_prefix /)
226
+ end
227
+
228
+ it "does not prefix the command if command_prefix is not set" do
229
+ config[:command_prefix] = nil
230
+
231
+ cmd.wont_match(/\Amy_prefix /)
232
+ end
233
+ end
234
+
213
235
  describe "for bourne shells" do
214
236
 
215
237
  before do
@@ -237,7 +259,9 @@ describe Kitchen::Verifier::Busser do
237
259
 
238
260
  it "sets gem install arguments" do
239
261
  cmd.must_match regexify(
240
- %{gem_install_args="busser --no-rdoc --no-ri"})
262
+ "gem_install_args=\"busser --no-rdoc --no-ri --no-format-executable" \
263
+ " -n /r/bin --no-user-install\""
264
+ )
241
265
  end
242
266
 
243
267
  it "prepends sudo for busser binstub command when :sudo is set" do
@@ -284,7 +308,9 @@ describe Kitchen::Verifier::Busser do
284
308
 
285
309
  it "sets gem install arguments" do
286
310
  cmd.must_match regexify(
287
- %{$gem_install_args = "busser --no-rdoc --no-ri"})
311
+ "$gem_install_args = \"busser --no-rdoc --no-ri --no-format-executable" \
312
+ " -n \\r\\bin --no-user-install\""
313
+ )
288
314
  end
289
315
 
290
316
  it "sets path to busser binstub command" do
@@ -329,6 +355,26 @@ describe Kitchen::Verifier::Busser do
329
355
 
330
356
  describe "with suite test files" do
331
357
 
358
+ describe "common behavior" do
359
+
360
+ before do
361
+ platform.stubs(:shell_type).returns("fake")
362
+ create_test_files
363
+ end
364
+
365
+ it "prefixs the whole command with the command_prefix if set" do
366
+ config[:command_prefix] = "my_prefix"
367
+
368
+ cmd.must_match(/\Amy_prefix /)
369
+ end
370
+
371
+ it "does not prefix the command if command_prefix is not set" do
372
+ config[:command_prefix] = nil
373
+
374
+ cmd.wont_match(/\Amy_prefix /)
375
+ end
376
+ end
377
+
332
378
  describe "for bourne shells" do
333
379
 
334
380
  before do
@@ -407,6 +453,26 @@ describe Kitchen::Verifier::Busser do
407
453
 
408
454
  describe "with suite test files" do
409
455
 
456
+ describe "common behavior" do
457
+
458
+ before do
459
+ platform.stubs(:shell_type).returns("fake")
460
+ create_test_files
461
+ end
462
+
463
+ it "prefixs the whole command with the command_prefix if set" do
464
+ config[:command_prefix] = "my_prefix"
465
+
466
+ cmd.must_match(/\Amy_prefix /)
467
+ end
468
+
469
+ it "does not prefix the command if command_prefix is not set" do
470
+ config[:command_prefix] = nil
471
+
472
+ cmd.wont_match(/\Amy_prefix /)
473
+ end
474
+ end
475
+
410
476
  describe "for bourne shells" do
411
477
 
412
478
  before do