Skip to content

Commit

Permalink
Merge 3bba385 into 57909bc
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Apr 23, 2019
2 parents 57909bc + 3bba385 commit de5e6fa
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 2 deletions.
6 changes: 6 additions & 0 deletions package/yast2-network.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Apr 22 16:41:51 UTC 2019 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Fix mode/second_stage value initialization (bsc#1132057)
- 4.1.45

-------------------------------------------------------------------
Thu Mar 21 10:09:32 UTC 2019 - knut.anderssen@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-network.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-network
Version: 4.1.44
Version: 4.1.45
Release: 0
BuildArch: noarch

Expand Down
3 changes: 2 additions & 1 deletion src/lib/network/network_autoyast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ def configure_submodule(yast_module, ay_config, write: false)
# Return true in order to not call the NetworkAutoconfiguration.configure_hosts
return true unless AutoInstall.valid_imported_values

write ||= !ay_general_section.fetch("mode", "second_stage" => true)["second_stage"]
mode_section = ay_general_section.fetch("mode", {})
write ||= !mode_section.fetch("second_stage", true)
log.info("Write configuration instantly: #{write}")

yast_module.Write(gui: false) if write
Expand Down
74 changes: 74 additions & 0 deletions test/network_autoyast_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
require_relative "test_helper"

require "network/network_autoyast"
Yast.import "Profile"
Yast.import "Lan"

describe "NetworkAutoYast" do
subject(:network_autoyast) { Yast::NetworkAutoYast.instance }
Expand Down Expand Up @@ -510,4 +512,76 @@ def mock_lan_item(renamed_to: nil)
end
end
end

describe "#configure_lan" do
before do
allow(Yast::Profile).to receive(:current)
.and_return("general" => general_section, "networking" => networking_section)
allow(Yast::AutoInstall).to receive(:valid_imported_values).and_return(true)
end

let(:networking_section) { nil }
let(:general_section) { nil }

context "when second stage is disabled" do
let(:general_section) do
{ "mode" => { "second_stage" => false } }
end

it "writes the Lan module configuration" do
expect(Yast::Lan).to receive(:Write)
subject.configure_lan
end
end

context "when writing the configuration is disabled" do
it "writes the Lan module configuration" do
expect(Yast::Lan).to_not receive(:Write)
subject.configure_lan(write: false)
end
end

context "when second stage is enabled" do
let(:general_section) do
{ "mode" => { "second_stage" => true } }
end

it "does not write the Lan module configuration" do
expect(Yast::Lan).to_not receive(:Write)
subject.configure_lan
end
end

context "when second stage is not explicitly enabled" do
let(:general_section) { nil }

it "does not write the Lan module configuration" do
expect(Yast::Lan).to_not receive(:write)
subject.configure_lan
end
end

it "merges the installation configuration" do
expect(Yast::NetworkAutoYast.instance).to receive(:merge_configs)
subject.configure_lan
end

context "when the user wants to keep the installation network" do
let(:networking_section) { { "keep_install_network" => true } }

it "merges the installation configuration" do
expect(Yast::NetworkAutoYast.instance).to receive(:merge_configs)
subject.configure_lan
end
end

context "when the user does not want to keep the installation network" do
let(:networking_section) { { "keep_install_network" => false } }

it "does not merge the installation configuration" do
expect(Yast::NetworkAutoYast.instance).to_not receive(:merge_configs)
subject.configure_lan
end
end
end
end
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def stub_module(name)

# stub classes from other modules to speed up a build
stub_module("AutoInstall")
stub_module("Profile")

# A two level section/key => value store
# to remember values of /etc/sysconfig/network/ifcfg-*
Expand Down

0 comments on commit de5e6fa

Please sign in to comment.