Hello community, here is the log from the commit of package autoyast2 for openSUSE:Factory checked in at 2020-07-24 09:53:32 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/autoyast2 (Old) and /work/SRC/openSUSE:Factory/.autoyast2.new.3592 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "autoyast2" Fri Jul 24 09:53:32 2020 rev:283 rq:822367 version:4.3.30 Changes: -------- --- /work/SRC/openSUSE:Factory/autoyast2/autoyast2.changes 2020-07-21 15:49:05.600199452 +0200 +++ /work/SRC/openSUSE:Factory/.autoyast2.new.3592/autoyast2.changes 2020-07-24 09:54:36.369319852 +0200 @@ -1,0 +2,14 @@ +Thu Jul 23 09:36:37 UTC 2020 - Josef Reidinger <[email protected]> + +- handle properly exceptions from new XML parser/serializer + (related to bsc#1171412) +- 4.3.30 + +------------------------------------------------------------------- +Tue Jul 21 19:24:34 UTC 2020 - Imobach Gonzalez Sosa <[email protected]> + +- Do not crash when the networking section is missing + (bsc#1174118). +- 4.3.29 + +------------------------------------------------------------------- Old: ---- autoyast2-4.3.28.tar.bz2 New: ---- autoyast2-4.3.30.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ autoyast2.spec ++++++ --- /var/tmp/diff_new_pack.dpcD5G/_old 2020-07-24 09:54:37.601321123 +0200 +++ /var/tmp/diff_new_pack.dpcD5G/_new 2020-07-24 09:54:37.601321123 +0200 @@ -22,7 +22,7 @@ %endif Name: autoyast2 -Version: 4.3.28 +Version: 4.3.30 Release: 0 Summary: YaST2 - Automated Installation License: GPL-2.0-only @@ -229,9 +229,6 @@ %{yast_yncludedir}/autoinstall/tree.rb %{yast_yncludedir}/autoinstall/types.rb -%dir %{yast_controldir} -%{yast_controldir}/*.xml - %{yast_moduledir}/AutoInstall.rb %{yast_moduledir}/AutoinstScripts.rb %{yast_moduledir}/AutoinstGeneral.rb @@ -255,8 +252,6 @@ %{yast_clientdir}/inst_autoconfigure.rb %{yast_clientdir}/inst_autopost.rb %{yast_clientdir}/files_auto.rb -%{yast_clientdir}/autoinst_test_clone.rb -%{yast_clientdir}/autoinst_test_stage.rb %{yast_clientdir}/autoinst_scripts1_finish.rb %{yast_clientdir}/autoinst_scripts2_finish.rb %{yast_clientdir}/ayast_probe.rb ++++++ autoyast2-4.3.28.tar.bz2 -> autoyast2-4.3.30.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/control/control_continue_autoyast.xml new/autoyast2-4.3.30/control/control_continue_autoyast.xml --- old/autoyast2-4.3.28/control/control_continue_autoyast.xml 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/control/control_continue_autoyast.xml 1970-01-01 01:00:00.000000000 +0100 @@ -1,39 +0,0 @@ -<?xml version="1.0"?> -<!-- Use /usr/share/YaST2/control/control.rng file for validation --> -<!-- Command: 'xmllint -noout -relaxng /usr/share/YaST2/control/control.rng dirinstall.xml' --> -<productDefines xmlns="http://www.suse.com/1.0/yast2ns" - xmlns:config="http://www.suse.com/1.0/configns"> - -<!-- -Work around for the text domain -textdomain="control" ---> - - <textdomain>control</textdomain> - - <workflows config:type="list"> - <workflow> - <defaults> - <arguments>false,false</arguments> - <archs>all</archs> - </defaults> - <stage>continue</stage> - <label>Configuration</label> - <mode>autoinstallation</mode> - <modules config:type="list"> - <module> - <name>inst_autopost</name> - </module> - <module> - <label>System Configuration</label> - <name>inst_autoconfigure</name> - </module> - <module> - <label>System Configuration</label> - <name>inst_x11</name> - <arguments>false,false</arguments> - </module> - </modules> - </workflow> - </workflows> -</productDefines> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/package/autoyast2.changes new/autoyast2-4.3.30/package/autoyast2.changes --- old/autoyast2-4.3.28/package/autoyast2.changes 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/package/autoyast2.changes 2020-07-23 13:16:06.000000000 +0200 @@ -1,4 +1,18 @@ ------------------------------------------------------------------- +Thu Jul 23 09:36:37 UTC 2020 - Josef Reidinger <[email protected]> + +- handle properly exceptions from new XML parser/serializer + (related to bsc#1171412) +- 4.3.30 + +------------------------------------------------------------------- +Tue Jul 21 19:24:34 UTC 2020 - Imobach Gonzalez Sosa <[email protected]> + +- Do not crash when the networking section is missing + (bsc#1174118). +- 4.3.29 + +------------------------------------------------------------------- Mon Jul 20 14:51:49 UTC 2020 - Josef Reidinger <[email protected]> - Fix fallback for autoyast client name (bsc#1174119) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/package/autoyast2.spec new/autoyast2-4.3.30/package/autoyast2.spec --- old/autoyast2-4.3.28/package/autoyast2.spec 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/package/autoyast2.spec 2020-07-23 13:16:06.000000000 +0200 @@ -22,7 +22,7 @@ %endif Name: autoyast2 -Version: 4.3.28 +Version: 4.3.30 Release: 0 Summary: YaST2 - Automated Installation License: GPL-2.0-only @@ -229,9 +229,6 @@ %{yast_yncludedir}/autoinstall/tree.rb %{yast_yncludedir}/autoinstall/types.rb -%dir %{yast_controldir} -%{yast_controldir}/*.xml - %{yast_moduledir}/AutoInstall.rb %{yast_moduledir}/AutoinstScripts.rb %{yast_moduledir}/AutoinstGeneral.rb @@ -255,8 +252,6 @@ %{yast_clientdir}/inst_autoconfigure.rb %{yast_clientdir}/inst_autopost.rb %{yast_clientdir}/files_auto.rb -%{yast_clientdir}/autoinst_test_clone.rb -%{yast_clientdir}/autoinst_test_stage.rb %{yast_clientdir}/autoinst_scripts1_finish.rb %{yast_clientdir}/autoinst_scripts2_finish.rb %{yast_clientdir}/ayast_probe.rb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/src/clients/autoinst_test_clone.rb new/autoyast2-4.3.30/src/clients/autoinst_test_clone.rb --- old/autoyast2-4.3.28/src/clients/autoinst_test_clone.rb 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/src/clients/autoinst_test_clone.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,39 +0,0 @@ -module Yast - class AutoinstTestCloneClient < Client - def main - textdomain "autoinst" - Yast.import "XML" - Yast.import "Wizard" - Yast.import "Popup" - Yast.import "Mode" - Mode.SetMode("autoinst_config") - Yast.include self, "autoinstall/xml.rb" - Wizard.CreateDialog - Popup.ShowFeedback( - _("Reading configuration data..."), - _("This may take a while") - ) - - profileSetup - @client = "" - - if Ops.greater_than(Builtins.size(WFM.Args), 0) && - Ops.is_string?(WFM.Args(0)) - @client = Convert.to_string(WFM.Args(0)) - end - - WFM.CallFunction(Ops.add(@client, "_auto"), ["Read"]) - @result = WFM.CallFunction(Ops.add(@client, "_auto"), ["Export"]) - @current = {} - Ops.set(@current, @client, @result) - XML.YCPToXMLFile(:profile, @current, Ops.add(@client, ".xml")) - Popup.ClearFeedback - - Wizard.CloseDialog - - nil - end - end -end - -Yast::AutoinstTestCloneClient.new.main diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/src/clients/autoinst_test_stage.rb new/autoyast2-4.3.30/src/clients/autoinst_test_stage.rb --- old/autoyast2-4.3.28/src/clients/autoinst_test_stage.rb 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/src/clients/autoinst_test_stage.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,59 +0,0 @@ -# This client starts a custom autoinstallation workflow using -# a stripped down control file and an autoyast profile. -# first argument is the autoyast profile, second is the workflow -# control file. -# see a test workflow control file in the same directory -module Yast - class AutoinstTestStageClient < Client - def main - Yast.import "UI" - Yast.import "Pkg" - Yast.import "XML" - Yast.import "Profile" - Yast.import "AutoInstall" - Yast.import "ProductControl" - - Yast.import "Wizard" - Yast.import "Popup" - Yast.import "Mode" - Yast.import "Stage" - - Mode.SetMode("autoinstallation") - Stage.Set("continue") - - @control = "" - @profile = "" - if Ops.greater_than(Builtins.size(WFM.Args), 0) && - Ops.is_string?(WFM.Args(0)) && - Ops.is_string?(WFM.Args(1)) - @profile = Convert.to_string(WFM.Args(0)) - @control = Convert.to_string(WFM.Args(1)) - end - - ProductControl.custom_control_file = @control - if !ProductControl.Init - Builtins.y2error( - "control file %1 not found", - ProductControl.custom_control_file - ) - return :abort - end - - Profile.ReadXML(@profile) - - Wizard.OpenNextBackStepsDialog - @stage_mode = [{ "stage" => "continue", "mode" => Mode.mode }] - ProductControl.AddWizardSteps(@stage_mode) - - @ret = ProductControl.Run - - Pkg.SourceFinishAll - Pkg.TargetFinish - - UI.CloseDialog - @ret - end - end -end - -Yast::AutoinstTestStageClient.new.main diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/src/include/autoinstall/classes.rb new/autoyast2-4.3.30/src/include/autoinstall/classes.rb --- old/autoyast2-4.3.28/src/include/autoinstall/classes.rb 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/src/include/autoinstall/classes.rb 2020-07-23 13:16:06.000000000 +0200 @@ -17,6 +17,7 @@ # XML_cleanup() # @return [Boolean] def XML_cleanup(_in, out) + # Note, inputs should be already valid, so exceptions is not handled here ycpin = XML.XMLToYCPFile(_in) Builtins.y2debug("Writing clean XML file to %1, YCP is (%2)", out, ycpin) XML.YCPToXMLFile(:profile, ycpin, out) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/src/include/autoinstall/conftree.rb new/autoyast2-4.3.30/src/include/autoinstall/conftree.rb --- old/autoyast2-4.3.28/src/include/autoinstall/conftree.rb 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/src/include/autoinstall/conftree.rb 2020-07-23 13:16:06.000000000 +0200 @@ -431,7 +431,16 @@ # Show Source def ShowSource Profile.Prepare - source = XML.YCPToXMLString(:profile, Profile.current) + begin + source = XML.YCPToXMLString(:profile, Profile.current) + rescue XMLSerializationError => e + Builtins.y2error "Creation of XML failed with #{e.inspect}" + Popup.Error( + _("An error occurred while creating XML Sources.") + ) + source = "" + end + sourceView = RichText(Id(:class_source), Opt(:plainText), source) Wizard.SetTitleIcon("autoyast") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/src/lib/autoinstall/autosetup_helpers.rb new/autoyast2-4.3.30/src/lib/autoinstall/autosetup_helpers.rb --- old/autoyast2-4.3.28/src/lib/autoinstall/autosetup_helpers.rb 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/src/lib/autoinstall/autosetup_helpers.rb 2020-07-23 13:16:06.000000000 +0200 @@ -126,23 +126,13 @@ # Prevent to be called twice in case of already configured return if @network_configured - if Yast::Profile.current["networking"] - if network_before_proposal? - log.info("Networking setup before the proposal") - else - log.info("Networking setup at the end of first installation stage") - end - - log.info("Importing Network settings from configuration file") - Yast::WFM.CallFunction("lan_auto", ["Import", Yast::Profile.current["networking"]]) - Yast::Profile.remove_sections("networking") - - # Import also the host section in order to resolve hosts only available - # with the network configuration and the host entry - if Yast::Profile.current["host"] && network_before_proposal? - Yast::WFM.CallFunction("host_auto", ["Import", Yast::Profile.current["host"]]) - Yast::Profile.remove_sections("host") - end + networking_section = Yast::Profile.current.fetch("networking", {}) + Yast::WFM.CallFunction("lan_auto", ["Import", networking_section]) + + # Import also the host section in order to resolve hosts only available + # with the network configuration and the host entry + if Yast::Profile.current["host"] + Yast::WFM.CallFunction("host_auto", ["Import", Yast::Profile.current["host"]]) end if semi_auto?("networking") @@ -151,7 +141,12 @@ @network_before_proposal = true end + log.info("Networking setup before the proposal: #{network_before_proposal?}") Yast::WFM.CallFunction("lan_auto", ["Write"]) if network_before_proposal? + + # Clean-up the profile + Yast::Profile.remove_sections(["networking", "host"]) + @network_configured = true end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/src/lib/autoinstall/clients/clone_system.rb new/autoyast2-4.3.30/src/lib/autoinstall/clients/clone_system.rb --- old/autoyast2-4.3.28/src/lib/autoinstall/clients/clone_system.rb 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/src/lib/autoinstall/clients/clone_system.rb 2020-07-23 13:16:06.000000000 +0200 @@ -152,7 +152,14 @@ Yast::ProductControl.clone_modules + ["general"] end Yast::AutoinstClone.Process(target: target) - Yast::XML.YCPToXMLFile(:profile, Yast::Profile.current, filename) + begin + Yast::XML.YCPToXMLFile(:profile, Yast::Profile.current, filename) + rescue Yast::XMLSerializationError => e + log.error "Creation of XML failed with #{e.inspect}" + Yast::Popup.Error( + _("Could not create the XML file. Please, report a bug.") + ) + end Yast::Popup.ClearFeedback true end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/src/modules/AutoInstallRules.rb new/autoyast2-4.3.30/src/modules/AutoInstallRules.rb --- old/autoyast2-4.3.28/src/modules/AutoInstallRules.rb 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/src/modules/AutoInstallRules.rb 2020-07-23 13:16:06.000000000 +0200 @@ -426,11 +426,12 @@ # Read rules file # @return [void] def Read - @UserRules = XML.XMLToYCPFile(AutoinstConfig.local_rules_file) - - if @UserRules.nil? + begin + @UserRules = XML.XMLToYCPFile(AutoinstConfig.local_rules_file) + rescue XMLDeserializationError => e message = _("Parsing the rules file failed. XML parser reports:\n") - Popup.Error(Ops.add(message, XML.XMLError)) + Popup.Error(message + e.message) + @UserRules = nil end Builtins.y2milestone("Rules: %1", @UserRules) @@ -772,12 +773,12 @@ ) end end - Builtins.foreach(conflictsCounter) do |e, v| + Builtins.foreach(conflictsCounter) do |key, v| if Ops.greater_than(v, 0) - UI.ChangeWidget(Id(e), :Enabled, false) - UI.ChangeWidget(Id(e), :Value, false) + UI.ChangeWidget(Id(key), :Enabled, false) + UI.ChangeWidget(Id(key), :Value, false) else - UI.ChangeWidget(Id(e), :Enabled, true) + UI.ChangeWidget(Id(key), :Enabled, true) end end end @@ -904,13 +905,15 @@ end dest_profile = (iter == 0) ? base_profile : cleaned_profile - if !XML_cleanup(current_profile, dest_profile) - log.error("Error reading XML file") + begin + XML_cleanup(current_profile, dest_profile) + rescue XMLDeserializationError => e + log.error("Error reading XML file: #{e.inspect}") message = _( "The XML parser reported an error while parsing the autoyast profile. " \ "The error message is:\n" ) - message += XML.XMLError + message += e.message Yast2::Popup.show(message, headline: :error) error = true end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/src/modules/AutoinstClass.rb new/autoyast2-4.3.30/src/modules/AutoinstClass.rb --- old/autoyast2-4.3.28/src/modules/AutoinstClass.rb 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/src/modules/AutoinstClass.rb 2020-07-23 13:16:06.000000000 +0200 @@ -53,10 +53,13 @@ def Read if SCR.Read(path(".target.size"), @classPath) != -1 && Y2Autoinstallation::XmlChecks.valid_classes?(@classPath) - - # TODO: use XML module - classes_map = Convert.to_map(SCR.Read(path(".xml"), @classPath)) - @Classes = (classes_map && classes_map["classes"]) || [] + begin + classes_map = XML.XMLToYCPFile(@classPath) + @Classes = (classes_map && classes_map["classes"]) || [] + rescue XMLDeserializationError => e + log.error "failed to parse classes xml file #{e.inspect}" + @Classes = [] + end else @Classes = [] end @@ -74,6 +77,8 @@ XML.YCPToXMLFile(:class, new_classes_map, @classPath) end nil + rescue XMLSerializationError => e + log.error "Failed to compact object #{e.inspect}" end # Changes the directory and reads the class definitions @@ -164,6 +169,9 @@ tmp = { "classes" => @Classes } log.debug "saving classes: #{@classPath}" XML.YCPToXMLFile(:class, tmp, @classPath) + rescue XMLSerializationError => e + log.error "Failed to save object #{e.inspect}" + false end # Imports configuration diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/src/modules/Profile.rb new/autoyast2-4.3.30/src/modules/Profile.rb --- old/autoyast2-4.3.28/src/modules/Profile.rb 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/src/modules/Profile.rb 2020-07-23 13:16:06.000000000 +0200 @@ -357,15 +357,20 @@ end end else - ret = XML.YCPToXMLFile(:profile, @current, file) + XML.YCPToXMLFile(:profile, @current, file) + ret = true end ret + rescue XMLSerializationError => e + log.error "Failed to serialize objects: #{e.inspect}" + false end # Save sections of current profile to separate files # # @param [String] dir - directory to store section xml files in - # @return - list of filenames + # @return [Hash<String,String>] returns map with section name and respective file where + # it is serialized def SaveSingleSections(dir) Prepare() Builtins.y2milestone("Saving data (%1) to XML single files", @current) @@ -376,7 +381,8 @@ ".xml" ) tmpProfile = { sectionName => section } - if XML.YCPToXMLFile(:profile, tmpProfile, sectionFileName) + begin + XML.YCPToXMLFile(:profile, tmpProfile, sectionFileName) Builtins.y2milestone( "Wrote section %1 to file %2", sectionName, @@ -387,14 +393,9 @@ sectionName, sectionFileName ) - else - Builtins.y2error( - Builtins.sformat( - _("Could not write section %1 to file %2."), - sectionName, - sectionFileName - ) - ) + rescue XMLSerializationError => e + log.error "Could not write section #{sectionName} to file #{sectionFileName}:" \ + "#{e.inspect}" end end deep_copy(sectionFiles) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/test/AutoInstallRules_test.rb new/autoyast2-4.3.30/test/AutoInstallRules_test.rb --- old/autoyast2-4.3.28/test/AutoInstallRules_test.rb 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/test/AutoInstallRules_test.rb 2020-07-23 13:16:06.000000000 +0200 @@ -115,7 +115,7 @@ end end - describe "#Rules XML" do + describe "#Read" do it "Reading rules with -or- operator" do expect(Yast::XML).to receive(:XMLToYCPFile).and_return( "rules" => [{ @@ -174,6 +174,13 @@ subject.Read end + + it "shows error Popup when xml is not valid" do + allow(Yast::XML).to receive(:XMLToYCPFile).and_raise(Yast::XMLDeserializationError) + expect(Yast::Popup).to receive(:Error) + + subject.Read + end end describe "#getNetwork" do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/test/AutoinstClass_test.rb new/autoyast2-4.3.30/test/AutoinstClass_test.rb --- old/autoyast2-4.3.28/test/AutoinstClass_test.rb 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/test/AutoinstClass_test.rb 2020-07-23 13:16:06.000000000 +0200 @@ -31,6 +31,20 @@ end end + context "when class definition is not valid" do + it "sets Classes to []" do + allow(Yast::XML).to receive(:XMLToYCPFile).and_raise(Yast::XMLDeserializationError) + subject.Read + expect(subject.Classes).to eq([]) + end + + it "returns nil" do + allow(Yast::XML).to receive(:XMLToYCPFile).and_raise(Yast::XMLDeserializationError) + expect(subject.Read).to be_nil + end + + end + context "when classes definition file does not exist" do before(:each) do allow(Yast::SCR).to receive(:Read).with(Yast::Path.new(".target.size"), CLASS_PATH) @@ -376,6 +390,12 @@ subject.Save end + it "does not raise exception when serialization failed" do + subject.Classes = nil + expect { subject.Save }.to_not raise_error + subject.Classes = [] + end + context "when classes are marked for deletion" do around(:each) do |example| subject.deletedClasses = ["swap"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/test/include/conftree_test.rb new/autoyast2-4.3.30/test/include/conftree_test.rb --- old/autoyast2-4.3.28/test/include/conftree_test.rb 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/test/include/conftree_test.rb 2020-07-23 13:16:06.000000000 +0200 @@ -20,6 +20,9 @@ require_relative "../test_helper" require "yast" +require "autoinstall/entries/registry" + +Yast.import "Profile" describe "Yast::AutoinstallConfTreeInclude" do class DummyClient < Yast::Client @@ -32,6 +35,27 @@ let(:subject) { DummyClient.new.tap(&:main) } + describe "#ShowSource" do + it "shows xml with current profile serialized to XML" do + allow(Yast::Profile).to receive(:Prepare) + allow(Yast::Profile).to receive(:current).and_return("test" => {}) + allow(Yast::Wizard).to receive(:SetTitleIcon) + expect(Yast::Wizard).to receive(:SetContents) + expect(Yast::Popup).to_not receive(:Error) + + subject.ShowSource + end + + it "shows error popup when profile serialization failed" do + allow(Yast::Profile).to receive(:Prepare) + allow(Yast::Profile).to receive(:current).and_return("test" => nil) + expect(Yast::Popup).to receive(:Error) + + subject.ShowSource + + end + end + describe "#configureModule" do let(:module_map) do { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/test/lib/autosetup_helpers_test.rb new/autoyast2-4.3.30/test/lib/autosetup_helpers_test.rb --- old/autoyast2-4.3.28/test/lib/autosetup_helpers_test.rb 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/test/lib/autosetup_helpers_test.rb 2020-07-23 13:16:06.000000000 +0200 @@ -241,7 +241,7 @@ end - describe "#network_autosetup" do + describe "#autosetup_network" do let(:profile) { networking_section } let(:networking_section) { { "networking" => { "setup_before_proposal" => true } } } let(:host_section) { { "host" => { "hosts" => [] } } } @@ -299,21 +299,33 @@ end it "sets the network config to be written before the proposal" do - expect { client.autosetup_network } - .to change { client.network_before_proposal? } - .from(false).to(true) + allow(Yast::WFM).to receive(:CallFunction).with("inst_lan", anything) + expect(Yast::WFM).to receive(:CallFunction).with("lan_auto", ["Write"]) + + client.autosetup_network end end - context "in case it was definitely se to be configured before the proposal" do - before do - allow(client).to receive(:network_before_proposal?).and_return(true) + context "in case it was definitely set to be configured before the proposal" do + let(:networking_section) do + { "networking" => { "setup_before_proposal" => true } } end + it "writes the network configuration calling the auto client" do expect(Yast::WFM).to receive(:CallFunction).with("lan_auto", ["Write"]) client.autosetup_network end + end + + context "when no network configuration is given" do + let(:networking_section) { {} } + + it "imports the empty profile" do + expect(Yast::WFM).to receive(:CallFunction).with("lan_auto", ["Import", {}]) + + client.autosetup_network + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/test/lib/clients/clone_system_test.rb new/autoyast2-4.3.30/test/lib/clients/clone_system_test.rb --- old/autoyast2-4.3.28/test/lib/clients/clone_system_test.rb 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/test/lib/clients/clone_system_test.rb 2020-07-23 13:16:06.000000000 +0200 @@ -121,6 +121,14 @@ client.main end + it "shows error popup if invalid object is found during serialization" do + allow(Yast::Profile).to receive(:current).and_return("test" => nil) + expect(Yast::Popup).to receive(:Error) + allow(Yast::XML).to receive(:YCPToXMLFile).and_call_original + + client.main + end + context "when a filename is given" do let(:args) { ["modules", "filename=/tmp/autoinst.xml"] } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/autoyast2-4.3.28/test/profile_test.rb new/autoyast2-4.3.30/test/profile_test.rb --- old/autoyast2-4.3.28/test/profile_test.rb 2020-07-20 17:32:58.000000000 +0200 +++ new/autoyast2-4.3.30/test/profile_test.rb 2020-07-23 13:16:06.000000000 +0200 @@ -563,4 +563,44 @@ end end end + + describe "#Save" do + before do + # TODO: test also encrypted autoyast + allow(Yast::AutoinstConfig).to receive(:ProfileEncrypted).and_return(false) + end + + it "returns true if saved profile to file" do + expect(Yast::XML).to receive(:YCPToXMLFile).and_return(true) + + expect(subject.Save("test")).to eq true + end + + it "returns false when failed" do + allow(subject).to receive(:Prepare) + subject.current = { "test" => nil } + + expect(subject.Save("Test")).to eq false + end + end + + describe "#SaveSingleSections" do + before do + allow(subject).to receive(:Prepare) + end + + it "returns list of saved sections" do + subject.current = { "test" => {} } + expect(Yast::XML).to receive(:YCPToXMLFile).and_return(true) + + expect(subject.SaveSingleSections("/tmp")).to eq("test" => "/tmp/test.xml") + end + + it "it does not return sections that failed to save" do + allow(subject).to receive(:Prepare) + subject.current = { "test" => nil } + + expect(subject.SaveSingleSections("/tmp")).to eq({}) + end + end end
