Hello community,

here is the log from the commit of package yast2-registration for 
openSUSE:Factory checked in at 2018-03-18 21:42:28
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2-registration (Old)
 and      /work/SRC/openSUSE:Factory/.yast2-registration.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2-registration"

Sun Mar 18 21:42:28 2018 rev:14 rq:587963 version:4.0.26

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2-registration/yast2-registration.changes    
2018-03-14 19:34:25.959016261 +0100
+++ 
/work/SRC/openSUSE:Factory/.yast2-registration.new/yast2-registration.changes   
    2018-03-18 21:42:31.118741513 +0100
@@ -1,0 +2,19 @@
+Fri Mar 16 17:17:42 UTC 2018 - [email protected]
+
+- Implemented the registration rollback functionality when going
+  back in the upgrade workflow (bsc#1080979)
+- Properly handle going back also in unregistered systems
+- Refresh the add-on IDs after migrating the registration to show
+  the correct values in the addon and the upgrade overview dialog
+- In the offline migration do not set the solver flags designed for
+  the online migration
+- 4.0.26
+
+-------------------------------------------------------------------
+Fri Mar 16 13:22:35 UTC 2018 - [email protected]
+
+- Just use the first product available from the media When a self
+  update id is defined in the control file (bsc#1084820)
+- 4.0.25
+
+-------------------------------------------------------------------

Old:
----
  yast2-registration-4.0.24.tar.bz2

New:
----
  yast2-registration-4.0.26.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2-registration.spec ++++++
--- /var/tmp/diff_new_pack.tFBoS8/_old  2018-03-18 21:42:32.558689636 +0100
+++ /var/tmp/diff_new_pack.tFBoS8/_new  2018-03-18 21:42:32.570689203 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-registration
-Version:        4.0.24
+Version:        4.0.26
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build

++++++ yast2-registration-4.0.24.tar.bz2 -> yast2-registration-4.0.26.tar.bz2 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.24/package/yast2-registration.changes 
new/yast2-registration-4.0.26/package/yast2-registration.changes
--- old/yast2-registration-4.0.24/package/yast2-registration.changes    
2018-03-13 14:04:41.000000000 +0100
+++ new/yast2-registration-4.0.26/package/yast2-registration.changes    
2018-03-16 19:38:35.000000000 +0100
@@ -1,4 +1,23 @@
 -------------------------------------------------------------------
+Fri Mar 16 17:17:42 UTC 2018 - [email protected]
+
+- Implemented the registration rollback functionality when going
+  back in the upgrade workflow (bsc#1080979)
+- Properly handle going back also in unregistered systems
+- Refresh the add-on IDs after migrating the registration to show
+  the correct values in the addon and the upgrade overview dialog
+- In the offline migration do not set the solver flags designed for
+  the online migration
+- 4.0.26
+
+-------------------------------------------------------------------
+Fri Mar 16 13:22:35 UTC 2018 - [email protected]
+
+- Just use the first product available from the media When a self
+  update id is defined in the control file (bsc#1084820)
+- 4.0.25
+
+-------------------------------------------------------------------
 Tue Mar 13 09:37:14 UTC 2018 - [email protected]
 
 - Prevent crashing when no product was defined in the profile
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.24/package/yast2-registration.spec 
new/yast2-registration-4.0.26/package/yast2-registration.spec
--- old/yast2-registration-4.0.24/package/yast2-registration.spec       
2018-03-13 14:04:41.000000000 +0100
+++ new/yast2-registration-4.0.26/package/yast2-registration.spec       
2018-03-16 19:38:35.000000000 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2-registration
-Version:        4.0.24
+Version:        4.0.26
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.24/src/clients/inst_offline_migration.rb 
new/yast2-registration-4.0.26/src/clients/inst_offline_migration.rb
--- old/yast2-registration-4.0.24/src/clients/inst_offline_migration.rb 
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-registration-4.0.26/src/clients/inst_offline_migration.rb 
2018-03-16 19:38:35.000000000 +0100
@@ -0,0 +1,17 @@
+# 
------------------------------------------------------------------------------
+# Copyright (c) 2015 SUSE LLC
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of version 2 of the GNU General Public License as published by the
+# Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
details.
+#
+# 
------------------------------------------------------------------------------
+#
+
+require "registration/ui/offline_migration_workflow"
+
+Registration::UI::OfflineMigrationWorkflow.new.main
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.24/src/lib/registration/clients/inst_migration_repos.rb
 
new/yast2-registration-4.0.26/src/lib/registration/clients/inst_migration_repos.rb
--- 
old/yast2-registration-4.0.24/src/lib/registration/clients/inst_migration_repos.rb
  2018-03-13 14:04:41.000000000 +0100
+++ 
new/yast2-registration-4.0.26/src/lib/registration/clients/inst_migration_repos.rb
  2018-03-16 19:38:35.000000000 +0100
@@ -32,7 +32,7 @@
         set_target_path
 
         # call the normal client
-        Yast::WFM.call("migration_repos")
+        Yast::WFM.call("migration_repos", [{ "enable_back" => true }])
       end
 
     private
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.24/src/lib/registration/migration_repositories.rb 
new/yast2-registration-4.0.26/src/lib/registration/migration_repositories.rb
--- 
old/yast2-registration-4.0.24/src/lib/registration/migration_repositories.rb    
    2018-03-13 14:04:41.000000000 +0100
+++ 
new/yast2-registration-4.0.26/src/lib/registration/migration_repositories.rb    
    2018-03-16 19:38:35.000000000 +0100
@@ -22,6 +22,7 @@
     include Yast::Logger
 
     Yast.import "Pkg"
+    Yast.import "Stage"
 
     # reset the libzypp migration setup
     def self.reset
@@ -101,6 +102,9 @@
     # set the solver flags for online migration
     # @see https://fate.suse.com/319138
     def set_solver
+      # skip in offline migration
+      return if Yast::Stage.initial
+
       log.info "Setting the solver flags for online migration"
       Yast::Pkg.SetSolverFlags("ignoreAlreadyRecommended" => true,
                                "dupAllowVendorChange"     => false)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.24/src/lib/registration/registration.rb 
new/yast2-registration-4.0.26/src/lib/registration/registration.rb
--- old/yast2-registration-4.0.24/src/lib/registration/registration.rb  
2018-03-13 14:04:41.000000000 +0100
+++ new/yast2-registration-4.0.26/src/lib/registration/registration.rb  
2018-03-16 19:38:35.000000000 +0100
@@ -190,17 +190,9 @@
     # @see SwMgmt.remote_product
     # @see SUSE::Connect::Yast.list_installer_updates
     def get_updates_list
-      product = SwMgmt.base_product_to_register
-      return [] unless product
       id = Yast::ProductFeatures.GetStringFeature("globals", "self_update_id")
-      if !id.empty?
-        log.info "Using self update id from control file #{id.inspect}"
-        # It replaces only name of product. It keeps version and arch of base 
product.
-        # For arch we are sure it is safe. For version it can be issue if 
media contain products
-        # in different versions, but we do not expect it as it share same 
installer and should be
-        # based on same base system and service pack.
-        product["name"] = id
-      end
+      product = SwMgmt.installer_update_base_product(id) || 
SwMgmt.base_product_to_register
+      return [] unless product
 
       log.info "Reading available updates for product: #{product["name"]}"
       remote_product = SwMgmt.remote_product(product)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.24/src/lib/registration/sw_mgmt.rb 
new/yast2-registration-4.0.26/src/lib/registration/sw_mgmt.rb
--- old/yast2-registration-4.0.24/src/lib/registration/sw_mgmt.rb       
2018-03-13 14:04:41.000000000 +0100
+++ new/yast2-registration-4.0.26/src/lib/registration/sw_mgmt.rb       
2018-03-16 19:38:35.000000000 +0100
@@ -116,6 +116,33 @@
       true
     end
 
+    # Prepare a pkg-binding product hash using the first base product available
+    # as a template and with the given self_update_id as the product name.
+    #
+    # With a media containing multiple products it is expected that all the
+    # products use the same version and arch.
+    #
+    # @param self_update_id [String] product name to be used for get the 
installer updates
+    # @return product [Hash,nil] with pkg-binding format; return nil if the
+    # given self_update_id is empty or there is no base product available
+    def self.installer_update_base_product(self_update_id)
+      return if self_update_id.empty?
+      base_product = Y2Packager::Product.available_base_products.first
+      return unless base_product
+
+      # filter out not needed data
+      product_info = {
+        "name"         => self_update_id,
+        "arch"         => base_product.arch,
+        "version"      => base_product.version,
+        "release_type" => nil
+      }
+
+      log.info("Base product for installer update: #{product_info}")
+
+      product_info
+    end
+
     def self.find_base_product
       # FIXME: refactor the code to use Y2Packager::Product
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.24/src/lib/registration/ui/offline_migration_workflow.rb
 
new/yast2-registration-4.0.26/src/lib/registration/ui/offline_migration_workflow.rb
--- 
old/yast2-registration-4.0.24/src/lib/registration/ui/offline_migration_workflow.rb
 1970-01-01 01:00:00.000000000 +0100
+++ 
new/yast2-registration-4.0.26/src/lib/registration/ui/offline_migration_workflow.rb
 2018-03-16 19:38:35.000000000 +0100
@@ -0,0 +1,154 @@
+# 
------------------------------------------------------------------------------
+# Copyright (c) 2018 SUSE LLC
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of version 2 of the GNU General Public License as published by the
+# Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
details.
+#
+# 
------------------------------------------------------------------------------
+#
+
+require "yast"
+require "uri"
+
+module Registration
+  module UI
+    # This class handles offline migration workflow,
+    # it is a wrapper around "migration_repos" client
+    class OfflineMigrationWorkflow
+      include Yast::I18n
+      include Yast::Logger
+
+      Yast.import "GetInstArgs"
+      Yast.import "Packages"
+      Yast.import "Installation"
+      Yast.import "Wizard"
+      Yast.import "Pkg"
+      Yast.import "AddOnProduct"
+
+      # the constructor
+      def initialize
+        textdomain "registration"
+      end
+
+      # The offline migration workflow is:
+      #
+      # - run the client which adds the new migration repositories
+      # - if it returns the :rollback status then run the registration rollback
+      # - return the user input symbol (:next, :back or :abort) to the caller
+      # @return [Symbol] the UI symbol
+      #
+      def main
+        log.info "Starting offline migration sequence"
+
+        # display an empty dialog just to hide the content of the previous step
+        Yast::Wizard.ClearContents
+
+        if Yast::GetInstArgs.going_back
+          going_back
+          return :back
+        end
+
+        # run the main registration migration
+        ui = migration_repos
+
+        rollback if ui == :rollback
+
+        # refresh the add-on records
+        update_addon_records
+
+        # go back in the upgrade workflow after rollback or abort,
+        # maybe the user just selected a wrong partition to upgrade
+        ui = :back if ui == :abort || ui == :rollback
+
+        log.info "Offline migration result: #{ui}"
+        ui
+      end
+
+    private
+
+      def going_back
+        log.info("Going back")
+
+        if Registration.is_registered?
+          log.info("Restoring the previous registration")
+          rollback
+        end
+      end
+
+      def rollback
+        Yast::WFM.CallFunction("registration_sync")
+
+        # remove the copied credentials file from the target system to not be
+        # used again by mistake (skip if accidentally called in a running 
system)
+        if Yast::Stage.initial && 
File.exist?(SUSE::Connect::YaST::GLOBAL_CREDENTIALS_FILE)
+          log.info("Removing 
#{SUSE::Connect::YaST::GLOBAL_CREDENTIALS_FILE}...")
+          File.delete(SUSE::Connect::YaST::GLOBAL_CREDENTIALS_FILE)
+        end
+      end
+
+      def migration_repos
+        Yast::WFM.CallFunction("inst_migration_repos", [{ "enable_back" => 
true }])
+      end
+
+      # update the repository IDs in the AddOnProduct records, the migration
+      # updates the repository setup and the source IDs might not match anymore
+      def update_addon_records
+        Yast::AddOnProduct.add_on_products.each do |addon|
+          next unless addon["media_url"]
+
+          url = URI(addon["media_url"])
+          log.info("Refreshing repository ID for addon #{addon["product"]} 
(#{url})")
+
+          # remove the alias from the URL if it is preset, it is removed by 
Pkg bindings
+          # when adding the repository so it would not match
+          remove_alias(url)
+
+          update_addon(addon, url)
+        end
+      end
+
+      # remove the "alias" query URL parameter from the URL if it is present
+      # @param url [URI] input URL
+      def remove_alias(url)
+        if url.query
+          # params is a list of pairs, "foo=bar" => [["foo, "bar]]
+          params = URI.decode_www_form(url.query)
+          params.reject! { |p| p.first == "alias" }
+          # avoid empty query after "?" in URL
+          url.query = params.empty? ? nil : URI.encode_www_form(params)
+        end
+      end
+
+      # Find the repository ID for the URL and product dir
+      # @param url [URI] repository URL
+      # @param dir [String] product directory
+      # @return [Integer,nil] repository ID
+      def find_repo_id(url, dir)
+        Yast::Pkg.SourceGetCurrent(false).find do |repo|
+          data = Yast::Pkg.SourceGeneralData(repo)
+          # the same URL and product dir
+          URI(data["url"]) == url && data["product_dir"] == dir
+        end
+      end
+
+      # update an addon record
+      # @param addon [Hash] an addon record
+      # @param url [URI] URL of the addon (without "alias")
+      def update_addon(addon, url)
+        new_id = find_repo_id(url, addon["product_dir"])
+
+        if new_id
+          log.info("Updating ID: #{addon["media"]} -> #{new_id}")
+          addon["media"] = new_id
+        else
+          log.warn("Addon not found")
+        end
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.24/test/inst_migration_repos_spec.rb 
new/yast2-registration-4.0.26/test/inst_migration_repos_spec.rb
--- old/yast2-registration-4.0.24/test/inst_migration_repos_spec.rb     
2018-03-13 14:04:41.000000000 +0100
+++ new/yast2-registration-4.0.26/test/inst_migration_repos_spec.rb     
2018-03-16 19:38:35.000000000 +0100
@@ -11,7 +11,7 @@
   end
 
   it "runs the standard \"migration_repos\" client" do
-    expect(Yast::WFM).to receive(:call).with("migration_repos")
+    expect(Yast::WFM).to receive(:call).with("migration_repos", anything)
     subject.main
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.24/test/migration_repositories_spec.rb 
new/yast2-registration-4.0.26/test/migration_repositories_spec.rb
--- old/yast2-registration-4.0.24/test/migration_repositories_spec.rb   
2018-03-13 14:04:41.000000000 +0100
+++ new/yast2-registration-4.0.26/test/migration_repositories_spec.rb   
2018-03-16 19:38:35.000000000 +0100
@@ -14,6 +14,7 @@
 
   describe "#activate_services" do
     before do
+      expect(Yast::Stage).to receive(:initial).and_return(false)
       expect(Yast::Pkg).to 
receive(:SetSolverFlags).with("ignoreAlreadyRecommended" => true,
                                                          
"dupAllowVendorChange"     => false)
       expect(Yast::Pkg).to receive(:PkgSolve)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-registration-4.0.24/test/offline_migration_workflow_test.rb 
new/yast2-registration-4.0.26/test/offline_migration_workflow_test.rb
--- old/yast2-registration-4.0.24/test/offline_migration_workflow_test.rb       
1970-01-01 01:00:00.000000000 +0100
+++ new/yast2-registration-4.0.26/test/offline_migration_workflow_test.rb       
2018-03-16 19:38:35.000000000 +0100
@@ -0,0 +1,130 @@
+#! /usr/bin/env rspec
+
+require_relative "spec_helper"
+
+describe Registration::UI::OfflineMigrationWorkflow do
+  describe "#main" do
+    before do
+      allow(Yast::Wizard).to receive(:ClearContents)
+      allow(Yast::Packages).to receive(:init_called=)
+      allow(Yast::Packages).to receive(:Initialize)
+      allow(Yast::GetInstArgs).to receive(:going_back)
+      allow(File).to receive(:delete)
+      allow(Yast::WFM).to receive(:CallFunction)
+    end
+
+    context "when going back" do
+      before do
+        expect(Yast::GetInstArgs).to receive(:going_back).and_return(true)
+        allow(Registration::Registration).to receive(:is_registered?)
+      end
+
+      it "returns :back" do
+        expect(subject.main).to eq(:back)
+      end
+
+      it "does not run rollback when the system is not registered" do
+        expect(subject).to_not receive(:rollback)
+        subject.main
+      end
+
+      context "the system is registered" do
+        before do
+          expect(Registration::Registration).to 
receive(:is_registered?).and_return(true)
+          allow(Yast::WFM).to receive(:CallFunction).with("registration_sync")
+        end
+
+        it "runs rollback" do
+          expect(Yast::WFM).to receive(:CallFunction).with("registration_sync")
+          subject.main
+        end
+
+        it "removes the copied credentials" do
+          expect(Yast::Stage).to receive(:initial).and_return(true)
+          # allow the other cases
+          allow(File).to receive(:exist?)
+          expect(File).to 
receive(:exist?).with(SUSE::Connect::YaST::GLOBAL_CREDENTIALS_FILE)
+            .and_return(true)
+          expect(File).to 
receive(:delete).with(SUSE::Connect::YaST::GLOBAL_CREDENTIALS_FILE)
+          subject.main
+        end
+      end
+    end
+
+    it "runs the 'inst_migration_repos' client" do
+      expect(Yast::WFM).to receive(:CallFunction).with("inst_migration_repos", 
anything)
+      subject.main
+    end
+
+    it "returns the 'inst_migration_repos' result" do
+      expect(Yast::WFM).to receive(:CallFunction).with("inst_migration_repos", 
anything)
+        .and_return(:foo)
+      expect(subject.main).to eq(:foo)
+    end
+
+    describe "it updates the add-on records" do
+      let(:new_id) { 23 }
+      let(:product_dir) { "" }
+      let(:url) { "dir:///update/000/repo" }
+
+      before do
+        expect(Yast::Pkg).to receive(:SourceGetCurrent).and_return([new_id])
+        expect(Yast::Pkg).to 
receive(:SourceGeneralData).with(new_id).and_return(
+          "url"         => url,
+          "product_dir" => product_dir
+        )
+      end
+
+      it "updates the repository ID" do
+        addons = [
+          {
+            "media_url"   => url,
+            "media"       => 42,
+            "product_dir" => product_dir,
+            "product"     => "Driver Update 0"
+          }
+        ]
+
+        Yast::AddOnProduct.add_on_products = addons
+
+        expect { subject.main }.to change { 
Yast::AddOnProduct.add_on_products.first["media"] }
+          .from(42).to(new_id)
+      end
+
+      it "ignores the alias query in the addon URL" do
+        url2 = "dir:///update/000/repo?alias=DriverUpdate0"
+
+        addons = [
+          {
+            "media_url"   => url2,
+            "media"       => 42,
+            "product_dir" => product_dir,
+            "product"     => "Driver Update 0"
+          }
+        ]
+
+        Yast::AddOnProduct.add_on_products = addons
+
+        expect { subject.main }.to change { 
Yast::AddOnProduct.add_on_products.first["media"] }
+          .from(42).to(new_id)
+      end
+    end
+
+    context "the 'inst_migration_repos' client returns :rollback" do
+      before do
+        expect(Yast::WFM).to 
receive(:CallFunction).with("inst_migration_repos", anything)
+          .and_return(:rollback)
+        allow(Yast::WFM).to receive(:CallFunction).with("registration_sync")
+      end
+
+      it "runs the 'registration_sync' client" do
+        expect(Yast::WFM).to receive(:CallFunction).with("registration_sync")
+        subject.main
+      end
+
+      it "return :back" do
+        expect(subject.main).to eq(:back)
+      end
+    end
+  end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-registration-4.0.24/test/registration_spec.rb 
new/yast2-registration-4.0.26/test/registration_spec.rb
--- old/yast2-registration-4.0.24/test/registration_spec.rb     2018-03-13 
14:04:41.000000000 +0100
+++ new/yast2-registration-4.0.26/test/registration_spec.rb     2018-03-16 
19:38:35.000000000 +0100
@@ -200,7 +200,9 @@
   end
 
   describe "#get_updates_list" do
+    let(:self_update_id) { "SLES" }
     let(:base_product) { { "name" => "base" } }
+    let(:installer_update_base_product) { { "name" => self_update_id } }
     let(:remote_product) { { "name" => "base" } }
     let(:updates) { ["http://updates.suse.com/sles12/";] }
     let(:suse_connect) { double("suse_connect") }
@@ -210,29 +212,37 @@
       stub_const("SUSE::Connect::YaST", suse_connect)
     end
 
-    it "returns updates list from the server for the self update id if 
defined" do
-      expect(Registration::SwMgmt).to receive(:remote_product).with("name" => 
"self_update_id")
-        .and_return("name" => "self_update_id")
-      expect(Yast::ProductFeatures).to receive(:GetStringFeature)
-        .with("globals", "self_update_id")
-        .and_return("self_update_id")
-      expect(suse_connect).to receive(:list_installer_updates)
-        .with({ "name" => "self_update_id" }, anything)
-        .and_return(updates)
-      expect(subject.get_updates_list).to eq(updates)
+    it "returns an empty list if no base product is available or selected" do
+      allow(Registration::SwMgmt).to 
receive(:base_product_to_register).and_return(nil)
+      allow(Registration::SwMgmt).to 
receive(:installer_update_base_product).and_return(nil)
+      expect(subject.get_updates_list).to eq([])
     end
 
-    it "returns updates list from the server for the base product" do
-      expect(Registration::SwMgmt).to 
receive(:remote_product).with(base_product)
-        .and_return(remote_product)
-      expect(suse_connect).to 
receive(:list_installer_updates).with(remote_product, anything)
-        .and_return(updates)
-      expect(subject.get_updates_list).to eq(updates)
+    context "when the control file defines a self_update_id" do
+      it "returns updates list from the server for the self update id" do
+        allow(Yast::ProductFeatures).to receive(:GetStringFeature)
+          .with("globals", "self_update_id").and_return(self_update_id)
+        expect(Registration::SwMgmt).to receive(:installer_update_base_product)
+          .with(self_update_id).and_return(installer_update_base_product)
+        expect(Registration::SwMgmt).to receive(:remote_product)
+          
.with(installer_update_base_product).and_return(installer_update_base_product)
+        expect(suse_connect).to receive(:list_installer_updates)
+          .with(installer_update_base_product, anything)
+          .and_return(updates)
+        expect(subject.get_updates_list).to eq(updates)
+      end
     end
 
-    it "returns an empty list if no base product is selected" do
-      allow(Registration::SwMgmt).to 
receive(:base_product_to_register).and_return(nil)
-      expect(subject.get_updates_list).to eq([])
+    context "when the control file does not define a self_update_id" do
+      it "returns updates list from the server for the base product" do
+        allow(Yast::ProductFeatures).to receive(:GetStringFeature)
+          .with("globals", "self_update_id").and_return("")
+        expect(Registration::SwMgmt).to 
receive(:remote_product).with(base_product)
+          .and_return(remote_product)
+        expect(suse_connect).to 
receive(:list_installer_updates).with(remote_product, anything)
+          .and_return(updates)
+        expect(subject.get_updates_list).to eq(updates)
+      end
     end
   end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-registration-4.0.24/test/sw_mgmt_spec.rb 
new/yast2-registration-4.0.26/test/sw_mgmt_spec.rb
--- old/yast2-registration-4.0.24/test/sw_mgmt_spec.rb  2018-03-13 
14:04:41.000000000 +0100
+++ new/yast2-registration-4.0.26/test/sw_mgmt_spec.rb  2018-03-16 
19:38:35.000000000 +0100
@@ -105,6 +105,44 @@
     end
   end
 
+  describe ".installer_update_base_product" do
+    let(:base_product) do
+      instance_double(Y2Packager::Product, name: "dummy", version: "15.0", 
arch: "x86_64")
+    end
+    let(:available_products) { [base_product] }
+
+    before do
+      allow(Y2Packager::Product).to 
receive(:available_base_products).and_return(available_products)
+    end
+
+    it "returns nil if the given self_update_id is empty" do
+      expect(subject.installer_update_base_product("")).to eq(nil)
+    end
+
+    context "when there is no base product available" do
+      let(:available_products) { [] }
+
+      it "returns nil" do
+        allow(Y2Packager::Product).to 
receive(:available_base_products).and_return([])
+        expect(subject.installer_update_base_product("self_update_id")).to 
eq(nil)
+      end
+    end
+
+    context "when there is some product available" do
+      it "returns a hash with the product keys 'name', 'version', 'arch' and 
'release_type' " do
+        product = subject.installer_update_base_product("self_update_id")
+        expect(product).to be_a(Hash)
+        expect(product.keys.size).to eq(4)
+        expect(product).to include("name", "version", "arch", "release_type")
+      end
+
+      it "uses the given self_update_id as the product name returned" do
+        product = subject.installer_update_base_product("self_update_id")
+        expect(product["name"]).to eq("self_update_id")
+      end
+    end
+  end
+
   describe ".base_product_to_register" do
     it "returns nil if not able to find a product" do
       expect(subject).to receive(:find_base_product).and_return(nil)


Reply via email to