Skip to content

Commit

Permalink
Merge branch 'master' into refactor-ask-list
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed May 11, 2021
2 parents 320d073 + 5490d88 commit 9784a9e
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 37 deletions.
9 changes: 8 additions & 1 deletion package/autoyast2.changes
@@ -1,11 +1,18 @@
-------------------------------------------------------------------
Thu May 6 12:42:00 UTC 2021 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>
Tue May 11 08:50:30 UTC 2021 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Refactor the <ask> mechanism (bsc#1185704):
- Split the code into several and testable classes.
- Fix 'Next' dialog calculation when the target does not exist.
- <script> and <default_value_script> support the same elements
than any other script.
- 4.4.4

-------------------------------------------------------------------
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

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

Name: autoyast2
Version: 4.4.3
Version: 4.4.4
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 9784a9e

Please sign in to comment.