diff --git a/lib/kitchen/driver/vagrant.rb b/lib/kitchen/driver/vagrant.rb index 3b2fb5bd..17541bfd 100644 --- a/lib/kitchen/driver/vagrant.rb +++ b/lib/kitchen/driver/vagrant.rb @@ -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 diff --git a/spec/kitchen/driver/vagrant_spec.rb b/spec/kitchen/driver/vagrant_spec.rb index cfdb1c29..36b96f32 100644 --- a/spec/kitchen/driver/vagrant_spec.rb +++ b/spec/kitchen/driver/vagrant_spec.rb @@ -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 @@ -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 diff --git a/templates/Vagrantfile.erb b/templates/Vagrantfile.erb index 64f8058c..786c4981 100644 --- a/templates/Vagrantfile.erb +++ b/templates/Vagrantfile.erb @@ -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 %>