diff --git a/plugins/providers/docker/action/prepare_networks.rb b/plugins/providers/docker/action/prepare_networks.rb index 21d3607af..4d1904e85 100644 --- a/plugins/providers/docker/action/prepare_networks.rb +++ b/plugins/providers/docker/action/prepare_networks.rb @@ -282,6 +282,7 @@ module VagrantPlugins begin range = IPAddr.new(range) if !subnet.include?(range) + puts "we in here" env[:ui].warn(I18n.t( "docker_provider.network_bridge_iprange_outofbounds", subnet: network_options[:subnet], diff --git a/test/unit/plugins/providers/docker/action/prepare_networks_test.rb b/test/unit/plugins/providers/docker/action/prepare_networks_test.rb index 2b5b0fb4e..1a2ccb7eb 100644 --- a/test/unit/plugins/providers/docker/action/prepare_networks_test.rb +++ b/test/unit/plugins/providers/docker/action/prepare_networks_test.rb @@ -322,5 +322,19 @@ describe VagrantPlugins::DockerProvider::Action::PrepareNetworks do end describe "#request_public_iprange" do + let(:options) { {:ip=>"172.30.130.2", :subnet=>"172.30.0.0/16", :driver=>"bridge", :id=>"30e017d5-488f-5a2f-a3ke-k8dce8246b60"} } + let(:ipaddr) { double("ipaddr", to_s: "172.30.100.2", prefix: 22, succ: "172.30.100.3", + ipv6?: false) } + let(:subnet) { double("ipaddr", to_s: "172.30.130.2", prefix: 22, succ: "172.30.130.3", + ipv6?: false) } + + it "requests a public ip range" do + allow(IPAddr).to receive(:new).with(options[:subnet]).and_return(subnet) + allow(IPAddr).to receive(:new).with("172.30.130.2").and_return(ipaddr) + allow(subnet).to receive(:include?).and_return(true) + allow(machine.ui).to receive(:ask).and_return(options[:ip]) + + addr = subject.request_public_iprange(options, "bridge", env) + end end end