Skip to content

Commit

Permalink
Added auto client write test.
Browse files Browse the repository at this point in the history
  • Loading branch information
teclator committed May 20, 2020
1 parent 5894766 commit 31d2e0f
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/modules/Lan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ def FromAY(input)

Ops.set(input, "config", "dhcp" => dhcp)
if !Ops.get(input, "strict_IP_check_timeout").nil?
input["strict_ip_check_timeout"] = input.delete("strict_IP_check_timeout")
Ops.set(input, ["config", "config"], "CHECK_DUPLICATE_IP" => true)
end

Expand Down
68 changes: 68 additions & 0 deletions test/y2network/clients/auto_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,37 @@

describe Y2Network::Clients::Auto do
let(:network_autoyast) { Yast::NetworkAutoYast.instance }
let(:eth0) { { "device" => "eth0", "bootproto" => "dhcp", "startmode" => "auto" } }
let(:interfaces) { [eth0] }

let(:dns) { { "hostname" => "host", "dhcp_hostname" => true, "write_hostname" => true } }
let(:routes) do
[
{
"destination" => "default",
"gateway" => "192.168.1.1",
"netmask" => "255.255.255.0",
"device" => "-"
},
{
"destination" => "172.26.0.0/24",
"device" => "eth0"
}
]
end

let(:profile) do
{
"keep_install_network" => false,
"interfaces" => interfaces,
"routing" => {
"ipv4_forward" => true,
"ipv6_forward" => false,
"routes" => routes
},
"dns" => dns
}
end

describe "#reset" do
it "clears Yast::Lan internal state" do
Expand Down Expand Up @@ -123,4 +154,41 @@
expect(subject.modified?).to eql(modified)
end
end

describe "#write" do
let(:system_config) { Y2Network::Config.new(source: :sysconfig) }

before do
allow(Yast::Lan).to receive(:Read)
Y2Network::Config.add(:system, system_config)
allow(Yast::Lan).to receive(:WriteOnly)
subject.import(profile)
end

it "writes the imported network configuration" do
expect(Yast::Lan).to receive(:WriteOnly)

subject.write
end

context "when the imported profile declares a strict ip check timeout" do
let(:profile) do
{
"strict_IP_check_timeout" => 15
}
end

context "and some interfaces is down" do
before do
allow(Yast::Lan).to receive(:isAnyInterfaceDown).and_return(true)
end

it "shows an error popup with the given timeout" do
expect(Yast::Popup).to receive(:TimedError)

subject.write
end
end
end
end
end

0 comments on commit 31d2e0f

Please sign in to comment.