Skip nil IP addresses in ipv6 fix

Fixes GH-6558
This commit is contained in:
Seth Vargo 2015-11-23 17:20:02 -05:00
parent e4dad788e1
commit 844cca9013
2 changed files with 35 additions and 1 deletions

View File

@ -27,7 +27,8 @@ module VagrantPlugins
env[:machine].config.vm.networks.each do |type, options|
next if type != :private_network
options = scoped_hash_override(options, :virtualbox)
next if options[:ip] == ""
next if options[:ip].to_s.strip == ""
if IPAddr.new(options[:ip]).ipv6?
has_v6 = true
break

View File

@ -0,0 +1,33 @@
require_relative "../base"
describe VagrantPlugins::ProviderVirtualBox::Action::NetworkFixIPv6 do
include_context "unit"
include_context "virtualbox"
let(:iso_env) do
env = isolated_environment
env.vagrantfile("")
env.create_vagrant_env
end
let(:machine) do
iso_env.machine(iso_env.machine_names[0], :dummy)
end
let(:env) {{ machine: machine }}
let(:app) { lambda { |*args| }}
subject { described_class.new(app, env) }
it "ignores nil IP addresses" do
allow(machine.config.vm).to receive(:networks)
.and_return(private_network: { ip: nil })
expect { subject.call(env) }.to_not raise_error
end
it "blank nil IP addresses" do
allow(machine.config.vm).to receive(:networks)
.and_return(private_network: { ip: "" })
expect { subject.call(env) }.to_not raise_error
end
end