Hello community, here is the log from the commit of package yast2-registration for openSUSE:Factory checked in at 2020-07-21 15:46:51 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-registration (Old) and /work/SRC/openSUSE:Factory/.yast2-registration.new.3592 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-registration" Tue Jul 21 15:46:51 2020 rev:56 rq:821772 version:4.3.4 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-registration/yast2-registration.changes 2020-07-15 11:18:44.345223566 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-registration.new.3592/yast2-registration.changes 2020-07-21 15:48:39.328166972 +0200 @@ -1,0 +2,13 @@ +Fri Jul 17 10:54:41 UTC 2020 - Imobach Gonzalez Sosa <[email protected]> + +- Export the registration settings in the <suse_register/> + section when cloning a registered system (bsc#1174202). +- 4.3.4 + +------------------------------------------------------------------- +Wed Jul 15 15:09:50 UTC 2020 - Josef Reidinger <[email protected]> + +- Do not use Profile.current unless necessary (bsc#1174173) +- 4.3.3 + +------------------------------------------------------------------- Old: ---- yast2-registration-4.3.2.tar.bz2 New: ---- yast2-registration-4.3.4.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-registration.spec ++++++ --- /var/tmp/diff_new_pack.6HrCGs/_old 2020-07-21 15:48:40.820168817 +0200 +++ /var/tmp/diff_new_pack.6HrCGs/_new 2020-07-21 15:48:40.824168821 +0200 @@ -17,7 +17,7 @@ Name: yast2-registration -Version: 4.3.2 +Version: 4.3.4 Release: 0 Summary: YaST2 - Registration Module License: GPL-2.0-only @@ -58,6 +58,9 @@ Requires: yast2-packager >= 4.2.27 Requires: yast2-update >= 3.1.36 +# new calls in AutoinstGeneral +Conflicts: autoyast2 < 4.3.23 + BuildArch: noarch # SUSEConnect does not build for i586 and s390 and is not supported on those architectures # bsc#1088552 ++++++ yast2-registration-4.3.2.tar.bz2 -> yast2-registration-4.3.4.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.2/.rubocop.yml new/yast2-registration-4.3.4/.rubocop.yml --- old/yast2-registration-4.3.2/.rubocop.yml 2020-07-13 11:13:04.000000000 +0200 +++ new/yast2-registration-4.3.4/.rubocop.yml 2020-07-19 23:20:54.000000000 +0200 @@ -2,6 +2,12 @@ inherit_from: /usr/share/YaST2/data/devtools/data/rubocop_yast_style.yml +AllCops: + TargetRubyVersion: 2.3 + +Style/FrozenStringLiteralComment: + Enabled: false + # TODO: this need some non-trivial refactoring... Metrics/AbcSize: Max: 111 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.2/package/yast2-registration.changes new/yast2-registration-4.3.4/package/yast2-registration.changes --- old/yast2-registration-4.3.2/package/yast2-registration.changes 2020-07-13 11:13:04.000000000 +0200 +++ new/yast2-registration-4.3.4/package/yast2-registration.changes 2020-07-19 23:20:54.000000000 +0200 @@ -1,4 +1,17 @@ ------------------------------------------------------------------- +Fri Jul 17 10:54:41 UTC 2020 - Imobach Gonzalez Sosa <[email protected]> + +- Export the registration settings in the <suse_register/> + section when cloning a registered system (bsc#1174202). +- 4.3.4 + +------------------------------------------------------------------- +Wed Jul 15 15:09:50 UTC 2020 - Josef Reidinger <[email protected]> + +- Do not use Profile.current unless necessary (bsc#1174173) +- 4.3.3 + +------------------------------------------------------------------- Thu Jul 9 10:31:17 CEST 2020 - [email protected] - Evaluating addon-list: Uses version without release for diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.2/package/yast2-registration.spec new/yast2-registration-4.3.4/package/yast2-registration.spec --- old/yast2-registration-4.3.2/package/yast2-registration.spec 2020-07-13 11:13:04.000000000 +0200 +++ new/yast2-registration-4.3.4/package/yast2-registration.spec 2020-07-19 23:20:54.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-registration -Version: 4.3.2 +Version: 4.3.4 Release: 0 Summary: YaST2 - Registration Module License: GPL-2.0-only @@ -58,6 +58,9 @@ Requires: yast2-packager >= 4.2.27 Requires: yast2-update >= 3.1.36 +# new calls in AutoinstGeneral +Conflicts: autoyast2 < 4.3.23 + BuildArch: noarch # SUSEConnect does not build for i586 and s390 and is not supported on those architectures # bsc#1088552 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.2/src/desktop/org.opensuse.yast.SCC.desktop new/yast2-registration-4.3.4/src/desktop/org.opensuse.yast.SCC.desktop --- old/yast2-registration-4.3.2/src/desktop/org.opensuse.yast.SCC.desktop 2020-07-13 11:13:04.000000000 +0200 +++ new/yast2-registration-4.3.4/src/desktop/org.opensuse.yast.SCC.desktop 2020-07-19 23:20:54.000000000 +0200 @@ -7,7 +7,7 @@ X-SuSE-YaST-RootOnly=false X-SuSE-YaST-Group=Software X-SuSE-YaST-AutoInst=all -X-SuSE-YaST-AutoInstClonable=false +X-SuSE-YaST-AutoInstClonable=true X-SuSE-YaST-AutoInstRequires=lan,proxy X-SuSE-YaST-AutoInstSchema=registration.rnc X-SuSE-YaST-AutoInstResource=suse_register diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.2/src/lib/registration/clients/scc_auto.rb new/yast2-registration-4.3.4/src/lib/registration/clients/scc_auto.rb --- old/yast2-registration-4.3.2/src/lib/registration/clients/scc_auto.rb 2020-07-13 11:13:04.000000000 +0200 +++ new/yast2-registration-4.3.4/src/lib/registration/clients/scc_auto.rb 2020-07-19 23:20:54.000000000 +0200 @@ -47,7 +47,6 @@ Yast.import "Label" Yast.import "Report" Yast.import "Popup" -Yast.import "Profile" Yast.import "Packages" Yast.import "Report" Yast.import "Installation" @@ -90,6 +89,7 @@ # if there is no registration section like can happen during auto upgrade return unless settings + # Lazy load it as registration does not depend on ay, but scc_auto is run only in ay context Yast.import "AutoinstFunctions" # merge reg code if not defined in the profile but @@ -147,8 +147,8 @@ end def read - log.error "Cloning is not supported by this YaST module" - false + @config.read + true end # return extra packages needed by this module (none so far) @@ -198,7 +198,17 @@ Yast::Packages.ImportGPGKeys products = Y2Packager::ProductControlProduct.products - ay_product = Yast::Profile.current.fetch("software", {}).fetch("products", []).first + + # Lazy load it as registration does not depend on ay, but scc_auto is run only in ay context + Yast.import "AutoinstFunctions" + + selected_product = Yast::AutoinstFunctions.selected_product + log.info "selected product #{selected_product.inspect}" + ay_product = if selected_product.respond_to?(:name) + selected_product.name + else + selected_product.details.product + end if !ay_product # TRANSLATORS: error message, %s is the XML path, e.g. "software/products" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.2/src/lib/registration/storage/config.rb new/yast2-registration-4.3.4/src/lib/registration/storage/config.rb --- old/yast2-registration-4.3.2/src/lib/registration/storage/config.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-registration-4.3.4/src/lib/registration/storage/config.rb 2020-07-19 23:20:54.000000000 +0200 @@ -0,0 +1,210 @@ +# Copyright (c) [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 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 "suse/connect" +require "registration/registration" + +module Registration + module Storage + # AutoYast configuration + # + # @example Import AutoYaST settings + # config = Registration::Storage::Config.instance + # config.import("do_registration" => true, reg_server" => "https://scc.example.net") + # config.do_registration #=> true + # + # @example Read configuration from the running system + # config = Registration::Storage::Config.instance + # config.read + # config.reg_server #=> "https://scc.example.net" + # config.modified? #=> true + class Config + include Singleton + + attr_accessor :modified, :do_registration, :reg_server, :reg_server_cert, :email, + :reg_code, :install_updates, :addons, :slp_discovery, + :reg_server_cert_fingerprint_type, :reg_server_cert_fingerprint + + def initialize + reset + end + + # Resets the current instance + def reset + @modified = false + @do_registration = false + @reg_server = "" + @reg_server_cert = "" + @email = "" + @reg_code = "" + @install_updates = false + @addons = [] + @slp_discovery = false + @reg_server_cert_fingerprint_type = nil + @reg_server_cert_fingerprint = "" + @connect_status = nil + end + + # Export AutoYaST settings + # + # @return [Hash<String,Object>] A hash representing AutoYaST settings + def export + ret = { "do_registration" => do_registration } + # export only the boolean flag when registration is disabled, + # all other config values are useless in that case + return ret unless do_registration + + ret.merge!( + "reg_server" => reg_server, + "slp_discovery" => slp_discovery, + "email" => email, + "reg_code" => reg_code, + "install_updates" => install_updates + ) + + ret["addons"] = export_addons + ret.merge!(export_ssl_config) + + ret + end + + # Imports AutoYaST settings + # + # @param settings [Hash<String,Object>] Settings + # @option settings [Boolean] "do_registration" Whether to register the system + # @option settings [String] "reg_server" URL of the registration server + # @option settings [Boolean] "slp_discovery" Whether to use SLP to find out the reg_server + # @option settings [String] "email" E-mail address related to the registration code + # @option settings [String] "reg_code" Registration code + # @option settings [String] "reg_server_cert" URL of the registration server certificate + # @option settings [String] "reg_server_cert_fingerprint_type" Certificate fingerprint type + # (e.g., "SHA1" or "SHA256") + # @option settings [String] "reg_server_cert_fingerprint" Fingerprint of the registration + # server certificate + # @option settings [Boolean] "install_updates" Whether to install package updates + # @option settings [Array<Hash<String,String>>] "addons" List of add-ons to register. + # Each entry contains "name", "version" and "arch" keys. + def import(settings) + reset + + @do_registration = settings.fetch("do_registration", false) + @reg_server = settings["reg_server"] || "" + @slp_discovery = settings.fetch("slp_discovery", false) + @reg_server_cert = settings["reg_server_cert"] || "" + @email = settings["email"] || "" + @reg_code = settings["reg_code"] || "" + @install_updates = settings.fetch("install_updates", false) + @addons = import_addons(settings) + @reg_server_cert_fingerprint_type = settings["reg_server_cert_fingerprint_type"] || "" + @reg_server_cert_fingerprint = settings["reg_server_cert_fingerprint"] || "" + end + + # Reads configuration settings from the running system + # + # If the system is not registered, it does nothing + def read + return unless ::Registration::Registration.is_registered? + config = SUSE::Connect::Config.new + @email = config.email + @reg_server = config.url + @reg_code = base_regcode + @addons = addons_from_system + @modified = true + @do_registration = true + end + + private + + def import_addons(settings) + (settings["addons"] || []).map do |a| + import_addon = a.dup + # handle "nil" release_type, nil cannot be stored in XML profile + import_addon["release_type"] = nil if a["release_type"] == "nil" + import_addon + end + end + + def export_addons + addons.map do |a| + addon_export = a.dup + # handle nil release_type at export, nil cannot be stored in XML profile + addon_export["release_type"] = "nil" if addon_export["release_type"].nil? + addon_export + end + end + + def export_ssl_config + ret = { "reg_server_cert" => reg_server_cert } + + if reg_server_cert_fingerprint_type && !reg_server_cert_fingerprint_type.empty? + ret["reg_server_cert_fingerprint_type"] = reg_server_cert_fingerprint_type + ret["reg_server_cert_fingerprint"] = reg_server_cert_fingerprint + end + + ret.reject { |_k, v| v.empty? } + end + + # Returns the registration code for the base system + # + # @return [String,nil] + def base_regcode + base_activation = connect_status.activations.find do |activation| + activation.service&.product&.isbase + end + base_activation && base_activation.regcode + end + + # Returns the elements for the <addons> section + # + # @return [Array<Hash>] + def addons_from_system + connect_status.activations.each_with_object([]) do |activation, all| + addon_data = addon_data_from_activation(activation) + all << addon_data if addon_data + end + end + + # Returns the addon data from an activation + # + # @param activation [SUSE::Connect::Remote::Activation] Add-on activation + # @return [Hash,nil] Add-on information to be exported in the profile or + # nil if no add-on was related to the given activation + def addon_data_from_activation(activation) + addon = activation&.service&.product + return if addon.nil? || addon.isbase + + addon_data = { + "name" => addon.identifier, + "version" => addon.version, + "arch" => addon.arch, + "release_type" => addon.release_type + } + addon_data["reg_code"] = activation.regcode if activation.regcode + addon_data + end + + # SUSE/Connect status information + # + # @return [SUSE::Connect::Status] Status information from SCC + def connect_status + @connect_status ||= SUSE::Connect::YaST.status({}) + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.2/src/lib/registration/storage.rb new/yast2-registration-4.3.4/src/lib/registration/storage.rb --- old/yast2-registration-4.3.2/src/lib/registration/storage.rb 2020-07-13 11:13:04.000000000 +0200 +++ new/yast2-registration-4.3.4/src/lib/registration/storage.rb 2020-07-19 23:20:54.000000000 +0200 @@ -25,6 +25,7 @@ require "singleton" require "registration/registration_codes_loader" require "yast" +require "registration/storage/config" Yast.import "Stage" module Registration @@ -83,98 +84,5 @@ self.ssl_failed_cert = nil end end - - # AutoYast configuration - class Config - include Singleton - - attr_accessor :modified, :do_registration, :reg_server, :reg_server_cert, :email, - :reg_code, :install_updates, :addons, :slp_discovery, - :reg_server_cert_fingerprint_type, :reg_server_cert_fingerprint - - def initialize - reset - end - - def reset - @modified = false - @do_registration = false - @reg_server = "" - @reg_server_cert = "" - @email = "" - @reg_code = "" - @install_updates = false - @addons = [] - @slp_discovery = false - @reg_server_cert_fingerprint_type = nil - @reg_server_cert_fingerprint = "" - end - - def export - ret = { "do_registration" => do_registration } - # export only the boolean flag when registration is disabled, - # all other config values are useless in that case - return ret unless do_registration - - ret.merge!( - "reg_server" => reg_server, - "slp_discovery" => slp_discovery, - "email" => email, - "reg_code" => reg_code, - "install_updates" => install_updates - ) - - ret["addons"] = export_addons - ret.merge!(export_ssl_config) - - ret - end - - def import(settings) - reset - - @do_registration = settings.fetch("do_registration", false) - @reg_server = settings["reg_server"] || "" - @slp_discovery = settings.fetch("slp_discovery", false) - @reg_server_cert = settings["reg_server_cert"] || "" - @email = settings["email"] || "" - @reg_code = settings["reg_code"] || "" - @install_updates = settings.fetch("install_updates", false) - @addons = import_addons(settings) - @reg_server_cert_fingerprint_type = settings["reg_server_cert_fingerprint_type"] || "" - @reg_server_cert_fingerprint = settings["reg_server_cert_fingerprint"] || "" - end - - private - - def import_addons(settings) - (settings["addons"] || []).map do |a| - import_addon = a.dup - # handle "nil" release_type, nil cannot be stored in XML profile - import_addon["release_type"] = nil if a["release_type"] == "nil" - import_addon - end - end - - def export_addons - addons.map do |a| - addon_export = a.dup - # handle nil release_type at export, nil cannot be stored in XML profile - addon_export["release_type"] = "nil" if addon_export["release_type"].nil? - addon_export - end - end - - def export_ssl_config - ret = { "reg_server_cert" => reg_server_cert } - - if reg_server_cert_fingerprint_type && !reg_server_cert_fingerprint_type.empty? - ret["reg_server_cert_fingerprint_type"] = reg_server_cert_fingerprint_type - ret["reg_server_cert_fingerprint"] = reg_server_cert_fingerprint - end - - ret - end - end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.2/test/registration/clients/scc_auto_test.rb new/yast2-registration-4.3.4/test/registration/clients/scc_auto_test.rb --- old/yast2-registration-4.3.2/test/registration/clients/scc_auto_test.rb 2020-07-13 11:13:04.000000000 +0200 +++ new/yast2-registration-4.3.4/test/registration/clients/scc_auto_test.rb 2020-07-19 23:20:54.000000000 +0200 @@ -51,8 +51,9 @@ end describe "#read" do - it "returns false" do - expect(subject.read).to eq false + it "returns true" do + expect(config).to receive(:read) + expect(subject.read).to eq true end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.2/test/registration/storage/config_test.rb new/yast2-registration-4.3.4/test/registration/storage/config_test.rb --- old/yast2-registration-4.3.2/test/registration/storage/config_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-registration-4.3.4/test/registration/storage/config_test.rb 2020-07-19 23:20:54.000000000 +0200 @@ -0,0 +1,196 @@ +# Copyright (c) [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 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" + +describe Registration::Storage::Config do + subject { Registration::Storage::Config.instance } + let(:addon) do + { + "arch" => "x86_64", + "name" => "sle-module-legacy", + "reg_code" => "", + "release_type" => "nil", + "version" => "12" + } + end + let(:config) do + { + "addons" => [{ + "arch" => "x86_64", "name" => "sle-module-legacy", "reg_code" => "", + "release_type" => "nil", "version" => "12" + }], + "do_registration" => true, + "email" => "[email protected]", + "install_updates" => false, + "reg_code" => "FOOBAR42", + "reg_server" => "", + "reg_server_cert" => "", + "reg_server_cert_fingerprint" => "AB:CD:EF", + "reg_server_cert_fingerprint_type" => "SHA1", + "slp_discovery" => false + } + end + + before do + # start each test with empty config + subject.reset + end + + describe "#reset" do + it "resets the current configuration" do + subject.do_registration = true + subject.reset + expect(subject.do_registration).to eq(false) + end + end + + describe "#export" do + it "exports only 'do_registration' key when registration is disabled" do + subject.do_registration = false + expect(subject.export).to eq("do_registration" => false) + end + + it "exports complete data as a Hash when registration is enabled" do + subject.do_registration = true + subject.reg_server_cert_fingerprint_type = "SHA1" + subject.reg_server_cert_fingerprint = "AB:CD:EF" + subject.addons << addon + subject.email = "[email protected]" + subject.reg_code = "FOOBAR42" + + expect(subject.export).to include( + "do_registration" => true, + "email" => "[email protected]", + "reg_code" => "FOOBAR42" + ) + end + end + + describe "#import" do + it "resets the configuration before importing the data" do + subject.reg_server = "http://example.com" + subject.import({}) + expect(subject.reg_server).to eq("") + end + + it "imports the data from a Hash" do + subject.import(config) + expect(subject.do_registration).to eq(true) + expect(subject.reg_server).to eq("") + expect(subject.email).to eq("[email protected]") + expect(subject.reg_code).to eq("FOOBAR42") + expect(subject.addons.size).to eq 1 + end + end + + describe "#read" do + before do + subject.reset + allow(::Registration::Registration).to receive(:is_registered?).and_return(registered) + end + + let(:registered) { true } + + let(:activations) do + [basesystem_activation, sles_activation, workstation_activation] + end + + let(:config) do + SUSE::Connect::Config.new(fixtures_file("SUSEConnect")) + end + + let(:status) do + instance_double( + SUSE::Connect::Status, + activations: activations, + activated_products: [sles_product, basesystem_product, workstation_product] + ) + end + + let(:sles_activation) do + SUSE::Connect::Remote::Activation.new( + "regcode" => "0123456789", + "service" => { + "product" => { + "name" => "SUSE Linux Enteprise Server", "identifier" => "SLES", "isbase" => true + } + } + ) + end + + let(:basesystem_activation) do + SUSE::Connect::Remote::Activation.new( + "service" => { + "product" => { + "name" => "Basesystem Module", "identifier" => "sle-basesystem" + } + } + ) + end + + let(:workstation_activation) do + SUSE::Connect::Remote::Activation.new( + "regcode" => "ABCDEFGHIJ", + "service" => { + "product" => { + "name" => "Workstation Extension", "identifier" => "sle-we" + } + } + ) + end + + let(:sles_product) { sles_activation.service.product } + let(:basesystem_product) { basesystem_activation.service.product } + let(:workstation_product) { workstation_activation.service.product } + + before do + allow(SUSE::Connect::Status).to receive(:new).and_return(status) + allow(SUSE::Connect::Config).to receive(:new).and_return(config) + end + + it "reads the registration information" do + subject.read + expect(subject.reg_server).to eq(config.url) + expect(subject.email).to eq(config.email) + end + + it "includes the addons but not the base product" do + subject.read + expect(subject.addons).to contain_exactly( + a_hash_including("name" => "sle-basesystem"), + a_hash_including("name" => "sle-we", "reg_code" => "ABCDEFGHIJ") + ) + end + + it "sets the configuration as modified" do + expect { subject.read }.to change { subject.modified }.from(false).to(true) + end + + context "when the system is not registered" do + let(:registered) { false } + + it "does not read the registration information" do + subject.read + expect(subject.reg_server).to be_empty + expect(subject.email).to be_empty + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-registration-4.3.2/test/storage_spec.rb new/yast2-registration-4.3.4/test/storage_spec.rb --- old/yast2-registration-4.3.2/test/storage_spec.rb 2020-07-13 11:13:04.000000000 +0200 +++ new/yast2-registration-4.3.4/test/storage_spec.rb 2020-07-19 23:20:54.000000000 +0200 @@ -2,89 +2,6 @@ require_relative "spec_helper" -describe Registration::Storage::Config do - subject { Registration::Storage::Config.instance } - let(:addon) do - { - "arch" => "x86_64", - "name" => "sle-module-legacy", - "reg_code" => "", - "release_type" => "nil", - "version" => "12" - } - end - let(:config) do - { - "addons" => [{ - "arch" => "x86_64", "name" => "sle-module-legacy", "reg_code" => "", - "release_type" => "nil", "version" => "12" - }], - "do_registration" => true, - "email" => "[email protected]", - "install_updates" => false, - "reg_code" => "FOOBAR42", - "reg_server" => "", - "reg_server_cert" => "", - "reg_server_cert_fingerprint" => "AB:CD:EF", - "reg_server_cert_fingerprint_type" => "SHA1", - "slp_discovery" => false - } - end - - before do - # start each test with empty config - subject.reset - end - - describe "#reset" do - it "resets the current configuration" do - subject.do_registration = true - subject.reset - expect(subject.do_registration).to eq(false) - end - end - - describe "#export" do - it "exports only 'do_registration' key when registration is disabled" do - subject.do_registration = false - expect(subject.export).to eq("do_registration" => false) - end - - it "exports complete data as a Hash when registration is enabled" do - subject.do_registration = true - subject.reg_server_cert_fingerprint_type = "SHA1" - subject.reg_server_cert_fingerprint = "AB:CD:EF" - subject.addons << addon - subject.email = "[email protected]" - subject.reg_code = "FOOBAR42" - - expect(subject.export).to eq(config) - end - - it "exports imported config unmodified" do - subject.import(config) - expect(subject.export).to eq(config) - end - end - - describe "#import" do - it "resets the configuration before importing the data" do - subject.reg_server = "http://example.com" - subject.import({}) - expect(subject.reg_server).to eq("") - end - - it "imports the data from a Hash" do - subject.import(config) - expect(subject.do_registration).to eq(true) - expect(subject.reg_server).to eq("") - expect(subject.email).to eq("[email protected]") - expect(subject.reg_code).to eq("FOOBAR42") - expect(subject.addons.size).to eq 1 - end - end -end - describe Registration::Storage::SSLErrors do subject { Registration::Storage::SSLErrors.instance }
