1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
require_relative "../base"
describe VagrantPlugins::ProviderVirtualBox::Driver::Version_6_1 do
include_context "virtualbox"
let(:vbox_version) { "6.1.0" }
subject { VagrantPlugins::ProviderVirtualBox::Driver::Version_6_1.new(uuid) }
it_behaves_like "a version 5.x virtualbox driver"
it_behaves_like "a version 6.x virtualbox driver"
describe "#read_dhcp_servers" do
before {
expect(subprocess).to receive(:execute).
with("VBoxManage", "list", "dhcpservers", an_instance_of(Hash)).
and_return(subprocess_result(stdout: output))
}
context "with empty output" do
let(:output) { "" }
it "returns an empty list" do
expect(subject.read_dhcp_servers).to eq([])
end
end
context "with a single dhcp server" do
let(:output) {
<<-OUTPUT.gsub(/^ */, '')
NetworkName: HostInterfaceNetworking-vboxnet0
Dhcpd IP: 192.168.56.100
LowerIPAddress: 192.168.56.101
UpperIPAddress: 192.168.56.254
NetworkMask: 255.255.255.0
Enabled: Yes
Global Configuration:
minLeaseTime: default
defaultLeaseTime: default
maxLeaseTime: default
Forced options: None
Suppressed opts.: None
1/legacy: 255.255.255.0
Groups: None
Individual Configs: None
OUTPUT
}
it "returns a list with one entry describing that server" do
expect(subject.read_dhcp_servers).to eq([{
network_name: 'HostInterfaceNetworking-vboxnet0',
network: 'vboxnet0',
ip: '192.168.56.100',
netmask: '255.255.255.0',
lower: '192.168.56.101',
upper: '192.168.56.254',
}])
end
end
context "with a multiple dhcp servers" do
let(:output) {
<<-OUTPUT.gsub(/^ */, '')
NetworkName: HostInterfaceNetworking-vboxnet0
Dhcpd IP: 192.168.56.100
LowerIPAddress: 192.168.56.101
UpperIPAddress: 192.168.56.254
NetworkMask: 255.255.255.0
Enabled: Yes
Global Configuration:
minLeaseTime: default
defaultLeaseTime: default
maxLeaseTime: default
Forced options: None
Suppressed opts.: None
1/legacy: 255.255.255.0
Groups: None
Individual Configs: None
NetworkName: HostInterfaceNetworking-vboxnet5
Dhcpd IP: 172.28.128.2
LowerIPAddress: 172.28.128.3
UpperIPAddress: 172.28.128.254
NetworkMask: 255.255.255.0
Enabled: Yes
Global Configuration:
minLeaseTime: default
defaultLeaseTime: default
maxLeaseTime: default
Forced options: None
Suppressed opts.: None
1/legacy: 255.255.255.0
Groups: None
Individual Configs: None
OUTPUT
}
it "returns a list with one entry for each server" do
expect(subject.read_dhcp_servers).to eq([{
network_name: 'HostInterfaceNetworking-vboxnet0',
network: 'vboxnet0',
ip: '192.168.56.100',
netmask: '255.255.255.0',
lower: '192.168.56.101',
upper: '192.168.56.254',
},{
network_name: 'HostInterfaceNetworking-vboxnet5',
network: 'vboxnet5',
ip: '172.28.128.2',
netmask: '255.255.255.0',
lower: '172.28.128.3',
upper: '172.28.128.254',
}])
end
end
end
end
|