Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for box_download_insecure to be passed to Vagrantfile #208

Merged
merged 2 commits into from
Feb 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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