Hello community, here is the log from the commit of package autoyast2 for openSUSE:Factory checked in at 2018-05-06 14:58:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/autoyast2 (Old) and /work/SRC/openSUSE:Factory/.autoyast2.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "autoyast2" Sun May 6 14:58:25 2018 rev:243 rq:604050 version:4.0.52 Changes: -------- --- /work/SRC/openSUSE:Factory/autoyast2/autoyast2.changes 2018-04-26 13:30:11.261324093 +0200 +++ /work/SRC/openSUSE:Factory/.autoyast2.new/autoyast2.changes 2018-05-06 14:58:31.851494585 +0200 @@ -1,0 +2,22 @@ +Fri May 4 10:58:42 UTC 2018 - igonzalezsosa@suse.com + +- Allow 'subvolumes' and 'subvolumes_prefix' elements to be empty + (bsc#1076337, bsc#1090095 and bsc#1091669). +- Drop 'btrfs_set_default_subvolume_name' element. +- 4.0.52 + +------------------------------------------------------------------- +Fri Apr 28 16:24:37 CEST 2018 - schubi@suse.de + +- Added general API for reporting errors while parsing the AutoYaST + configuration file (part of bnc#1089855). +- 4.0.51 + +------------------------------------------------------------------- +Fri Apr 27 15:43:05 UTC 2018 - igonzalezsosa@suse.com + +- Display an error and abort the installation when no storage + devices are available for installation (bsc#1091033). +- 4.0.50 + +------------------------------------------------------------------- Old: ---- autoyast2-4.0.49.tar.bz2 New: ---- autoyast2-4.0.52.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ autoyast2.spec ++++++ --- /var/tmp/diff_new_pack.ieC6WW/_old 2018-05-06 14:58:33.399437781 +0200 +++ /var/tmp/diff_new_pack.ieC6WW/_new 2018-05-06 14:58:33.403437634 +0200 @@ -22,7 +22,7 @@ %endif Name: autoyast2 -Version: 4.0.49 +Version: 4.0.52 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -85,7 +85,7 @@ Requires: yast2-ruby-bindings >= 1.0.0 Summary: YaST2 - Automated Installation -License: GPL-2.0 +License: GPL-2.0-only Group: System/YaST %description @@ -302,6 +302,9 @@ %dir %{yast_libdir}/autoinstall/clients %{yast_libdir}/autoinstall/clients/*.rb +%dir %{yast_libdir}/autoinstall/autoinst_issues +%{yast_libdir}/autoinstall/autoinst_issues/*.rb + # scripts %{_prefix}/lib/YaST2/bin/fetch_image.sh %{_prefix}/lib/YaST2/bin/autoyast-initscripts.sh ++++++ autoyast2-4.0.49.tar.bz2 -> autoyast2-4.0.52.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/package/autoyast2.changes new/autoyast2-4.0.52/package/autoyast2.changes --- old/autoyast2-4.0.49/package/autoyast2.changes 2018-04-23 11:08:21.000000000 +0200 +++ new/autoyast2-4.0.52/package/autoyast2.changes 2018-05-04 16:23:04.000000000 +0200 @@ -1,4 +1,26 @@ ------------------------------------------------------------------- +Fri May 4 10:58:42 UTC 2018 - igonzalezsosa@suse.com + +- Allow 'subvolumes' and 'subvolumes_prefix' elements to be empty + (bsc#1076337, bsc#1090095 and bsc#1091669). +- Drop 'btrfs_set_default_subvolume_name' element. +- 4.0.52 + +------------------------------------------------------------------- +Fri Apr 28 16:24:37 CEST 2018 - schubi@suse.de + +- Added general API for reporting errors while parsing the AutoYaST + configuration file (part of bnc#1089855). +- 4.0.51 + +------------------------------------------------------------------- +Fri Apr 27 15:43:05 UTC 2018 - igonzalezsosa@suse.com + +- Display an error and abort the installation when no storage + devices are available for installation (bsc#1091033). +- 4.0.50 + +------------------------------------------------------------------- Fri Apr 20 20:58:54 UTC 2018 - igonzalezsosa@suse.com - AutoYaST: properly handle empty proposals (bsc#1090390). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/package/autoyast2.spec new/autoyast2-4.0.52/package/autoyast2.spec --- old/autoyast2-4.0.49/package/autoyast2.spec 2018-04-23 11:08:21.000000000 +0200 +++ new/autoyast2-4.0.52/package/autoyast2.spec 2018-05-04 16:23:04.000000000 +0200 @@ -22,7 +22,7 @@ %endif Name: autoyast2 -Version: 4.0.49 +Version: 4.0.52 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -302,6 +302,9 @@ %dir %{yast_libdir}/autoinstall/clients %{yast_libdir}/autoinstall/clients/*.rb +%dir %{yast_libdir}/autoinstall/autoinst_issues +%{yast_libdir}/autoinstall/autoinst_issues/*.rb + # scripts %{_prefix}/lib/YaST2/bin/fetch_image.sh %{_prefix}/lib/YaST2/bin/autoyast-initscripts.sh diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/src/Makefile.am new/autoyast2-4.0.52/src/Makefile.am --- old/autoyast2-4.0.49/src/Makefile.am 2018-04-23 11:08:21.000000000 +0200 +++ new/autoyast2-4.0.52/src/Makefile.am 2018-05-04 16:23:04.000000000 +0200 @@ -75,6 +75,8 @@ lib/autoinstall/partitioning_preprocessor.rb \ lib/autoinstall/autosetup_helpers.rb \ lib/autoinstall/storage_proposal.rb \ + lib/autoinstall/autoinst_issues_presenter.rb \ + lib/autoinstall/autoinst_issues.rb \ lib/autoinstall/storage_proposal_issues_presenter.rb ydialogsdir = @ylibdir@/autoinstall/dialogs @@ -86,6 +88,13 @@ yclients_DATA = \ lib/autoinstall/clients/ayast_probe.rb +ycautoinst_issuesdir = @ylibdir@/autoinstall/autoinst_issues +ycautoinst_issues_DATA = \ + lib/autoinstall/autoinst_issues/invalid_value.rb \ + lib/autoinstall/autoinst_issues/issue.rb \ + lib/autoinstall/autoinst_issues/list.rb \ + lib/autoinstall/autoinst_issues/missing_value.rb + scrconf_DATA = \ scrconf/cfg_autoinstall.scr \ scrconf/autoinstall.scr diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/src/autoyast-rnc/general.rnc new/autoyast2-4.0.52/src/autoyast-rnc/general.rnc --- old/autoyast2-4.0.49/src/autoyast-rnc/general.rnc 2018-04-23 11:08:21.000000000 +0200 +++ new/autoyast2-4.0.52/src/autoyast-rnc/general.rnc 2018-05-04 16:23:04.000000000 +0200 @@ -26,9 +26,7 @@ element proposal { text }* }? & element storage { - element start_multipath { BOOLEAN }? & - # FATE#317775: support for arbitraty Btrfs subvolume structure - element btrfs_set_default_subvolume_name { BOOLEAN }? + element start_multipath { BOOLEAN }? }? & element wait { element pre-modules { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/src/autoyast-rnc/partitioning.rnc new/autoyast2-4.0.52/src/autoyast-rnc/partitioning.rnc --- old/autoyast2-4.0.49/src/autoyast-rnc/partitioning.rnc 2018-04-23 11:08:21.000000000 +0200 +++ new/autoyast2-4.0.52/src/autoyast-rnc/partitioning.rnc 2018-05-04 16:23:04.000000000 +0200 @@ -76,6 +76,7 @@ | part_subvolumes_prefix | device_order | subvolumes + | create_subvolumes partition = element partition { y2_partition* } part_create = @@ -143,6 +144,9 @@ element copy_on_write { BOOLEAN }? } +create_subvolumes = + element create_subvolumes { BOOLEAN } + part_fstopt = element fstopt { text } part_label = element label { text } part_loop_fs = diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/src/clients/inst_autopost.rb new/autoyast2-4.0.52/src/clients/inst_autopost.rb --- old/autoyast2-4.0.49/src/clients/inst_autopost.rb 2018-04-23 11:08:21.000000000 +0200 +++ new/autoyast2-4.0.52/src/clients/inst_autopost.rb 2018-05-04 16:23:04.000000000 +0200 @@ -209,6 +209,9 @@ end end + # Checking result of semantic checks of imported values. + return :abort unless AutoInstall.valid_imported_values + # Add all found packages Progress.NextStep Progress.Title(_("Adding found packages...")) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/src/clients/inst_autosetup.rb new/autoyast2-4.0.52/src/clients/inst_autosetup.rb --- old/autoyast2-4.0.49/src/clients/inst_autosetup.rb 2018-04-23 11:08:21.000000000 +0200 +++ new/autoyast2-4.0.52/src/clients/inst_autosetup.rb 2018-05-04 16:23:04.000000000 +0200 @@ -424,7 +424,7 @@ Progress.NextStage autosetup_users - # + # # Import profile settings for copying SSH keys from a # previous installation # @@ -450,6 +450,9 @@ end end + # Results of imported values semantic check. + return :abort unless AutoInstall.valid_imported_values + Progress.Finish @ret = ProductControl.RunFrom(ProductControl.CurrentStep + 1, true) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/src/clients/inst_autosetup_upgrade.rb new/autoyast2-4.0.52/src/clients/inst_autosetup_upgrade.rb --- old/autoyast2-4.0.49/src/clients/inst_autosetup_upgrade.rb 2018-04-23 11:08:21.000000000 +0200 +++ new/autoyast2-4.0.52/src/clients/inst_autosetup_upgrade.rb 2018-05-04 16:23:04.000000000 +0200 @@ -457,6 +457,9 @@ end end + # Results of imported values semantic check. + return :abort unless AutoInstall.valid_imported_values + Progress.Finish @ret = ProductControl.RunFrom( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/src/include/autoinstall/xml.rb new/autoyast2-4.0.52/src/include/autoinstall/xml.rb --- old/autoyast2-4.0.49/src/include/autoinstall/xml.rb 2018-04-23 11:08:21.000000000 +0200 +++ new/autoyast2-4.0.52/src/include/autoinstall/xml.rb 2018-05-04 16:23:04.000000000 +0200 @@ -107,7 +107,8 @@ "sources" => "source", "zones" => "zone", "authorized_keys" => "authorized_key", - "products" => "product" + "products" => "product", + "subvolumes" => "subvolume" } ) @@ -122,7 +123,8 @@ "pxelinux-config", "location", "script_source", - "media_url" + "media_url", + "subvolumes_prefix" ] ) # doc["systemID"] = "/usr/share/autoinstall/dtd/profile.dtd"; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/src/lib/autoinstall/autoinst_issues/invalid_value.rb new/autoyast2-4.0.52/src/lib/autoinstall/autoinst_issues/invalid_value.rb --- old/autoyast2-4.0.49/src/lib/autoinstall/autoinst_issues/invalid_value.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-4.0.52/src/lib/autoinstall/autoinst_issues/invalid_value.rb 2018-05-04 16:23:04.000000000 +0200 @@ -0,0 +1,58 @@ +# encoding: utf-8 + +# 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. + +require "autoinstall/autoinst_issues/issue" + +module Y2Autoinstallation + module AutoinstIssues + # Represents an AutoYaST situation where an invalid value was given. + # + class InvalidValue < Issue + include Yast::Logger + + # @param section [String] main section name in the AutoYaST configuration file + # @param attribute [String] wrong attribute + # @param value [String] wrong attribute value + # @param description [String] additional explanation + # @param severity [Symbol] :warn, :fatal = abort the installation + def initialize(section, attribute, value, description, severity = :warn) + textdomain "autoinst" + @section = section + @attribute = attribute + @value = value + @description = description + @severity = severity + end + + # Return the error message to be displayed + # + # @return [String] Error message + # @see Issue#message + def message + # TRANSLATORS: + # 'value' is a generic value (number or string) 'attribute' is an AutoYaST element + # 'description' has already been translated in other modules. + _("Invalid value '%{value}' for attribute '%{attribute}': %{description}") % + { value: @value, attribute: @attribute, description: @description } + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/src/lib/autoinstall/autoinst_issues/issue.rb new/autoyast2-4.0.52/src/lib/autoinstall/autoinst_issues/issue.rb --- old/autoyast2-4.0.49/src/lib/autoinstall/autoinst_issues/issue.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-4.0.52/src/lib/autoinstall/autoinst_issues/issue.rb 2018-05-04 16:23:04.000000000 +0200 @@ -0,0 +1,55 @@ +module Y2Autoinstallation + module AutoinstIssues + # Base class for autoinstallation problems while importing the + # AutoYaST configuration file. + # + # Y2Autoinstallation::AutoinstIssues offers an API to register + # and report related AutoYaST problems. + class Issue + include Yast::I18n + + # @return [String] Section where it was detected + attr_reader :section + + # @return [Symbol] :warn, :fatal problem severity + attr_reader :severity + + # Return problem severity + # + # * :fatal: abort the installation. + # * :warn: display a warning. + # + # @return [Symbol] Issue severity (:warn, :fatal) + # @raise NotImplementedError + def severity + @severity || :warn + end + + # Return the error message to be displayed + # + # @return [String] Error message + # @raise NotImplementedError + def message + raise NotImplementedError + end + + # Determine whether an error is fatal + # + # This is just a convenience method. + # + # @return [Boolean] + def fatal? + severity == :fatal + end + + # Determine whether an error is just a warning + # + # This is just a convenience method. + # + # @return [Boolean] + def warn? + severity == :warn + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/src/lib/autoinstall/autoinst_issues/list.rb new/autoyast2-4.0.52/src/lib/autoinstall/autoinst_issues/list.rb --- old/autoyast2-4.0.49/src/lib/autoinstall/autoinst_issues/list.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-4.0.52/src/lib/autoinstall/autoinst_issues/list.rb 2018-05-04 16:23:04.000000000 +0200 @@ -0,0 +1,87 @@ +# encoding: utf-8 + +# 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. + +require "forwardable" + +module Y2Autoinstallation + module AutoinstIssues + # List of general AutoYaST problems + # + # @example Registering some problems + # list = List.new + # list.add(:invalid_value, "firewall", "interfaces", + # "eth0", + # _("This interface has been defined for more than one zone.")) + # + # @example Iterating through the list of problems + # list.map(&:severity) #=> [:warn] + class List + include Yast::Logger + include Enumerable + extend Forwardable + + def_delegators :@items, :each, :empty?, :<< + + # Constructor + def initialize + @items = [] + end + + # Add a problem to the list + # + # The type of the problem is identified as a symbol which name is the + # underscore version of the class which implements it. For instance, + # `InvalidValue` would be referred as `:invalid_value`. + # + # If a given type of problem requires some additional arguments, they + # should be added when calling this method. See the next example. + # + # @example Adding a problem with additional arguments + # list = List.new + # list.add(:invalid_value, "firewall", "FW_DEV_INT", "1", + # _("Is not supported anymore.")) + # list.empty? #=> false + # + # @param type [Symbol] Issue type + # @param extra_args [Array] Additional arguments for the given problem + # @return [Array<Issue>] List of problems + def add(type, *extra_args) + class_name = type.to_s.split("_").map(&:capitalize).join + klass = Y2Autoinstallation::AutoinstIssues.const_get(class_name) + self << klass.new(*extra_args) + end + + # Determine whether any of the problem on the list is fatal + # + # @return [Boolean] true if any of them is a fatal problem + def fatal? + any?(&:fatal?) + end + + # Returns an array containing registered problems + # + # @return [Array<Issue>] List of problems + def to_a + @items + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/src/lib/autoinstall/autoinst_issues/missing_value.rb new/autoyast2-4.0.52/src/lib/autoinstall/autoinst_issues/missing_value.rb --- old/autoyast2-4.0.49/src/lib/autoinstall/autoinst_issues/missing_value.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-4.0.52/src/lib/autoinstall/autoinst_issues/missing_value.rb 2018-05-04 16:23:04.000000000 +0200 @@ -0,0 +1,62 @@ +# encoding: utf-8 + +# 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. + + +require "autoinstall/autoinst_issues/issue" + +module Y2Autoinstallation + module AutoinstIssues + # Represents an AutoYaST situation where a mandatory value is missing. + # + # @example Missing value for attribute 'bar' in 'foo' section. + # problem = MissingValue.new("foo","bar") + class MissingValue < Issue + # @return [String] Name of the missing attribute + attr_reader :attr + attr_reader :description + + # @param section [String] Section where it was detected + # @param attr [String] Name of the missing attribute + # @param description [String] additional explanation; optional + # @param severity [Symbol] :warn, :fatal = abort the installation ; optional + def initialize(section, attr, description = "", severity = :warn) + textdomain "autoinst" + + @section = section + @attr = attr + @description = description + @severity = severity + end + + # Return the error message to be displayed + # + # @return [String] Error message + # @see Issue#message + def message + # TRANSLATORS: + # 'attr' is an AutoYaST element + # 'description' has already been translated in other modules. + _("Missing element '%{attr}'. %{description}") % + { attr: attr, description: description } + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/src/lib/autoinstall/autoinst_issues.rb new/autoyast2-4.0.52/src/lib/autoinstall/autoinst_issues.rb --- old/autoyast2-4.0.49/src/lib/autoinstall/autoinst_issues.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-4.0.52/src/lib/autoinstall/autoinst_issues.rb 2018-05-04 16:23:04.000000000 +0200 @@ -0,0 +1,40 @@ +# encoding: utf-8 + +# 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. + +module Y2Autoinstallation + # Y2Autoinstallation::AutoinstIssues offers an API to register and report + # related AutoYaST problems. + # + # Basically, it works by registering found problems when importing settings + # from the AutoYaST profile and displaying them to the user. + # Check {Y2Autoinstallation::AutoinstIssues::Issue} in order to + # find out more details about the kind of problems. + # + # About registering errors, an instance of the + # {Y2Autoinstallation::AutoinstIssues::List} will be used. + module AutoinstIssues + end +end + +require "autoinstall/autoinst_issues/list" +require "autoinstall/autoinst_issues/issue" +require "autoinstall/autoinst_issues/invalid_value" +require "autoinstall/autoinst_issues/missing_value" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/src/lib/autoinstall/autoinst_issues_presenter.rb new/autoyast2-4.0.52/src/lib/autoinstall/autoinst_issues_presenter.rb --- old/autoyast2-4.0.49/src/lib/autoinstall/autoinst_issues_presenter.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-4.0.52/src/lib/autoinstall/autoinst_issues_presenter.rb 2018-05-04 16:23:04.000000000 +0200 @@ -0,0 +1,133 @@ +# encoding: utf-8 + +# 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. + +Yast.import "HTML" +Yast.import "RichText" + +module Y2Autoinstallation + + # FIXME merge this class with StorageProposalIssuesPresenter class. + + # This class converts a list of issues into a message to be shown to users + # + # The message will summarize the list of issues, separating them into non-fatal + # and fatal issues. + class AutoinstIssuesPresenter + include Yast::I18n + + # @return [Y2Autoinstallation::AutoinstIssues::List] List of issues + attr_reader :issues_list + + # Constructor + # + # @param issues_list [Y2Autoinstallation::AutoinstIssues::List] List of issues + def initialize(issues_list) + textdomain "autoinst" + @issues_list = issues_list + end + + # Return the text to be shown to the user regarding the list of issues + # + # @return [String] Plain text + def to_plain + Yast::RichText.Rich2Plain(to_html) + end + + # Return the text to be shown to the user regarding the list of issues + # + # @return [String] HTML formatted text + def to_html + fatal, non_fatal = issues_list.partition(&:fatal?) + + parts = [] + parts << error_text(fatal) unless fatal.empty? + parts << warning_text(non_fatal) unless non_fatal.empty? + parts << Yast::HTML.Newline + + parts << + if fatal.empty? + _("Do you want to continue?") + else + _("Please, correct these problems and try again.") + end + + parts.join + end + + # Return warning message with a list of issues + # + # @param issues [ArrayY2Autoinstallation::AutoinstIssues::Issue] Array containing issues + # @return [String] Message + def warning_text(issues) + Yast::HTML.Para( + _("Minor issues have been detected while reading AutoYaST configuration file:") + ) + issues_list_content(issues) + end + + # Return error message with a list of issues + # + # @param issues [ArrayY2Autoinstallation::AutoinstIssues::Issue] Array containing issues + # @return [String] Message + def error_text(issues) + Yast::HTML.Para( + _("Important issues have been detected while reading AutoYaST configuration file:") + ) + issues_list_content(issues) + end + + # Return an HTML representation for a list of issues + # + # The issues are grouped by the section of the profile where they were detected. + # General issues (with no section) are listed first. + # + # @return [String] Issues list content + # + # @see issues_by_section + def issues_list_content(issues) + all_issues = [] + issues_map = issues_by_section(issues) + + if issues_map[:nosection] + all_issues += issues_map[:nosection].map(&:message) + issues_map.delete(:nosection) + end + + issues_map.each do |section, items| + messages = Yast::HTML.List(items.map(&:message)) + all_issues << "#{section}:#{messages}" + end + + Yast::HTML.List(all_issues) + end + + # Return issues grouped by section where they were found + # + # @return [Hash<(#parent,#section_name),Y2Storage::AutoinstIssues::Issue>] + # Issues grouped by AutoYaST profile section + def issues_by_section(issues) + issues.each_with_object({}) do |issue, all| + section = issue.section || :nosection + all[section] ||= [] + all[section] << issue + end + end + + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/src/lib/autoinstall/dialogs/question.rb new/autoyast2-4.0.52/src/lib/autoinstall/dialogs/question.rb --- old/autoyast2-4.0.49/src/lib/autoinstall/dialogs/question.rb 2018-04-23 11:08:21.000000000 +0200 +++ new/autoyast2-4.0.52/src/lib/autoinstall/dialogs/question.rb 2018-05-04 16:23:04.000000000 +0200 @@ -46,10 +46,12 @@ # Constructor # + # @param headline [String] Dialog's headline # @param content [String] Dialog's content # @param timeout [Integer] Countdown (in seconds); 0 means no timeout. # @param buttons_set [Symbol] Buttons set (:abort, :question) - def initialize(content, timeout: 10, buttons_set: :question) + def initialize(headline, content, timeout: 10, buttons_set: :question) + @headline = headline @content = content @remaining_time = timeout @timed = timeout > 0 @@ -65,7 +67,7 @@ VSpacing(20), VBox( HSpacing(70), - Left(Heading("Partitioning issues")), + Left(Heading(@headline)), VSpacing(1), RichText(content), timed? ? ReplacePoint(Id(:counter_replace), counter) : Empty(), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/src/modules/AutoInstall.rb new/autoyast2-4.0.52/src/modules/AutoInstall.rb --- old/autoyast2-4.0.49/src/modules/AutoInstall.rb 2018-04-23 11:08:21.000000000 +0200 +++ new/autoyast2-4.0.52/src/modules/AutoInstall.rb 2018-05-04 16:23:04.000000000 +0200 @@ -8,11 +8,16 @@ # $Id$ require "yast" require "autoinstall/pkg_gpg_check_handler" +require "autoinstall/autoinst_issues" +require "autoinstall/autoinst_issues_presenter" module Yast class AutoInstallClass < Module include Yast::Logger + # @return [AutoinstIssues::AutoinstIssues::List] AutoYaST issues list + attr_accessor :issues_list + def main textdomain "autoinst" @@ -25,6 +30,8 @@ Yast.import "TFTP" @autoconf = false + @issues_list = Y2Autoinstallation::AutoinstIssues::List.new + AutoInstall() end @@ -330,6 +337,43 @@ accept ? "I" : "" end + # Checking for valid imported values and there is an fatal error + # we will stop the installation. + # + # @return [Boolean] True if the proposal is valid or the user accepted an invalid one. + def valid_imported_values + return true if @issues_list.empty? + + report_settings = Report.Export + if @issues_list.fatal? + # On fatal errors, the message should be displayed + level = :error + buttons_set = :abort + display_message = true + log_message = report_settings["errors"]["log"] + timeout = report_settings["errors"]["timeout"] + else + # On non-fatal issues, obey report settings for warnings + level = :warn + buttons_set = :question + display_message = report_settings["warnings"]["show"] + log_message = report_settings["warnings"]["log"] + timeout = report_settings["warnings"]["timeout"] + end + + presenter = Y2Autoinstallation::AutoinstIssuesPresenter.new(@issues_list) + log.send(level, presenter.to_plain) if log_message + return true unless display_message + + dialog = Y2Autoinstallation::Dialogs::Question.new( + _("AutoYaST configuration file check"), + presenter.to_html, + timeout: timeout, + buttons_set: buttons_set + ) + dialog.run == :ok + end + publish :variable => :autoconf, :type => "boolean" publish :function => :callbackTrue_boolean_string, :type => "boolean (string)" publish :function => :callbackFalse_boolean_string, :type => "boolean (string)" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/src/modules/AutoinstStorage.rb new/autoyast2-4.0.52/src/modules/AutoinstStorage.rb --- old/autoyast2-4.0.49/src/modules/AutoinstStorage.rb 2018-04-23 11:08:21.000000000 +0200 +++ new/autoyast2-4.0.52/src/modules/AutoinstStorage.rb 2018-05-04 16:23:04.000000000 +0200 @@ -7,6 +7,7 @@ # # $Id$ require "yast" +require "y2storage" require "autoinstall/storage_proposal" require "autoinstall/dialogs/question" require "autoinstall/storage_proposal_issues_presenter" @@ -56,6 +57,7 @@ # @return [Boolean] success def Import(settings) log.info "entering Import with #{settings.inspect}" + return false unless available_storage? partitioning = preprocessed_settings(settings) return false unless partitioning @@ -78,12 +80,6 @@ self.general_settings = settings.clone - # Backward compatibility - if general_settings["btrfs_set_default_subvolume_name"] == false - general_settings["btrfs_default_subvolume"] = "" - end - general_settings.delete("btrfs_set_default_subvolume_name") - # Override product settings from control file control_settings = Yast::ProductFeatures.GetSection("partitioning") || {} Yast::ProductFeatures.SetSection("partitioning", control_settings.merge(general_settings)) @@ -302,6 +298,7 @@ return true unless display_message dialog = Y2Autoinstallation::Dialogs::Question.new( + _("Partitioning issues"), presenter.to_html, timeout: timeout, buttons_set: buttons_set @@ -325,6 +322,20 @@ preprocessor = Y2Autoinstallation::PartitioningPreprocessor.new preprocessor.run(settings) end + + # Determine (and warn the user) no storage is available for installation + # + # @return [Boolean] true if there are devices for installation; false otherwise. + def available_storage? + probed = Y2Storage::StorageManager.instance.probed + return true if probed && !probed.empty? + Yast::Popup.Error( + _("No storage devices were found for the installation.\n" \ + "Please, check your hardware or your AutoYaST profile.") + ) + false + end + end AutoinstStorage = AutoinstStorageClass.new diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/test/AutoInstall_test.rb new/autoyast2-4.0.52/test/AutoInstall_test.rb --- old/autoyast2-4.0.49/test/AutoInstall_test.rb 2018-04-23 11:08:21.000000000 +0200 +++ new/autoyast2-4.0.52/test/AutoInstall_test.rb 2018-05-04 16:23:04.000000000 +0200 @@ -1,11 +1,14 @@ #!/usr/bin/env rspec require_relative "test_helper" +require "autoinstall/autoinst_issues" +require "autoinstall/autoinst_issues_presenter" +require "autoinstall/dialogs/question" Yast.import "AutoInstall" +Yast.import "UI" describe "Yast::AutoInstall" do - subject { Yast::AutoInstall } describe "#pkg_gpg_check" do @@ -35,4 +38,25 @@ end end end + + describe "#valid_imported_values" do + before(:each) do + subject.issues_list = Y2Autoinstallation::AutoinstIssues::List.new + end + + context "when no issue has been found" do + it "returns true" do + expect(subject.valid_imported_values).to eq(true) + end + end + + context "when an issue has been found" do + it "shows a popup" do + subject.issues_list.add(:invalid_value, "firewall", "FW_DEV_INT", "1", + _("Is not supported anymore.")) + expect_any_instance_of(Y2Autoinstallation::Dialogs::Question).to receive(:run).and_return(:ok) + expect(subject.valid_imported_values).to eq(true) + end + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/test/AutoinstSoftware_test.rb new/autoyast2-4.0.52/test/AutoinstSoftware_test.rb --- old/autoyast2-4.0.49/test/AutoinstSoftware_test.rb 2018-04-23 11:08:21.000000000 +0200 +++ new/autoyast2-4.0.52/test/AutoinstSoftware_test.rb 2018-05-04 16:23:04.000000000 +0200 @@ -82,7 +82,6 @@ expect(Yast::Report).to_not receive(:Error) subject.SelectPackagesForInstallation() end - end describe "#locked_packages" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/test/autoinst_storage_test.rb new/autoyast2-4.0.52/test/autoinst_storage_test.rb --- old/autoyast2-4.0.49/test/autoinst_storage_test.rb 2018-04-23 11:08:21.000000000 +0200 +++ new/autoyast2-4.0.52/test/autoinst_storage_test.rb 2018-05-04 16:23:04.000000000 +0200 @@ -22,7 +22,15 @@ let(:warnings_settings) { { "show" => true, "timeout" => 5 } } let(:settings) { [{ "device" => "/dev/sda" }] } let(:ask_settings) { [{ "device" => "ask" }] } - let(:preprocessor) { instance_double(Y2Autoinstallation::PartitioningPreprocessor, run: settings) } + let(:preprocessor) do + instance_double(Y2Autoinstallation::PartitioningPreprocessor, run: settings) + end + let(:probed_devicegraph) do + instance_double(Y2Storage::Devicegraph, :empty? => false) + end + let(:storage_manager) do + instance_double(Y2Storage::StorageManager, probed: probed_devicegraph) + end before do allow(Y2Autoinstallation::StorageProposal).to receive(:new) @@ -32,6 +40,7 @@ allow(storage_proposal).to receive(:save) allow(Y2Autoinstallation::PartitioningPreprocessor).to receive(:new) .and_return(preprocessor) + allow(Y2Storage::StorageManager).to receive(:instance).and_return(storage_manager) end around do |example| @@ -84,7 +93,7 @@ it "shows errors to the user without timeout" do expect(Y2Autoinstallation::Dialogs::Question).to receive(:new) - .with(/Important issues/, timeout: 0, buttons_set: :abort) + .with("Partitioning issues", /Important issues/, timeout: 0, buttons_set: :abort) .and_return(issues_dialog) expect(issues_dialog).to receive(:run) subject.Import({}) @@ -128,7 +137,7 @@ context "and warnings reporting is enabled" do it "asks the user for confirmation" do expect(Y2Autoinstallation::Dialogs::Question).to receive(:new) - .with(/Minor issues/, timeout: 5, buttons_set: :question) + .with("Partitioning issues", /Minor issues/, timeout: 5, buttons_set: :question) .and_return(issues_dialog) expect(issues_dialog).to receive(:run) subject.Import({}) @@ -184,11 +193,41 @@ end end + + context "when there are no available storage for installation" do + before do + allow(probed_devicegraph).to receive(:empty?).and_return(true) + end + + it "displays an error" do + expect(Yast::Popup).to receive(:Error).with(/No storage devices/) + subject.Import({}) + end + + it "returns false" do + expect(subject.Import({})).to eq(false) + end + end + + context "when the probed devicegraph is nil" do + before do + allow(storage_manager).to receive(:probed).and_return(nil) + end + + it "displays an error" do + expect(Yast::Popup).to receive(:Error).with(/No storage devices/) + subject.Import({}) + end + + it "returns false" do + expect(subject.Import({})).to eq(false) + end + end end describe "#import_general_settings" do let(:profile) { { "proposal_lvm" => true } } - let(:partitioning_features) { {"btrfs_default_subvolume" => "@" } } + let(:partitioning_features) { {"foo" => "bar" } } around do |example| old_partitioning = Yast::ProductFeatures.GetSection("partitioning") @@ -204,38 +243,7 @@ it "keeps not overriden values" do subject.import_general_settings(profile) - expect(Yast::ProductFeatures.GetSection("partitioning")) - .to include("btrfs_default_subvolume" => "@") - end - - context "when btrfs default subvolume name is set to false" do - let(:profile) { { "btrfs_set_default_subvolume_name" => false } } - - it "disables the btrfs default subvolume" do - subject.import_general_settings(profile) - expect(Yast::ProductFeatures.GetSection("partitioning")) - .to include("btrfs_default_subvolume" => "") - end - end - - context "when btrfs default subvolume name is not set" do - let(:profile) { {} } - - it "uses the default for the product" do - subject.import_general_settings(profile) - expect(Yast::ProductFeatures.GetSection("partitioning")) - .to include("btrfs_default_subvolume" => "@") - end - end - - context "when btrfs default subvolume name is set to true" do - let(:profile) { { "btrfs_set_default_subvolume_name" => true } } - - it "uses the default for the product" do - subject.import_general_settings(profile) - expect(Yast::ProductFeatures.GetSection("partitioning")) - .to include("btrfs_default_subvolume" => "@") - end + expect(Yast::ProductFeatures.GetSection("partitioning")).to include("foo" => "bar") end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/test/lib/autoinst_issues/invalid_value_test.rb new/autoyast2-4.0.52/test/lib/autoinst_issues/invalid_value_test.rb --- old/autoyast2-4.0.49/test/lib/autoinst_issues/invalid_value_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-4.0.52/test/lib/autoinst_issues/invalid_value_test.rb 2018-05-04 16:23:04.000000000 +0200 @@ -0,0 +1,45 @@ +#!/usr/bin/env rspec +# encoding: utf-8 + +# 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. + +require_relative '../../test_helper.rb' +require 'autoinstall/autoinst_issues/invalid_value' + +describe Y2Autoinstallation::AutoinstIssues::InvalidValue do + subject(:issue) do + described_class.new('firewall', 'interfaces', 'eth0', + 'This interface has been defined for more than one zone.', :fatal) + end + + describe '#message' do + it 'includes relevant information' do + message = issue.message + expect(message).to include 'interfaces' + expect(message).to include 'eth0' + end + end + + describe '#severity which has been set to :fatal while initialization' do + it 'returns :fatal' do + expect(issue.severity).to eq(:fatal) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/test/lib/autoinst_issues/issue_test.rb new/autoyast2-4.0.52/test/lib/autoinst_issues/issue_test.rb --- old/autoyast2-4.0.49/test/lib/autoinst_issues/issue_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-4.0.52/test/lib/autoinst_issues/issue_test.rb 2018-05-04 16:23:04.000000000 +0200 @@ -0,0 +1,84 @@ +#!/usr/bin/env rspec +# encoding: utf-8 + +# 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. + +require_relative '../../test_helper.rb' +require 'autoinstall/autoinst_issues/missing_value' + +describe Y2Autoinstallation::AutoinstIssues::Issue do + subject(:issue) { described_class.new } + + describe '#message' do + it 'raises a NotImplementedError exception' do + expect { issue.message }.to raise_error(NotImplementedError) + end + end + + describe '#severity' do + it 'returns :warn as default value' do + expect(issue.severity).to eq(:warn) + end + end + + describe '#warn?' do + before do + allow(issue).to receive(:severity).and_return(severity) + end + + context 'when severity is :warn' do + let(:severity) { :warn } + + it 'returns true' do + expect(issue).to be_warn + end + end + + context 'when severity is not :warn' do + let(:severity) { :fatal } + + it 'returns false' do + expect(issue).to_not be_warn + end + end + end + + describe '#fatal?' do + before do + allow(issue).to receive(:severity).and_return(severity) + end + + context 'when severity is :fatal' do + let(:severity) { :fatal } + + it 'returns true' do + expect(issue).to be_fatal + end + end + + context 'when severity is not :fatal' do + let(:severity) { :warn } + + it 'returns false' do + expect(issue).to_not be_fatal + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/test/lib/autoinst_issues/list_test.rb new/autoyast2-4.0.52/test/lib/autoinst_issues/list_test.rb --- old/autoyast2-4.0.49/test/lib/autoinst_issues/list_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-4.0.52/test/lib/autoinst_issues/list_test.rb 2018-05-04 16:23:04.000000000 +0200 @@ -0,0 +1,98 @@ +#!/usr/bin/env rspec +# encoding: utf-8 + +# 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. + +require_relative '../../test_helper.rb' +require 'autoinstall/autoinst_issues/list' +require 'autoinstall/autoinst_issues/invalid_value' +require 'autoinstall/autoinst_issues/missing_value' + +describe Y2Autoinstallation::AutoinstIssues::List do + subject(:list) { described_class.new } + + describe '#add' do + it 'adds a new issue to the list' do + list.add(:missing_value, 'foo', 'bar') + expect(list.to_a).to all(be_an(Y2Autoinstallation::AutoinstIssues::MissingValue)) + end + + it 'pass extra arguments to issue instance constructor' do + expect(Y2Autoinstallation::AutoinstIssues::InvalidValue) + .to receive(:new).with('firewall', 'interfaces', 'eth0', + _('This interface has been defined for more than one zone.')) + list.add(:invalid_value, 'firewall', 'interfaces', 'eth0', + _('This interface has been defined for more than one zone.')) + end + end + + describe '#to_a' do + context 'when list is empty' do + it 'returns an empty array' do + expect(list.to_a).to eq([]) + end + end + + context 'when some issue was added' do + before do + 2.times { list.add(:missing_value, 'foo', 'bar') } + end + + it 'returns an array containing added issues' do + expect(list.to_a).to all(be_a(Y2Autoinstallation::AutoinstIssues::MissingValue)) + expect(list.to_a.size).to eq(2) + end + end + end + + describe '#empty?' do + context 'when list is empty' do + it 'returns true' do + expect(list).to be_empty + end + end + + context 'when some issue was added' do + before { list.add(:missing_value, 'foo', 'bar') } + + it 'returns false' do + expect(list).to_not be_empty + end + end + end + + describe '#fatal?' do + context 'when contains some fatal error' do + before { list.add(:missing_value, 'foo', 'bar', 'descritption', :fatal) } + + it 'returns true' do + expect(list).to be_fatal + end + end + + context 'when contains no fatal error' do + before { list.add(:missing_value, 'foo', 'bar', 'descritption', :warn) } + + it 'returns false' do + expect(list).to_not be_fatal + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/test/lib/autoinst_issues/missing_value_test.rb new/autoyast2-4.0.52/test/lib/autoinst_issues/missing_value_test.rb --- old/autoyast2-4.0.49/test/lib/autoinst_issues/missing_value_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-4.0.52/test/lib/autoinst_issues/missing_value_test.rb 2018-05-04 16:23:04.000000000 +0200 @@ -0,0 +1,40 @@ +#!/usr/bin/env rspec +# encoding: utf-8 + +# 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. + +require_relative '../../test_helper.rb' +require 'autoinstall/autoinst_issues/missing_value' + +describe Y2Autoinstallation::AutoinstIssues::MissingValue do + subject(:issue) { described_class.new('foo', 'bar') } + + describe '#message' do + it 'returns a description of the issue' do + expect(issue.message).to match(/Missing element 'bar'/) + end + end + + describe '#severity' do + it 'returns :warn as default' do + expect(issue.severity).to eq(:warn) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/test/lib/autoinst_issues_presenter_test.rb new/autoyast2-4.0.52/test/lib/autoinst_issues_presenter_test.rb --- old/autoyast2-4.0.49/test/lib/autoinst_issues_presenter_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/autoyast2-4.0.52/test/lib/autoinst_issues_presenter_test.rb 2018-05-04 16:23:04.000000000 +0200 @@ -0,0 +1,101 @@ +#!/usr/bin/env rspec +# encoding: utf-8 + +# 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. + +require_relative '../test_helper' +require 'autoinstall/autoinst_issues' +require 'autoinstall/autoinst_issues_presenter' + +describe Y2Autoinstallation::AutoinstIssuesPresenter do + subject(:presenter) { described_class.new(list) } + + let(:list) { Y2Autoinstallation::AutoinstIssues::List.new } + + describe '#to_html' do + context 'when a fatal issue was found' do + before do + list.add(:missing_value, 'foo', 'bar', + 'The installer is trying to evaluate bar.', + :fatal) + end + + it 'includes issues messages' do + issue = list.first + expect(presenter.to_html.to_s).to include "<li>#{issue.message}</li>" + end + + it 'includes an introduction to fatal issues list' do + expect(presenter.to_html.to_s).to include '<p>Important issues' + end + end + + context 'when a non fatal issue was found' do + before do + list.add(:invalid_value, 'firewall', 'interfaces', 'eth0', + 'This interface has been defined for more than one zone.') + end + + it 'includes issues messages' do + issue = list.first + expect(presenter.to_html.to_s).to include "<li>#{issue.message}</li>" + end + + it 'includes an introduction to non fatal issues list' do + expect(presenter.to_html.to_s).to include '<p>Minor issues' + end + end + end + + describe '#to_plain' do + context 'when a fatal issue was found' do + before do + list.add(:missing_value, 'foo', 'bar', + 'The installer is trying to evaluate bar.', + :fatal) + end + + it 'includes issues messages' do + issue = list.first + expect(presenter.to_plain.to_s).to include "* #{issue.message}" + end + + it 'includes an introduction to fatal issues list' do + expect(presenter.to_plain.to_s).to include 'Important issues' + end + end + + context 'when a non fatal issue was found' do + before do + list.add(:invalid_value, 'firewall', 'interfaces', 'eth0', + 'This interface has been defined for more than one zone.') + end + + it 'includes issues messages' do + issue = list.first + expect(presenter.to_plain.to_s).to include "* #{issue.message}" + end + + it 'includes an introduction to non fatal issues list' do + expect(presenter.to_plain.to_s).to include 'Minor issues' + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.0.49/test/lib/dialogs/question_test.rb new/autoyast2-4.0.52/test/lib/dialogs/question_test.rb --- old/autoyast2-4.0.49/test/lib/dialogs/question_test.rb 2018-04-23 11:08:21.000000000 +0200 +++ new/autoyast2-4.0.52/test/lib/dialogs/question_test.rb 2018-05-04 16:23:04.000000000 +0200 @@ -25,10 +25,11 @@ require "y2storage/autoinst_issues" describe Y2Autoinstallation::Dialogs::Question do - subject(:dialog) { described_class.new(content, timeout: timeout, buttons_set: buttons_set) } + subject(:dialog) { described_class.new(headline, content, timeout: timeout, buttons_set: buttons_set) } let(:timeout) { 0 } let(:content) { "some content" } + let(:headline) { "some headline" } let(:buttons_set) { :abort } before do