Skip to content

Commit

Permalink
Remember the added services during upgrade (bsc#1194453)
Browse files Browse the repository at this point in the history
- to not accidentally remove them as old ones
  • Loading branch information
lslezak committed Jan 26, 2022
1 parent 208d564 commit 60f645b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
10 changes: 5 additions & 5 deletions package/yast2-registration.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-registration
Version: 4.4.13
Version: 4.4.14
Release: 0
Summary: YaST2 - Registration Module
License: GPL-2.0-only
Expand All @@ -27,8 +27,8 @@ Url: https://github.com/yast/yast-registration
Source0: %{name}-%{version}.tar.bz2

BuildRequires: update-desktop-files
# ProductSpec API
BuildRequires: yast2 >= 4.4.21
# Y2Packager::NewRepositorySetup
BuildRequires: yast2 >= 4.4.42
BuildRequires: yast2-devtools >= 4.2.2
BuildRequires: yast2-slp >= 3.1.9
BuildRequires: rubygem(%{rb_default_ruby_abi}:rspec)
Expand All @@ -41,8 +41,8 @@ BuildRequires: yast2-update >= 3.1.36
# yast/rspec/helpers.rb
BuildRequires: yast2-ruby-bindings >= 4.4.7

# ProductSpec API
Requires: yast2 >= 4.4.21
# Y2Packager::NewRepositorySetup
Requires: yast2 >= 4.4.42
# "dupAllowVendorChange" option in Pkg.SetSolverFlags()
Requires: yast2-pkg-bindings >= 3.1.34
# N_() method
Expand Down
5 changes: 5 additions & 0 deletions src/lib/registration/registration.rb
Expand Up @@ -21,6 +21,7 @@

require "ostruct"
require "yast"
require "y2packager/new_repository_setup"
require "suse/connect"
require "registration/connect_helpers"

Expand Down Expand Up @@ -71,6 +72,8 @@ def register_product(product, email = nil)

service = SUSE::Connect::YaST.activate_product(product_ident, params, email)
log.info "Register product result: #{service}"
# remember the new service, might be useful later
Y2Packager::NewRepositorySetup.instance.add_service(service.name)
set_registered(product_ident)

renames = collect_renames([service.product])
Expand All @@ -85,6 +88,8 @@ def upgrade_product(product)
log.info "Upgrading product: #{product}"
service = SUSE::Connect::YaST.upgrade_product(product_ident, params)
log.info "Upgrade product result: #{service}"
# remember the new service to not accidentally delete it as an old service
Y2Packager::NewRepositorySetup.instance.add_service(service.name)
# skip loading the remote addons in offline upgrade, there is a confusion
# between installed and the upgraded product, moreover we do not need the
# addons list at all
Expand Down
9 changes: 9 additions & 0 deletions test/registration_spec.rb
Expand Up @@ -68,6 +68,8 @@
allow(SUSE::Connect::YaST).to receive(:credentials)
.with(SUSE::Connect::YaST::GLOBAL_CREDENTIALS_FILE)
.and_return(OpenStruct.new(username: "SCC_foo", password: "bar"))

allow_any_instance_of(Y2Packager::NewRepositorySetup).to receive(:add_service)
end

it "adds the selected product and returns added zypp services" do
Expand All @@ -82,6 +84,13 @@

subject.send(yast_method, product)
end

it "stores the added service name" do
expect_any_instance_of(Y2Packager::NewRepositorySetup).to \
receive(:add_service).with("service")

subject.send(yast_method, product)
end
end

describe "#register_product" do
Expand Down

0 comments on commit 60f645b

Please sign in to comment.