|
9 | 9 | let(:provider){ double("provider", driver: driver) }
|
10 | 10 | let(:driver){ double("driver") }
|
11 | 11 | let(:machine){ double("machine", provider: provider, provider_config: provider_config) }
|
12 |
| - let(:provider_config){ double("provider_config", ip_address_timeout: ip_address_timeout) } |
| 12 | + let(:provider_config){ double("provider_config", ip_address_timeout: ip_address_timeout, ipv4_only: ipv4_only) } |
13 | 13 | let(:ip_address_timeout){ 1 }
|
| 14 | + let(:ipv4_only){ false } |
14 | 15 |
|
15 | 16 | let(:subject){ described_class.new(app, env) }
|
16 | 17 |
|
17 | 18 | before do
|
18 | 19 | allow(driver).to receive(:read_guest_ip).and_return("ip" => "127.0.0.1")
|
19 | 20 | allow(app).to receive(:call)
|
| 21 | + allow(Vagrant::Util::Platform).to receive(:wsl?).and_return(false) |
20 | 22 | end
|
21 | 23 |
|
22 | 24 | it "should call the app on success" do
|
|
35 | 37 | expect(subject).to receive(:sleep)
|
36 | 38 | subject.call(env)
|
37 | 39 | end
|
| 40 | + |
| 41 | + it "should call the app on success with IPv6 address" do |
| 42 | + expect(driver).to receive(:read_guest_ip).and_return("ip" => "FE80:0000:0000:0000:0202:B3FF:FE1E:8329") |
| 43 | + subject.call(env) |
| 44 | + end |
| 45 | + |
| 46 | + context "IPv4_only" do |
| 47 | + let(:ipv4_only){ true } |
| 48 | + |
| 49 | + it "should call the app on success" do |
| 50 | + expect(app).to receive(:call) |
| 51 | + subject.call(env) |
| 52 | + end |
| 53 | + |
| 54 | + it "should set a timeout for waiting for IPv4 address" do |
| 55 | + expect(Timeout).to receive(:timeout).with(ip_address_timeout) |
| 56 | + subject.call(env) |
| 57 | + end |
| 58 | + |
| 59 | + it "should retry until it receives a valid IPv4 address" do |
| 60 | + expect(driver).to receive(:read_guest_ip).and_return("ip" => "FE80:0000:0000:0000:0202:B3FF:FE1E:8329") |
| 61 | + expect(driver).to receive(:read_guest_ip).and_return("ip" => "127.0.0.1") |
| 62 | + expect(subject).to receive(:sleep) |
| 63 | + subject.call(env) |
| 64 | + end |
| 65 | + end |
38 | 66 | end
|
0 commit comments