Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package yast2-storage-ng for openSUSE:Factory checked in at 2022-01-05 13:39:20 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-storage-ng (Old) and /work/SRC/openSUSE:Factory/.yast2-storage-ng.new.1896 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-storage-ng" Wed Jan 5 13:39:20 2022 rev:115 rq:943568 version:4.4.30 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-storage-ng/yast2-storage-ng.changes 2021-12-21 18:40:28.337865259 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-storage-ng.new.1896/yast2-storage-ng.changes 2022-01-05 13:39:34.797517433 +0100 @@ -1,0 +2,20 @@ +Mon Jan 3 09:22:05 UTC 2022 - Ladislav Slez??k <lsle...@suse.cz> + +- Display LUKS2 configuration checkbox in the installer console + (related to jsc#SLE-21308) +- 4.4.30 + +------------------------------------------------------------------- +Fri Dec 31 10:36:11 UTC 2021 - Josef Reidinger <jreidin...@suse.com> + +- Adapt for ruby 3.1 (bsc#1193192) +- 4.4.29 + +------------------------------------------------------------------- +Wed Dec 22 14:06:54 UTC 2021 - Ancor Gonzalez Sosa <an...@suse.com> + +- Dropped test clients proposal_testing and partitioner_testing in + favor of a more powerful one called storage_testing (related to + fate#318196). + +------------------------------------------------------------------- Old: ---- yast2-storage-ng-4.4.28.tar.bz2 New: ---- yast2-storage-ng-4.4.30.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-storage-ng.spec ++++++ --- /var/tmp/diff_new_pack.V9G7XF/_old 2022-01-05 13:39:35.285517817 +0100 +++ /var/tmp/diff_new_pack.V9G7XF/_new 2022-01-05 13:39:35.293517824 +0100 @@ -1,7 +1,7 @@ # # spec file for package yast2-storage-ng # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: yast2-storage-ng -Version: 4.4.28 +Version: 4.4.30 Release: 0 Summary: YaST2 - Storage Configuration License: GPL-2.0-only OR GPL-3.0-only ++++++ yast2-storage-ng-4.4.28.tar.bz2 -> yast2-storage-ng-4.4.30.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.4.28/package/yast2-storage-ng.changes new/yast2-storage-ng-4.4.30/package/yast2-storage-ng.changes --- old/yast2-storage-ng-4.4.28/package/yast2-storage-ng.changes 2021-12-20 17:32:39.000000000 +0100 +++ new/yast2-storage-ng-4.4.30/package/yast2-storage-ng.changes 2022-01-03 11:33:41.000000000 +0100 @@ -1,4 +1,24 @@ ------------------------------------------------------------------- +Mon Jan 3 09:22:05 UTC 2022 - Ladislav Slez??k <lsle...@suse.cz> + +- Display LUKS2 configuration checkbox in the installer console + (related to jsc#SLE-21308) +- 4.4.30 + +------------------------------------------------------------------- +Fri Dec 31 10:36:11 UTC 2021 - Josef Reidinger <jreidin...@suse.com> + +- Adapt for ruby 3.1 (bsc#1193192) +- 4.4.29 + +------------------------------------------------------------------- +Wed Dec 22 14:06:54 UTC 2021 - Ancor Gonzalez Sosa <an...@suse.com> + +- Dropped test clients proposal_testing and partitioner_testing in + favor of a more powerful one called storage_testing (related to + fate#318196). + +------------------------------------------------------------------- Mon Dec 20 16:25:17 UTC 2021 - Ancor Gonzalez Sosa <an...@suse.com> - Partitioner: added a warning if a required mount option, eg. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.4.28/package/yast2-storage-ng.spec new/yast2-storage-ng-4.4.30/package/yast2-storage-ng.spec --- old/yast2-storage-ng-4.4.28/package/yast2-storage-ng.spec 2021-12-20 17:32:39.000000000 +0100 +++ new/yast2-storage-ng-4.4.30/package/yast2-storage-ng.spec 2022-01-03 11:33:41.000000000 +0100 @@ -16,7 +16,7 @@ # Name: yast2-storage-ng -Version: 4.4.28 +Version: 4.4.30 Release: 0 Summary: YaST2 - Storage Configuration License: GPL-2.0-only OR GPL-3.0-only diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.4.28/src/clients/partitioner_testing.rb new/yast2-storage-ng-4.4.30/src/clients/partitioner_testing.rb --- old/yast2-storage-ng-4.4.28/src/clients/partitioner_testing.rb 2021-12-20 17:32:39.000000000 +0100 +++ new/yast2-storage-ng-4.4.30/src/clients/partitioner_testing.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,40 +0,0 @@ -# Copyright (c) [2017] 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. -# TODO: just temporary client for testing partitioner with different hardware setup -# call with `yast2 partitioner_testing <path_to_yaml>` - -require "yast" -require "y2partitioner/clients/main" -require "y2storage" - -# Comment next line and run the file with root privileges to test system lock -Y2Storage::StorageManager.create_test_instance - -arg = Yast::WFM.Args.first -case arg -when /.ya?ml$/ - Y2Storage::StorageManager.instance(mode: :rw).probe_from_yaml(arg) -when /.xml$/ - # note: support only xml device graph, not xml output of probing commands - Y2Storage::StorageManager.instance(mode: :rw).probe_from_xml(arg) -else - raise "Invalid testing parameter #{arg}, expecting foo.yml or foo.xml." -end - -Y2Partitioner::Clients::Main.new.run(allow_commit: false) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.4.28/src/clients/proposal_testing.rb new/yast2-storage-ng-4.4.30/src/clients/proposal_testing.rb --- old/yast2-storage-ng-4.4.28/src/clients/proposal_testing.rb 2021-12-20 17:32:39.000000000 +0100 +++ new/yast2-storage-ng-4.4.30/src/clients/proposal_testing.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,64 +0,0 @@ -# Copyright (c) [2018] 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. -# TODO: just temporary client for testing partitioner with different hardware setup -# call with `yast2 partitioner_testing <path_to_yaml>` - -require "yast" -require "y2storage" -require "y2storage/clients/inst_disk_proposal" - -# Usage: -# -# /sbin/yast2 proposal_testing path_to_devicegraph_file [path_to_control_file] -# -# Example: -# -# $ Y2DIR=src/ /sbin/yast2 proposal_testing test/data/devicegraphs/empty_disks.yml -# test/data/control_files/volumes_ng/control.SLE-like.xml - -Yast.import "ProductFeatures" - -def load_devicegraph - file = Yast::WFM.Args.first - - case file - when /.ya?ml$/ - Y2Storage::StorageManager.instance(mode: :rw).probe_from_yaml(file) - when /.xml$/ - # note: support only xml device graph, not xml output of probing commands - Y2Storage::StorageManager.instance(mode: :rw).probe_from_xml(file) - else - raise "Invalid testing parameter #{file}, expecting foo.yml or foo.xml." - end -end - -def load_control_file - file = Yast::WFM.Args.last - return if file.nil? - - features = Yast::XML.XMLToYCPFile(file) - Yast::ProductFeatures.Import(features) -end - -Y2Storage::StorageManager.create_test_instance - -load_devicegraph -load_control_file - -Y2Storage::Clients::InstDiskProposal.new.run diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.4.28/src/clients/storage_testing.rb new/yast2-storage-ng-4.4.30/src/clients/storage_testing.rb --- old/yast2-storage-ng-4.4.28/src/clients/storage_testing.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-storage-ng-4.4.30/src/clients/storage_testing.rb 2022-01-03 11:33:41.000000000 +0100 @@ -0,0 +1,25 @@ +# 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. +# TODO: just temporary client for testing partitioner with different hardware setup +# call with `yast2 partitioner_testing <path_to_yaml>` + +require "yast" +require "y2storage/clients/manual_test" + +Y2Storage::Clients::ManualTest.run diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.4.28/src/lib/installation/console/plugins/luks2_checkbox.rb new/yast2-storage-ng-4.4.30/src/lib/installation/console/plugins/luks2_checkbox.rb --- old/yast2-storage-ng-4.4.28/src/lib/installation/console/plugins/luks2_checkbox.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-storage-ng-4.4.30/src/lib/installation/console/plugins/luks2_checkbox.rb 2022-01-03 11:33:41.000000000 +0100 @@ -0,0 +1,74 @@ +# ------------------------------------------------------------------------------ +# 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. +# +# ------------------------------------------------------------------------------ + +require "yast" + +require "cwm" +require "installation/console/menu_plugin" +require "y2storage/storage_env" + +module Installation + module Console + module Plugins + # define a checkbox for enabling the experimental LUKS2 support in the installer + class LUKS2CheckBox < CWM::CheckBox + include Yast::Logger + + def initialize + textdomain "storage" + end + + # set the initial status + def init + check if Y2Storage::StorageEnv.instance.luks2_available? + end + + def label + # TRANSLATORS: check box label + _("Enable Experimental LUKS2 Encryption Support") + end + + def store + # the evaluated env variables are cached, we need to drop the cache + # when doing any change + Y2Storage::StorageEnv.instance.reset_cache + + if checked? + ENV["YAST_LUKS2_AVAILABLE"] = "1" + else + ENV.delete("YAST_LUKS2_AVAILABLE") + end + end + + def help + # TRANSLATORS: help text for the checkbox enabling LUKS2 support + _("<p>You can enable experimental LUKS2 encryption support in "\ + "the YaST partitioner. It is not supported and is designed as a " \ + "technology preview only.</p>") + end + end + + # define the plugin + class LUKS2CheckBoxPlugin < MenuPlugin + def widget + LUKS2CheckBox.new + end + + # at the end + def order + 2000 + end + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.4.28/src/lib/y2storage/abstract_device_factory.rb new/yast2-storage-ng-4.4.30/src/lib/y2storage/abstract_device_factory.rb --- old/yast2-storage-ng-4.4.28/src/lib/y2storage/abstract_device_factory.rb 2021-12-20 17:32:39.000000000 +0100 +++ new/yast2-storage-ng-4.4.30/src/lib/y2storage/abstract_device_factory.rb 2022-01-03 11:33:41.000000000 +0100 @@ -74,7 +74,15 @@ if yaml_file.respond_to?(:read) YAML.load_stream(yaml_file) { |doc| build_tree(doc) } else - File.open(yaml_file) { |file| YAML.load_stream(file, yaml_file) { |doc| build_tree(doc) } } + File.open(yaml_file) do |file| + block = proc { |doc| build_tree(doc) } + old_ruby = RUBY_VERSION.start_with?("2.") + if old_ruby + YAML.load_stream(file, yaml_file, &block) + else + YAML.load_stream(file, filename: yaml_file, &block) + end + end end rescue SystemCallError => e log.error(e.to_s) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.4.28/src/lib/y2storage/clients/autoinst_manual_test.rb new/yast2-storage-ng-4.4.30/src/lib/y2storage/clients/autoinst_manual_test.rb --- old/yast2-storage-ng-4.4.28/src/lib/y2storage/clients/autoinst_manual_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-storage-ng-4.4.30/src/lib/y2storage/clients/autoinst_manual_test.rb 2022-01-03 11:33:41.000000000 +0100 @@ -0,0 +1,79 @@ +#!/usr/bin/env ruby +# +# encoding: utf-8 + +# 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 "yast" +require "y2storage" +require "installation/proposal_store" +require "installation/proposal_runner" + +module Y2Storage + # Helper class to display only the partitioning AutoYaST proposal + class TestProposalStore < Installation::ProposalStore + # @return [Array<String>] proposal names in execution order, including + # the "_proposal" suffix + def proposal_names + ["partitions_proposal"] + end + + # @return [Array<String>] single list of modules presentation order + def presentation_order + proposal_names + end + end + + module Clients + # Simple client to compute and display the AutoYaST storage proposal + class AutoinstManualTest + # Constructor + def initialize + Yast.import "AutoinstStorage" + Yast.import "AutoinstConfig" + Yast.import "Wizard" + end + + # Computes the AutoYaST partitioning proposal based on the current profile and opens a dialog + # to display the result + # + # @return [Symbol] + def run + Yast::AutoinstStorage.Import(Yast::Profile.current["partitioning"]) + display_autoinst_proposal + end + + private + + # @see #run + def display_autoinst_proposal + Yast::AutoinstConfig.Confirm = true + Yast::Wizard.OpenNextBackDialog + begin + ret = Installation::ProposalRunner.new(TestProposalStore).run + ensure + Yast::Wizard.CloseDialog + end + + ret + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.4.28/src/lib/y2storage/clients/manual_test.rb new/yast2-storage-ng-4.4.30/src/lib/y2storage/clients/manual_test.rb --- old/yast2-storage-ng-4.4.28/src/lib/y2storage/clients/manual_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-storage-ng-4.4.30/src/lib/y2storage/clients/manual_test.rb 2022-01-03 11:33:41.000000000 +0100 @@ -0,0 +1,182 @@ +#!/usr/bin/env ruby +# +# encoding: utf-8 + +# 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 "yast" +require "y2storage" +require "y2partitioner/clients/main" +require "y2storage/clients/inst_disk_proposal" +require "y2storage/clients/autoinst_manual_test" + +module Y2Storage + module Clients + # Client that runs any of the relevant parts of yast2-storage-ng into a mocked environment + class ManualTest + include Yast::I18n + + # Constructor + def initialize + textdomain "storage" + + @action = nil + @command_error = nil + @devicegraph_path = nil + @profile_path = nil + @control_file_path = nil + end + + # Parses the arguments and opens the corresponding dialog + def self.run + client = new + client.parse_args + client.run + end + + # Parses the command line arguments + def parse_args + @action = args.first&.to_sym + return unless validate_action + + @devicegraph_path = args[1] + return unless validate_devicegraph_path + + if action == :autoinst + @profile_path = args[2] + @command_error = _("No AutoYaST profile provided") unless profile_path + elsif action == :proposal + @control_file_path = args[2] + end + end + + # Executes the client + def run + if command_error + display_help + return :abort + end + + Y2Storage::StorageManager.create_test_instance + mock + + case action + when :partitioner + Y2Partitioner::Clients::Main.new.run(allow_commit: false) + when :proposal + Y2Storage::Clients::InstDiskProposal.new.run + when :autoinst + Y2Storage::Clients::AutoinstManualTest.new.run + end + end + + private + + # @return [String, nil] error to display if the client is not invoked correctly + attr_reader :command_error + + # @return [String, nil] path of the file containing the devicegraph to use as main mock + attr_reader :devicegraph_path + + # @return [String, nil] path to an AutoYaST profile + attr_reader :profile_path + + # @return [String, nil] path to a control file to influence the action behavior + attr_reader :control_file_path + + # @return [Symbol, nil] action to test, can be :partitioner, :proposal or :autoinst + attr_reader :action + + # Command line arguments + def args + Yast::WFM.Args + end + + # Mocks the execution environment + def mock + load_devicegraph if devicegraph_path + load_profile if profile_path + load_control_file if control_file_path + end + + # @see #parse_args + def validate_action + if action.nil? + @command_error = _("No action specified") + return false + end + + return true if [:partitioner, :proposal, :autoinst].include?(action) + + @command_error = format(_("Unknown action '%s'"), action) + false + end + + # @see #parse_args + def validate_devicegraph_path + if devicegraph_path.nil? + @command_error = _("No devicegraph file provided") + return false + end + + return true if devicegraph_path =~ /.(xml|ya?ml)$/ + + @command_error = format( + _("Wrong devicegraph path %s, expecting foo.yml, foo.yaml or foo.xml."), devicegraph_path + ) + false + end + + # @see #mock + def load_devicegraph + if devicegraph_path =~ /.ya?ml$/ + Y2Storage::StorageManager.instance(mode: :rw).probe_from_yaml(devicegraph_path) + else + Y2Storage::StorageManager.instance(mode: :rw).probe_from_xml(devicegraph_path) + end + end + + # @see #mock + def load_profile + Yast.import "Profile" + Yast::Profile.ReadXML(profile_path) + end + + # @see #mock + def load_control_file + Yast.import "ProductFeatures" + features = Yast::XML.XMLToYCPFile(control_file_path) + Yast::ProductFeatures.Import(features) + end + + # Prints a basic help text to the standard output + def display_help + warn command_error + # TRANSLATORS: help text printed in the standard output in case of wrong command + warn _( + "Use one of the following:\n" \ + " yast2 storage_testing partitioner devicegraph.(xml|yml)\n" \ + " yast2 storage_testing proposal devicegraph.(xml|yml) [control_file.xml]\n" \ + " yast2 storage_testing autoinst devicegraph.(xml|yml) profile.xml" + ) + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.4.28/src/lib/y2storage/device.rb new/yast2-storage-ng-4.4.30/src/lib/y2storage/device.rb --- old/yast2-storage-ng-4.4.28/src/lib/y2storage/device.rb 2021-12-20 17:32:39.000000000 +0100 +++ new/yast2-storage-ng-4.4.30/src/lib/y2storage/device.rb 2022-01-03 11:33:41.000000000 +0100 @@ -458,7 +458,12 @@ serialized = userdata[key.to_s] return nil if serialized.nil? - YAML.load(serialized) # rubocop:disable Security/YAMLLoad # here it is our data, so safe + if RUBY_VERSION.start_with?("2.") + YAML.load(serialized) # rubocop:disable Security/YAMLLoad # here it is our data, so safe + else + # ruby3 from 3.1 defaults load to safe_load, so need explicit unsafe_load + YAML.unsafe_load(serialized) + end end # Generic mechanism to update the concrete attribute checked by {#in_etc?} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.4.28/src/lib/y2storage/storage_env.rb new/yast2-storage-ng-4.4.30/src/lib/y2storage/storage_env.rb --- old/yast2-storage-ng-4.4.28/src/lib/y2storage/storage_env.rb 2021-12-20 17:32:39.000000000 +0100 +++ new/yast2-storage-ng-4.4.30/src/lib/y2storage/storage_env.rb 2022-01-03 11:33:41.000000000 +0100 @@ -40,6 +40,13 @@ private_constant :ENV_LIBSTORAGE_IGNORE_PROBE_ERRORS def initialize + reset_cache + end + + # Reset the cached values of the environment variables, + # call this after changing the value of any used environment variable + def reset_cache + log.debug "Resetting ENV values cache" @active_cache = {} end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.4.28/test/installation/console/plugins/luks2_checkbox_test.rb new/yast2-storage-ng-4.4.30/test/installation/console/plugins/luks2_checkbox_test.rb --- old/yast2-storage-ng-4.4.28/test/installation/console/plugins/luks2_checkbox_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-storage-ng-4.4.30/test/installation/console/plugins/luks2_checkbox_test.rb 2022-01-03 11:33:41.000000000 +0100 @@ -0,0 +1,114 @@ +# 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" + +begin + # in development or in GitHub Actions the file might be present, + # try loading the original file + old_require "installation/console/menu_plugin" +rescue LoadError + # the file is missing, mock the "installation/console/menu_plugin" content, + # needed during RPM build + module Installation + module Console + class MenuPlugin + end + end + end +end + +require "installation/console/plugins/luks2_checkbox" +require "cwm/rspec" + +describe Installation::Console::Plugins::LUKS2CheckBox do + subject(:widget) { described_class.new } + + include_examples "CWM::CheckBox" + + describe "#init" do + before do + expect(Y2Storage::StorageEnv.instance).to receive(:luks2_available?) + .and_return(luks2_available) + end + + context "LUKS2 available" do + let(:luks2_available) { true } + + it "sets the initial state to checked" do + expect(widget).to receive(:check) + widget.init + end + end + + context "LUKS2 not available" do + let(:luks2_available) { false } + + it "sets the initial state to unchecked" do + expect(widget).to_not receive(:check) + widget.init + end + end + end + + describe "#store" do + before do + allow(Y2Storage::StorageEnv.instance).to receive(:reset_cache) + allow(ENV).to receive(:delete) + allow(ENV).to receive(:[]=) + + allow(widget).to receive(:checked?).and_return(checked) + end + + context "the checkbox is checked" do + let(:checked) { true } + + it "sets the YAST_LUKS2_AVAILABLE env variable to 1" do + expect(Y2Storage::StorageEnv.instance).to receive(:reset_cache) + expect(ENV).to receive(:[]=).with("YAST_LUKS2_AVAILABLE", "1") + widget.store + end + end + + context "the checkbox is not checked" do + let(:checked) { false } + + it "deletes the YAST_LUKS2_AVAILABLE env variable" do + expect(Y2Storage::StorageEnv.instance).to receive(:reset_cache) + expect(ENV).to receive(:delete).with("YAST_LUKS2_AVAILABLE") + widget.store + end + end + end +end + +describe Installation::Console::Plugins::LUKS2CheckBoxPlugin do + describe "#order" do + it "returns a positive number" do + expect(subject.order).to be_a(Numeric) + expect(subject.order).to be > 0 + end + end + + describe "#widget" do + it "returns a CWM widget" do + expect(subject.widget).to be_a(CWM::AbstractWidget) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.4.28/test/spec_helper.rb new/yast2-storage-ng-4.4.30/test/spec_helper.rb --- old/yast2-storage-ng-4.4.28/test/spec_helper.rb 2021-12-20 17:32:39.000000000 +0100 +++ new/yast2-storage-ng-4.4.30/test/spec_helper.rb 2022-01-03 11:33:41.000000000 +0100 @@ -29,7 +29,12 @@ # fail fast if a class does not declare textdomain (bsc#1130822) ENV["Y2STRICTTEXTDOMAIN"] = "1" -LIBS_TO_SKIP = ["y2packager/repository"] +LIBS_TO_SKIP = [ + "installation/console/menu_plugin", + "installation/proposal_runner", + "installation/proposal_store", + "y2packager/repository" +] # Hack to avoid to require some files # @@ -76,6 +81,13 @@ require_relative "support/storage_helpers" +module Installation + # The Installation::ProposalStore and Installation::ProposalRunner classes are not loaded in the + # tests to avoid cyclic dependencies with yast2-installation at build time. + class ProposalStore; end + class ProposalRunner; end +end + RSpec.configure do |c| c.include Yast::RSpec::StorageHelpers @@ -86,6 +98,16 @@ stub_const("Y2Packager::Repository", double("Y2Packager::Repository")) allow(Y2Packager::Repository).to receive(:all).and_return([]) + allow(Yast).to receive(:import).and_call_original + # Yast::Profile, AutoinstStorage and AutoinstConfig are not loaded in the tests to avoid cyclic + # dependencies with the yast-installation package at build time. + allow(Yast).to receive(:import).with("Profile") + allow(Yast).to receive(:import).with("AutoinstStorage") + allow(Yast).to receive(:import).with("AutoinstConfig") + stub_const("Yast::Profile", double("Yast::Profile")) + stub_const("Yast::AutoinstStorage", double("Yast::AutoinstStorage")) + stub_const("Yast::AutoinstConfig", double("Yast::AutoinstConfig")) + allow(Y2Storage::DumpManager.instance).to receive(:dump) if respond_to?(:architecture) # Match mocked architecture in Arch module diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.4.28/test/y2storage/clients/manual_test_test.rb new/yast2-storage-ng-4.4.30/test/y2storage/clients/manual_test_test.rb --- old/yast2-storage-ng-4.4.28/test/y2storage/clients/manual_test_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-storage-ng-4.4.30/test/y2storage/clients/manual_test_test.rb 2022-01-03 11:33:41.000000000 +0100 @@ -0,0 +1,222 @@ +#!/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 "y2storage/clients/manual_test" + +describe Y2Storage::Clients::ManualTest do + describe ".run" do + before do + allow(Yast::WFM).to receive(:Args).and_return(args) + allow(Y2Partitioner::Clients::Main).to receive(:new).and_return partitioner_client + allow(Y2Storage::Clients::InstDiskProposal).to receive(:new).and_return proposal_client + allow(Y2Storage::StorageManager).to receive(:create_test_instance) + allow(Y2Storage::StorageManager).to receive(:instance).and_return storage_manager + end + + let(:storage_manager) { double("StorageManager", probe_from_yaml: nil, probe_from_xml: nil) } + let(:partitioner_client) { double("Main", run: :next) } + let(:proposal_client) { double("InstDiskProposal", run: :next) } + + RSpec.shared_examples "abort" do + it "shows the help text" do + expect { described_class.run }.to output(/yast2 storage_testing/).to_stderr + end + + it "returns :abort" do + allow(Warning).to receive(:warn) + expect(described_class.run).to eq :abort + end + end + + RSpec.shared_examples "mock devicegraph" do + it "mocks the devicegraph with the given file" do + expect(storage_manager).to receive(:probe_from_xml).with(args[1]) + described_class.run + end + end + + context "if no arguments are provided" do + let(:args) { [] } + + it "reports the corresponding error" do + expect { described_class.run }.to output(/No action/).to_stderr + end + + include_examples "abort" + end + + context "if a wrong action is specified" do + let(:args) { ["whatever"] } + + it "reports the corresponding error" do + expect { described_class.run }.to output(/Unknown action/).to_stderr + end + + include_examples "abort" + end + + context "partitioner action without a devicegraph" do + let(:args) { ["partitioner"] } + + it "reports the corresponding error" do + expect { described_class.run }.to output(/No devicegraph/).to_stderr + end + + include_examples "abort" + end + + context "partitioner action with a devicegraph file not ending in xml/yml/yaml" do + let(:args) { ["partitioner", "devicegraph.txt"] } + + it "reports the corresponding error" do + expect { described_class.run }.to output(/Wrong devicegraph path/).to_stderr + end + + include_examples "abort" + end + + context "partitioner action with a devicegraph file ending in .xml" do + let(:args) { ["partitioner", "devicegraph.xml"] } + + it "mocks the devicegraph with the xml file" do + expect(storage_manager).to receive(:probe_from_xml).with("devicegraph.xml") + described_class.run + end + + it "opens the partitioner" do + expect(partitioner_client).to receive(:run) + described_class.run + end + end + + context "partitioner action with a devicegraph file ending in .yaml" do + let(:args) { ["partitioner", "/path/to/devicegraph.yaml"] } + + it "mocks the devicegraph with the YAML file" do + expect(storage_manager).to receive(:probe_from_yaml).with("/path/to/devicegraph.yaml") + described_class.run + end + + it "opens the partitioner" do + expect(partitioner_client).to receive(:run) + described_class.run + end + end + + context "proposal action without a devicegraph" do + let(:args) { ["partitioner"] } + + it "reports the corresponding error" do + expect { described_class.run }.to output(/No devicegraph/).to_stderr + end + + include_examples "abort" + end + + context "proposal action with a devicegraph file and no control file" do + let(:args) { ["proposal", "devicegraph.xml"] } + + include_examples "mock devicegraph" + + it "uses the product features from the current system" do + expect(Yast::ProductFeatures).to_not receive(:Import) + described_class.run + end + + it "opens the proposal client" do + expect(proposal_client).to receive(:run) + described_class.run + end + end + + context "proposal action with a devicegraph file and a control file" do + let(:args) { ["proposal", "/path/to/devicegraph.xml", "control.xml"] } + + before do + allow(Yast::XML).to receive(:XMLToYCPFile).and_return(some: "value") + end + + include_examples "mock devicegraph" + + it "mocks the product features" do + expect(Yast::ProductFeatures).to receive(:Import).with(some: "value") + described_class.run + end + + it "opens the proposal client" do + expect(proposal_client).to receive(:run) + described_class.run + end + end + + context "autoinst action without a devicegraph" do + let(:args) { ["autoinst"] } + + it "reports the corresponding error" do + expect { described_class.run }.to output(/No devicegraph/).to_stderr + end + + include_examples "abort" + end + + context "autoinst action with a devicegraph file and no profile" do + let(:args) { ["autoinst", "/path/to/devicegraph.xml"] } + + it "reports the corresponding error" do + expect { described_class.run }.to output(/No AutoYaST profile/).to_stderr + end + + include_examples "abort" + end + + context "autoinst action with a devicegraph file and a profile" do + let(:args) { ["autoinst", "/path/to/devicegraph.xml", "/the/profile.xml"] } + + before do + allow(Yast::Profile).to receive(:ReadXML) + allow(Yast::Profile).to receive(:current).and_return({}) + allow(Yast::AutoinstConfig).to receive(:Confirm=) + allow(Yast::AutoinstStorage).to receive(:Import) + allow(Installation::ProposalRunner).to receive(:new).and_return runner + + Yast.import "Wizard" + allow(Yast::Wizard).to receive(:OpenNextBackDialog) + allow(Yast::Wizard).to receive(:CloseDialog) + end + + let(:runner) { double("ProposalRunner", run: :next) } + + include_examples "mock devicegraph" + + it "loads and imports the profile" do + expect(Yast::Profile).to receive(:ReadXML).with("/the/profile.xml") + expect(Yast::AutoinstStorage).to receive(:Import) + described_class.run + end + + it "displays the proposal dialog" do + expect(Yast::AutoinstConfig).to receive(:Confirm=).with(true) + expect(runner).to receive(:run) + described_class.run + end + end + end +end