Skip to content

Commit

Permalink
Merge pull request #208 from drrk/add-box_download_insecure-option
Browse files Browse the repository at this point in the history
Add option for box_download_insecure to be passed to Vagrantfile
  • Loading branch information
Seth Thomas committed Feb 19, 2016
2 parents bc29df7 + b85ccf4 commit 8031773
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/kitchen/driver/vagrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class Vagrant < Kitchen::Driver::Base

default_config :box_check_update, nil

default_config :box_download_insecure, nil

default_config(:box_url) { |driver| driver.default_box_url }

default_config :box_version, nil
Expand Down
39 changes: 39 additions & 0 deletions spec/kitchen/driver/vagrant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ def run_command(_cmd, options = {})
expect(driver[:box_check_update]).to eq(true)
end

it "sets :box_download_insecure to nil by default" do
expect(driver[:box_download_insecure]).to eq(nil)
end

it "sets :box_download_insecure to a custom value" do
config[:box_download_insecure] = true

expect(driver[:box_download_insecure]).to eq(true)
end

it "sets :box_version to nil by default" do
expect(driver[:box_version]).to eq(nil)
end
Expand Down Expand Up @@ -967,6 +977,35 @@ def run_command(_cmd, options = {})
expect(vagrantfile).to match(regexify(%{c.vm.box_check_update = "um"}))
end

it "sets no vm.box_download_insecure if missing" do
config[:box_download_insecure] = nil
cmd

expect(vagrantfile).to_not match(
regexify(%{c.vm.box_download_insecure}, :partial)
)
end

it "sets vm.box_download_insecure to false
if :box_download_insecure is false" do

config[:box_download_insecure] = false
cmd

expect(
vagrantfile).to match(regexify(%{c.vm.box_download_insecure = "false"})
)
end

it "sets vm.box_download_insecure if :box_download_insecure is set" do
config[:box_download_insecure] = "um"
cmd

expect(
vagrantfile).to match(regexify(%{c.vm.box_download_insecure = "um"})
)
end

it "sets no vm.communicator if missing" do
config[:communicator] = nil
cmd
Expand Down
4 changes: 4 additions & 0 deletions templates/Vagrantfile.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Vagrant.configure("2") do |c|
c.vm.box_check_update = "<%= config[:box_check_update] %>"
<% end %>

<% if !config[:box_download_insecure].nil? %>
c.vm.box_download_insecure = "<%= config[:box_download_insecure] %>"
<% end %>

<% if config[:vm_hostname] %>
c.vm.hostname = "<%= config[:vm_hostname] %>"
<% end %>
Expand Down

0 comments on commit 8031773

Please sign in to comment.