Skip to content

Commit

Permalink
Merge pull request #540 from yast/bsc_1188717_sp3
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Oct 12, 2021
2 parents 160c236 + 455f1ae commit d107d9d
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 5 deletions.
8 changes: 8 additions & 0 deletions package/yast2-registration.changes
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Tue Oct 12 08:30:59 UTC 2021 - Ladislav Slezák <lslezak@suse.cz>

- Fixed evaluating the update repositories (bsc#1188717),
the SUSE Manager update repositories were not disabled
when installing the system without updates
- 4.3.24

-------------------------------------------------------------------
Fri Jul 16 07:20:58 UTC 2021 - José Iván López González <jlopez@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-registration.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-registration
Version: 4.3.23
Version: 4.3.24
Release: 0
Summary: YaST2 - Registration Module
License: GPL-2.0-only
Expand Down
21 changes: 17 additions & 4 deletions src/lib/registration/registration_ui.rb
Expand Up @@ -234,7 +234,12 @@ def register_addons(selected_addons, known_reg_codes)
# Or, try registering the paid add-ons with the base product's key:
# eg. use SLES4SAP registration for HA.
selected_addons.replace(try_register_addons(selected_addons, known_reg_codes))
return :next if selected_addons.empty?

if selected_addons.empty?
handle_updates
return :next
end

# cannot be helped by asking for regcodes
return :back if selected_addons.all?(&:free)

Expand Down Expand Up @@ -401,9 +406,6 @@ def register_selected_addon(product, reg_code, silent_reg_code_mismatch:)
registration.register_product(product_data)
end

# select repositories to use in installation (e.g. enable/disable Updates)
select_repositories(product_service) if Yast::Mode.installation || Yast::Mode.update

# remember the added service
Storage::Cache.instance.addon_services << product_service

Expand All @@ -413,6 +415,17 @@ def register_selected_addon(product, reg_code, silent_reg_code_mismatch:)
success
end

# enable/disable update repositories according to the user selection
def handle_updates
# select repositories to use in installation (e.g. enable/disable Updates)
return unless Yast::Mode.installation || Yast::Mode.update

Storage::Cache.instance.addon_services.each do |product_service|
# select repositories to use in installation (e.g. enable/disable Updates)
select_repositories(product_service)
end
end

def select_repositories(product_service)
# added update repositories
updates = SwMgmt.service_repos(product_service, only_updates: true)
Expand Down
1 change: 1 addition & 0 deletions test/inst_scc_test.rb
Expand Up @@ -19,6 +19,7 @@
allow(Y2Packager::MediumType).to receive(:online?).and_return(false)
allow(subject).to receive(:init_registration)
allow(Registration::Addon).to receive(:find_all).and_return([])
allow(Yast::Report).to receive(:Error)
end

context "the system is already registered" do
Expand Down
1 change: 1 addition & 0 deletions test/migration_repos_workflow_spec.rb
Expand Up @@ -20,6 +20,7 @@
allow(Yast::Linuxrc).to receive(:InstallInf)
allow(Y2Packager::MediumType).to receive(:offline?).and_return(false)
allow(Y2Packager::MediumType).to receive(:online?).and_return(false)
allow(Yast::Report).to receive(:Error)
end

shared_examples "media based upgrade" do |popup_method|
Expand Down
4 changes: 4 additions & 0 deletions test/registration/clients/scc_auto_test.rb
Expand Up @@ -16,6 +16,10 @@ def self.current
describe Registration::Clients::SCCAuto do
let(:config) { ::Registration::Storage::Config.instance }

before do
allow(Yast::Report).to receive(:Error)
end

describe "#summary" do
it "returns string with config description" do
expect(subject.summary).to be_a(::String)
Expand Down
2 changes: 2 additions & 0 deletions test/registration/ui/addon_eula_dialog_test.rb
Expand Up @@ -34,6 +34,7 @@
allow(Yast::Wizard).to receive(:SetContents)
allow(dialog).to receive(:find_license).and_return(product_license)
allow(dialog).to receive(:download_eula).and_return(true)
allow(Yast::Report).to receive(:Error)
registered_addon.registered
end

Expand Down Expand Up @@ -162,6 +163,7 @@
.and_return(license_content)
allow(dialog).to receive(:setup_eula_dialog)
allow(dialog).to receive(:run_eula_dialog)
allow(Yast::Report).to receive(:Error)
end

context "when the eula could not be downloaded" do
Expand Down
27 changes: 27 additions & 0 deletions test/registration_ui_test.rb
Expand Up @@ -120,6 +120,33 @@

# stub the registration
allow(registration).to receive(:register_product)
allow(Registration::SwMgmt).to receive(:service_repos).and_return([])
allow(registration_ui).to receive(:handle_updates)
end

it "disables update repositories if requested" do
# unmock the call
allow(registration_ui).to receive(:handle_updates).and_call_original

allow(registration_ui).to receive(:try_register_addons).and_return([])

prod_service = double("Product service")
allow(Registration::Storage::Cache.instance).to receive(:addon_services)
.and_return([prod_service])

update_repo = double("Update repo")
allow(Registration::SwMgmt).to receive(:service_repos)
.with(prod_service, only_updates: true).and_return([update_repo])

# user does not want to install the updates
allow(registration_ui).to receive(:install_updates?).and_return(false)

# make sure the update repo is disabled
expect(Registration::SwMgmt).to receive(:set_repos_state)
.with([update_repo], false)

# Register Legacy module
registration_ui.register_addons([addon_legacy], {})
end

context "when the addons are free" do
Expand Down

0 comments on commit d107d9d

Please sign in to comment.