Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package yast2-registration for openSUSE:Factory checked in at 2021-03-08 15:16:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-registration (Old) and /work/SRC/openSUSE:Factory/.yast2-registration.new.2378 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-registration" Mon Mar 8 15:16:08 2021 rev:70 rq:877266 version:4.3.21 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-registration/yast2-registration.changes 2021-02-26 21:58:42.079781293 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-registration.new.2378/yast2-registration.changes 2021-03-08 15:17:53.301966421 +0100 @@ -1,0 +2,7 @@ +Fri Mar 5 13:36:44 UTC 2021 - David Diaz <dgonza...@suse.com> + +- Allow registering system again during firstboot stage + (bsc#1182149). +- 4.3.21 + +------------------------------------------------------------------- Old: ---- yast2-registration-4.3.20.tar.bz2 New: ---- yast2-registration-4.3.21.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-registration.spec ++++++ --- /var/tmp/diff_new_pack.p72LPs/_old 2021-03-08 15:17:53.969966910 +0100 +++ /var/tmp/diff_new_pack.p72LPs/_new 2021-03-08 15:17:53.969966910 +0100 @@ -17,7 +17,7 @@ Name: yast2-registration -Version: 4.3.20 +Version: 4.3.21 Release: 0 Summary: YaST2 - Registration Module License: GPL-2.0-only ++++++ yast2-registration-4.3.20.tar.bz2 -> yast2-registration-4.3.21.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.20/package/yast2-registration.changes new/yast2-registration-4.3.21/package/yast2-registration.changes --- old/yast2-registration-4.3.20/package/yast2-registration.changes 2021-02-19 13:19:31.000000000 +0100 +++ new/yast2-registration-4.3.21/package/yast2-registration.changes 2021-03-05 16:51:56.000000000 +0100 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Fri Mar 5 13:36:44 UTC 2021 - David Diaz <dgonza...@suse.com> + +- Allow registering system again during firstboot stage + (bsc#1182149). +- 4.3.21 + +------------------------------------------------------------------- Mon Feb 15 17:39:06 UTC 2021 - Josef Reidinger <jreidin...@suse.com> - Adapted unit test to recent changes in Yast::Report (related to diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.20/package/yast2-registration.spec new/yast2-registration-4.3.21/package/yast2-registration.spec --- old/yast2-registration-4.3.20/package/yast2-registration.spec 2021-02-19 13:19:31.000000000 +0100 +++ new/yast2-registration-4.3.21/package/yast2-registration.spec 2021-03-05 16:51:56.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-registration -Version: 4.3.20 +Version: 4.3.21 Release: 0 Summary: YaST2 - Registration Module License: GPL-2.0-only diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.20/src/lib/registration/clients/inst_scc.rb new/yast2-registration-4.3.21/src/lib/registration/clients/inst_scc.rb --- old/yast2-registration-4.3.20/src/lib/registration/clients/inst_scc.rb 2021-02-19 13:19:31.000000000 +0100 +++ new/yast2-registration-4.3.21/src/lib/registration/clients/inst_scc.rb 2021-03-05 16:51:56.000000000 +0100 @@ -1,24 +1,22 @@ -# encoding: utf-8 - -# ------------------------------------------------------------------------------ -# Copyright (c) 2013 Novell, Inc. All Rights Reserved. +# Copyright (c) [2013-2020] SUSE LLC # +# All Rights Reserved. # -# 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 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. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, contact Novell, Inc. +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. # -# To contact Novell about this file by physical or electronic mail, you may find -# current contact information at www.novell.com. -# ------------------------------------------------------------------------------ +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. # +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + # Summary: Ask user for the SCC credentials # @@ -230,13 +228,16 @@ return :cancel if init_registration == :cancel extensions_enabled = true + success = Registration::ConnectHelpers.catch_registration_errors do extensions_enabled = !Registration::Addon.find_all(@registration).empty? end + return :abort unless success ::Registration::UI::RegisteredSystemDialog.run( - extensions_enabled: extensions_enabled + extensions: extensions_enabled, + registration: ::Registration::Registration.allowed? ) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.20/src/lib/registration/helpers.rb new/yast2-registration-4.3.21/src/lib/registration/helpers.rb --- old/yast2-registration-4.3.20/src/lib/registration/helpers.rb 2021-02-19 13:19:31.000000000 +0100 +++ new/yast2-registration-4.3.21/src/lib/registration/helpers.rb 2021-03-05 16:51:56.000000000 +0100 @@ -1,25 +1,22 @@ -# encoding: utf-8 - -# ------------------------------------------------------------------------------ -# Copyright (c) 2014 Novell, Inc. All Rights Reserved. +# Copyright (c) [2014-2021] SUSE LLC # +# All Rights Reserved. # -# 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 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. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, contact Novell, Inc. -# -# To contact Novell about this file by physical or electronic mail, you may find -# current contact information at www.novell.com. -# ------------------------------------------------------------------------------ +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. # +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. # +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. +# encoding: utf-8 require "yast" require "erb" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.20/src/lib/registration/registration.rb new/yast2-registration-4.3.21/src/lib/registration/registration.rb --- old/yast2-registration-4.3.20/src/lib/registration/registration.rb 2021-02-19 13:19:31.000000000 +0100 +++ new/yast2-registration-4.3.21/src/lib/registration/registration.rb 2021-03-05 16:51:56.000000000 +0100 @@ -233,6 +233,27 @@ File.exist?(credentials_path) end + # Whether the (re)registration is allowed + # + # The system can be (re)registered only + # + # * when not registered yet, or + # * running in normal mode, or + # * during the firstboot stage + # + # @return [Boolean] true if system is not registered yet; + # true when running in normal mode or firstboot stage; + # false otherwise + def self.allowed? + # Always true if system is not registered yet + return true unless Registration.is_registered? + + # System can be registered again only in normal mode or firstboot stage + return true if Yast::Mode.normal || Yast::Stage.firstboot + + false + end + private def set_registered(remote_product) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.20/src/lib/registration/ui/base_system_registration_dialog.rb new/yast2-registration-4.3.21/src/lib/registration/ui/base_system_registration_dialog.rb --- old/yast2-registration-4.3.20/src/lib/registration/ui/base_system_registration_dialog.rb 2021-02-19 13:19:31.000000000 +0100 +++ new/yast2-registration-4.3.21/src/lib/registration/ui/base_system_registration_dialog.rb 2021-03-05 16:51:56.000000000 +0100 @@ -585,8 +585,8 @@ Yast::UI.ChangeWidget(Id(:action), :Value, action) refresh_next - # disable the input fields when already registered - return disable_widgets if Registration.is_registered? && !Yast::Mode.normal + # Disable the input fields if system cannot be (re)registered + return disable_widgets unless Registration.allowed? WIDGETS.values.flatten.each do |wgt| Yast::UI.ChangeWidget(Id(wgt), :Enabled, WIDGETS[action].include?(wgt)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.20/src/lib/registration/ui/registered_system_dialog.rb new/yast2-registration-4.3.21/src/lib/registration/ui/registered_system_dialog.rb --- old/yast2-registration-4.3.20/src/lib/registration/ui/registered_system_dialog.rb 2021-02-19 13:19:31.000000000 +0100 +++ new/yast2-registration-4.3.21/src/lib/registration/ui/registered_system_dialog.rb 2021-03-05 16:51:56.000000000 +0100 @@ -1,4 +1,3 @@ - require "yast" module Registration @@ -17,46 +16,45 @@ Yast.import "Label" Yast.import "UI" - # displays and run the status dialog for an already registered system + # Displays and run the status dialog for an already registered system + # + # @param extensions [Boolean] Whether "Select extensions" button shoudl be enabled + # @param registration [Boolean] Whether the "Register Again" button should be enabled # - # @param extensions_enabled [Boolean] select extension button enabled # @return [Symbol] user input - def self.run(extensions_enabled: true) - dialog = RegisteredSystemDialog.new - dialog.run(extensions_enabled: extensions_enabled) + def self.run(extensions: true, registration: true) + RegisteredSystemDialog.new(extensions: extensions, registration: registration).run end - # the constructor - def initialize + # Constructor + # + # @param extensions [Boolean] Whether "Select extensions" button shoudl be enabled + # @param registration [Boolean] Whether the "Register Again" button should be enabled + def initialize(extensions: true, registration: true) textdomain "registration" + + @extensions = extensions + @registration = registration end - # display and run the dialog + # Display and run the dialog # - # @param extensions_enabled [Boolean] select extension button enabled # @return [Symbol] user input - def run(extensions_enabled: true) + def run Wizard.SetContents( # dialog title _("Registration"), dialog_content, - # help text - _("<p>The system is already registered.</p>") + - _("<p>You can re-register it again or you can register additional "\ - "extension or modules to enhance the functionality of the system.</p>") + - _("<p>If you want to deregister your system you need to log "\ - "into the SUSE Customer Center and remove the system manually there.</p>"), + help_text, true, true ) - Yast::UI.ChangeWidget(Id(:extensions), :Enabled, extensions_enabled) + Yast::UI.ChangeWidget(Id(:extensions), :Enabled, extensions) + Yast::UI.ChangeWidget(Id(:register), :Enabled, registration) Wizard.SetNextButton(:next, Label.FinishButton) if Mode.normal - continue_buttons = [:next, :back, :cancel, :abort, :register, :extensions] - - ret = nil - ret = Yast::UI.UserInput until continue_buttons.include?(ret) + ret = Yast::UI.UserInput until available_actions.include?(ret) Wizard.RestoreNextButton @@ -65,19 +63,56 @@ private - # the main dialog content + attr_reader :extensions, :registration + + # Available dialog actions + # + # @return [Symbol] + def available_actions + [:next, :back, :cancel, :abort, :register, :extensions] + end + + # The dialog content + # # @return [Yast::Term] UI term def dialog_content VBox( Heading(_("The system is already registered.")), VSpacing(2), - # button label PushButton(Id(:extensions), _("Select Extensions")), VSpacing(1), - # button label PushButton(Id(:register), _("Register Again")) ) end + + # The dialog's help text + # + # @return [String] + def help_text + text = [_("<p>The system is already registered.</p>")] + text << actions_help + text << _("<p>If you want to deregister your system you need to log "\ + "into the SUSE Customer Center and remove the system manually there.</p>") + text.join + end + + # The help text for enabled actions + # + # @return [String] + def actions_help + if extensions && registration + _("<p>You can re-register the system again or register additional "\ + "extension or modules to enhance the functionality of the system.</p>") + elsif extensions + _("<p>You can register additional extension or modules "\ + "to enhance the functionality of the system.</p>") + elsif registration + _("<p>You can re-register it again.</p>") + else + _("<p>At this moment, you can neither re-register it again " \ + "nor register additional extensions</p>") + end + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.20/test/base_system_registration_dialog_test.rb new/yast2-registration-4.3.21/test/base_system_registration_dialog_test.rb --- old/yast2-registration-4.3.20/test/base_system_registration_dialog_test.rb 2021-02-19 13:19:31.000000000 +0100 +++ new/yast2-registration-4.3.21/test/base_system_registration_dialog_test.rb 2021-03-05 16:51:56.000000000 +0100 @@ -30,12 +30,14 @@ describe "#run" do let(:base_product) { Registration::SwMgmt::FAKE_BASE_PRODUCT } let(:mode) { "installation" } + let(:stage) { "initial" } before do textdomain "registration" allow(Registration::SwMgmt).to receive(:find_base_product).and_return(base_product) allow(Yast::Mode).to receive(:mode).and_return(mode) + allow(Yast::Stage).to receive(:stage).and_return(stage) allow(Registration::Registration).to receive(:is_registered?).and_return(registered?) allow(Registration::UrlHelpers).to receive(:slp_discovery_feedback).and_return([]) allow(Yast::UI).to receive(:ChangeWidget) @@ -281,6 +283,16 @@ subject.run end end + + context "during firstboot stage" do + let(:stage) { "firstboot" } + + it "does not disable widgets" do + expect(Yast::UI).to_not receive(:ChangeWidget).with(Id(:action), :Enabled, false) + allow(Yast::UI).to receive(:ChangeWidget).and_call_original + subject.run + end + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.20/test/helpers_spec.rb new/yast2-registration-4.3.21/test/helpers_spec.rb --- old/yast2-registration-4.3.20/test/helpers_spec.rb 2021-02-19 13:19:31.000000000 +0100 +++ new/yast2-registration-4.3.21/test/helpers_spec.rb 2021-03-05 16:51:56.000000000 +0100 @@ -2,7 +2,9 @@ require_relative "spec_helper" -describe "Registration::Helpers" do +describe Registration::Helpers do + subject(:helpers) { described_class } + describe ".service_description" do let(:slp_url) { "https://example.com/registration" } let(:slp_attributes) { double } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.20/test/registration/ui/registered_system_dialog_test.rb new/yast2-registration-4.3.21/test/registration/ui/registered_system_dialog_test.rb --- old/yast2-registration-4.3.20/test/registration/ui/registered_system_dialog_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-registration-4.3.21/test/registration/ui/registered_system_dialog_test.rb 2021-03-05 16:51:56.000000000 +0100 @@ -0,0 +1,161 @@ +#!/usr/bin/env rspec +# Copyright (c) [2021] SUSE LLC +# +# All Rights Reserved. +# +# 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. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require_relative "../../spec_helper" +require "registration/ui/registered_system_dialog" + +describe Registration::UI::RegisteredSystemDialog do + include Yast::UIShortcuts + + subject(:dialog) { described_class.new(extensions: extensions, registration: registration) } + + let(:extensions) { true } + let(:registration) { true } + + describe ".run" do + let(:dialog) { double(Registration::UI::RegisteredSystemDialog, run: true) } + + before do + allow(described_class).to receive(:new).and_return(dialog) + end + + it "creates an instance of the dialog" do + expect(described_class).to receive(:new) + + described_class.run + end + + it "runs the dialog" do + expect(dialog).to receive(:run) + + described_class.run + end + end + + describe "#run" do + let(:mode) { "installation" } + let(:user_input) { :cancel } + + before do + allow(Yast::Wizard).to receive(:SetContents) + allow(Yast::Wizard).to receive(:SetNextButton) + allow(Yast::Wizard).to receive(:RestoreNextButton) + + allow(Yast::Mode).to receive(:mode).and_return(mode) + + allow(Yast::UI).to receive(:ChangeWidget) + allow(Yast::UI).to receive(:UserInput).and_return(user_input) + end + + it "returns the user input" do + expect(subject.run).to eq(:cancel) + end + + it "does not change the next button label" do + expect(Yast::Wizard).to_not receive(:SetNextButton) + end + + it "keeps 'Select Extensions' button enabled" do + expect(Yast::UI).to_not receive(:ChangeWidget).with(Id(:extensions), :Enabled, false) + + subject.run + end + + it "includes help for 'Select Extensions' button" do + expect(Yast::Wizard).to receive(:SetContents).with( + anything, + anything, + /register additional extension/, + any_args + ) + + subject.run + end + + it "keeps 'Register Again' button enabled" do + expect(Yast::UI).to_not receive(:ChangeWidget).with(Id(:register), :Enabled, false) + + subject.run + end + + it "includes help for 'Register Again' button" do + expect(Yast::Wizard).to receive(:SetContents).with( + anything, + anything, + /re-register the system again/, + any_args + ) + + subject.run + end + + context "when running in normal mode" do + let(:mode) { "normal" } + + it "changes the next button label" do + expect(Yast::Wizard).to receive(:SetNextButton) + + subject.run + end + end + + context "when extensions are not enabled" do + let(:extensions) { false } + + it "disables 'Select Extensions' button" do + expect(Yast::UI).to receive(:ChangeWidget).with(Id(:extensions), :Enabled, false) + + subject.run + end + + it "does not include help for it" do + expect(Yast::Wizard).to_not receive(:SetContents).with( + anything, + anything, + /register additional extension/, + any_args + ) + + subject.run + end + end + + context "when register is not enabled" do + let(:registration) { false } + + it "disables 'Register Again' button" do + expect(Yast::UI).to receive(:ChangeWidget).with(Id(:register), :Enabled, false) + + subject.run + end + + it "does not include help for it" do + expect(Yast::Wizard).to_not receive(:SetContents).with( + anything, + anything, + /re-register the system again/, + any_args + ) + + subject.run + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.20/test/registration_spec.rb new/yast2-registration-4.3.21/test/registration_spec.rb --- old/yast2-registration-4.3.20/test/registration_spec.rb 2021-02-19 13:19:31.000000000 +0100 +++ new/yast2-registration-4.3.21/test/registration_spec.rb 2021-03-05 16:51:56.000000000 +0100 @@ -334,4 +334,50 @@ expect(Registration::Registration.is_registered?).to eq(false) end end + + describe ".allowed?" do + let(:mode) { "normal" } + let(:stage) { "initial" } + let(:registered) { false } + + before do + allow(Yast::Mode).to receive(:mode).and_return(mode) + allow(Yast::Stage).to receive(:stage).and_return(stage) + allow(Registration::Registration).to receive(:is_registered?).and_return(registered) + end + + context "when system is not registered yet" do + it "returns true" do + expect(described_class.allowed?).to eq(true) + end + end + + context "when system is already registered" do + let(:registered) { true } + + context "and running in normal mode" do + it "returns true" do + expect(described_class.allowed?).to eq(true) + end + end + + context "and running in firstboot stage" do + let(:mode) { "installation" } + let(:stage) { "firstboot" } + + it "returns true" do + expect(described_class.allowed?).to eq(true) + end + end + + context "but running neither in normal mode nor in firstboot stage" do + let(:mode) { "installation" } + let(:stage) { "initial" } + + it "returns false" do + expect(described_class.allowed?).to eq(false) + end + end + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.20/test/scc_test.rb new/yast2-registration-4.3.21/test/scc_test.rb --- old/yast2-registration-4.3.20/test/scc_test.rb 2021-02-19 13:19:31.000000000 +0100 +++ new/yast2-registration-4.3.21/test/scc_test.rb 2021-03-05 16:51:56.000000000 +0100 @@ -13,11 +13,12 @@ allow(Yast::UI).to receive(:SetFocus) allow(Yast::UI).to receive(:ReplaceWidget) Yast.import "Wizard" - expect(Yast::Wizard).to receive(:CreateDialog) - expect(Yast::Wizard).to receive(:CloseDialog) + allow(Yast::Wizard).to receive(:CreateDialog) + allow(Yast::Wizard).to receive(:CloseDialog) - expect(Registration::SwMgmt).to receive(:init) - expect(Registration::SwMgmt).to receive(:find_base_product).and_return("name" => "SLES") + allow(Registration::SwMgmt).to receive(:init) + allow(Registration::SwMgmt).to receive(:find_base_product).and_return("name" => "SLES") + allow(Registration::Registration).to receive(:is_registered?) end context "the system is already registered" do