Skip to content

Commit

Permalink
Merge pull request #757 from yast/merge_SLE-15-SP3
Browse files Browse the repository at this point in the history
Merge SLE-15-SP3 into master
  • Loading branch information
teclator committed May 11, 2021
2 parents 77b3f65 + 59da47c commit 5490d88
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 36 deletions.
7 changes: 7 additions & 0 deletions package/autoyast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri May 7 10:24:22 UTC 2021 - Knut Anderssen <kanderssen@suse.com>

- During autoupgrade do not try to register the system if it is
explicitly disabled in the profile (bsc#1176965)
- 4.4.3

-------------------------------------------------------------------
Thu Apr 8 16:13:44 UTC 2021 - Steffen Winterfeldt <snwint@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/autoyast2.spec
Expand Up @@ -22,7 +22,7 @@
%endif

Name: autoyast2
Version: 4.4.2
Version: 4.4.3
Release: 0
Summary: YaST2 - Automated Installation
License: GPL-2.0-only
Expand Down
11 changes: 9 additions & 2 deletions src/lib/autoinstall/autosetup_helpers.rb
Expand Up @@ -89,8 +89,15 @@ def modified_profile?
def suse_register
return true unless registration_module_available? # do nothing

register_section = Yast::Profile.current.fetch_as_hash(REGISTER_SECTION, nil)
disabled_registration = (register_section || {})["do_registration"] == false

# remove the registration section to not run it again in the 2nd when it is explicitly
# disabled (no autoupgrade detection is needed in this case)
Yast::Profile.remove_sections(REGISTER_SECTION) if disabled_registration

# autoupgrade detects itself if system is registered and if needed do migration via scc
if Yast::Profile.current[REGISTER_SECTION] || Yast::Mode.autoupgrade
if !disabled_registration && (register_section || Yast::Mode.autoupgrade)
Yast::WFM.CallFunction(
"scc_auto",
["Import", Yast::Profile.current[REGISTER_SECTION]]
Expand All @@ -111,7 +118,7 @@ def suse_register
true
end

# Convenienve method to check whether a particular client should be run to
# Convenience method to check whether a particular client should be run to
# be configured manually during the autoinstallation according to the
# semi-automatic section
#
Expand Down
76 changes: 43 additions & 33 deletions test/lib/autosetup_helpers_test.rb
Expand Up @@ -61,8 +61,8 @@ class DummyClient < Yast::Client
allow_any_instance_of(Y2Autoinstallation::AutosetupHelpers).to receive(
:registration_module_available?
).and_return(reg_module_available)
allow(Yast::Profile).to receive(:current).and_return(profile_content)
allow(Yast::Profile).to receive(:remove_sections).with("suse_register")
Yast::Profile.Import(profile_content)
end

context "yast2-register is not available" do
Expand All @@ -86,47 +86,57 @@ class DummyClient < Yast::Client
end

context "suse_register tag is defined in AY file" do
let(:profile_content) do
Yast::ProfileHash.new("suse_register" => { "reg_code" => "12345" })
end
context "and the registration is disabled explicitly" do
let(:profile_content) { { "suse_register" => { "do_registration" => false } } }

before do
allow(Yast::WFM).to receive(:CallFunction).with("inst_download_release_notes")
.and_return(true)
allow(Yast::WFM).to receive(:CallFunction).with("scc_auto", anything).and_return(true)
Yast::Profile.Import(profile_content)
it "does not call any client and returns true." do
# no scc_auto call at all
expect(Yast::WFM).not_to receive(:CallFunction)
expect(client.suse_register).to eq(true)
end
end

it "imports the registration settings from the profile" do
expect(Yast::WFM).to receive(:CallFunction).with("scc_auto",
["Import", profile_content["suse_register"]]).and_return(true)
expect(Yast::WFM).to receive(:CallFunction).with("scc_auto", ["Write"])
.and_return(true)
client.suse_register
end
context "and the registration is not disabled explicitly" do
let(:profile_content) { { "suse_register" => { "reg_code" => "12345" } } }

it "downloads release notes" do
expect(Yast::WFM).to receive(:CallFunction).with("inst_download_release_notes")
client.suse_register
end
before do
allow(Yast::WFM).to receive(:CallFunction).with("inst_download_release_notes")
.and_return(true)
allow(Yast::WFM).to receive(:CallFunction).with("scc_auto", anything).and_return(true)
end

# bsc#1153293
it "removes the registration section to not run it again in the 2nd stage" do
expect(Yast::Profile).to receive(:remove_sections).with("suse_register")
client.suse_register
end
it "imports the registration settings from the profile" do
expect(Yast::WFM).to receive(:CallFunction).with("scc_auto",
["Import", profile_content["suse_register"]]).and_return(true)
expect(Yast::WFM).to receive(:CallFunction).with("scc_auto", ["Write"])
.and_return(true)
client.suse_register
end

it "returns true" do
expect(client.suse_register).to eq(true)
end
it "downloads release notes" do
expect(Yast::WFM).to receive(:CallFunction).with("inst_download_release_notes")
client.suse_register
end

context "when something goes wrong" do
before do
allow(Yast::WFM).to receive(:CallFunction).with("scc_auto", ["Write"]).and_return(false)
# bsc#1153293
it "removes the registration section to not run it again in the 2nd stage" do
expect(Yast::Profile).to receive(:remove_sections).with("suse_register")
client.suse_register
end

it "returns true" do
expect(client.suse_register).to eq(true)
end

it "returns false" do
expect(client.suse_register).to eq(false)
context "when something goes wrong" do
before do
allow(Yast::WFM).to receive(:CallFunction).with("scc_auto", ["Write"])
.and_return(false)
end

it "returns false" do
expect(client.suse_register).to eq(false)
end
end
end
end
Expand Down

0 comments on commit 5490d88

Please sign in to comment.