Hello community, here is the log from the commit of package yast2-network for openSUSE:Leap:15.2 checked in at 2020-03-13 10:55:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/yast2-network (Old) and /work/SRC/openSUSE:Leap:15.2/.yast2-network.new.3160 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-network" Fri Mar 13 10:55:52 2020 rev:123 rq:784271 version:4.2.61 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/yast2-network/yast2-network.changes 2020-03-02 17:21:25.934073186 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.yast2-network.new.3160/yast2-network.changes 2020-03-13 10:55:54.460371900 +0100 @@ -1,0 +2,29 @@ +Tue Mar 10 14:29:36 UTC 2020 - Josef Reidinger <[email protected]> + +- Store ip forwarding set during installation to target system + (bsc#1159295) +- 4.2.61 + +------------------------------------------------------------------- +Mon Mar 2 21:01:33 UTC 2020 - Michal Filka <[email protected]> + +- bsc#1164506 + - fixed setting hostname in installer +- bsc#1164587 + - fixed setting hostname according to AY profile +- 4.2.60 + +------------------------------------------------------------------- +Mon Mar 2 19:12:32 UTC 2020 - Knut Anderssen <[email protected]> + +- Do not modify interface name when enslaving it (bsc#1165463) +- 4.2.59 + +------------------------------------------------------------------- +Thu Feb 27 20:40:51 UTC 2020 - Knut Anderssen <[email protected]> + +- Do not crash when running the network configuration client if + the config has not been read by a previous client (bsc#1101514) +- 4.2.58 + +------------------------------------------------------------------- Old: ---- yast2-network-4.2.57.tar.bz2 New: ---- yast2-network-4.2.61.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-network.spec ++++++ --- /var/tmp/diff_new_pack.YRFGnu/_old 2020-03-13 10:55:54.904372216 +0100 +++ /var/tmp/diff_new_pack.YRFGnu/_new 2020-03-13 10:55:54.912372222 +0100 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 4.2.57 +Version: 4.2.61 Release: 0 Summary: YaST2 - Network Configuration License: GPL-2.0-only ++++++ yast2-network-4.2.57.tar.bz2 -> yast2-network-4.2.61.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.2.57/package/yast2-network.changes new/yast2-network-4.2.61/package/yast2-network.changes --- old/yast2-network-4.2.57/package/yast2-network.changes 2020-02-26 12:14:43.000000000 +0100 +++ new/yast2-network-4.2.61/package/yast2-network.changes 2020-03-10 16:13:28.000000000 +0100 @@ -1,4 +1,33 @@ ------------------------------------------------------------------- +Tue Mar 10 14:29:36 UTC 2020 - Josef Reidinger <[email protected]> + +- Store ip forwarding set during installation to target system + (bsc#1159295) +- 4.2.61 + +------------------------------------------------------------------- +Mon Mar 2 21:01:33 UTC 2020 - Michal Filka <[email protected]> + +- bsc#1164506 + - fixed setting hostname in installer +- bsc#1164587 + - fixed setting hostname according to AY profile +- 4.2.60 + +------------------------------------------------------------------- +Mon Mar 2 19:12:32 UTC 2020 - Knut Anderssen <[email protected]> + +- Do not modify interface name when enslaving it (bsc#1165463) +- 4.2.59 + +------------------------------------------------------------------- +Thu Feb 27 20:40:51 UTC 2020 - Knut Anderssen <[email protected]> + +- Do not crash when running the network configuration client if + the config has not been read by a previous client (bsc#1101514) +- 4.2.58 + +------------------------------------------------------------------- Tue Feb 25 12:16:42 CET 2020 - [email protected] - Using SysctlConfig class: Handle sysctl entries in different diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.2.57/package/yast2-network.spec new/yast2-network-4.2.61/package/yast2-network.spec --- old/yast2-network-4.2.57/package/yast2-network.spec 2020-02-26 12:14:43.000000000 +0100 +++ new/yast2-network-4.2.61/package/yast2-network.spec 2020-03-10 16:13:28.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 4.2.57 +Version: 4.2.61 Release: 0 Summary: YaST2 - Network Configuration License: GPL-2.0-only diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.2.57/src/clients/inst_lan.rb new/yast2-network-4.2.61/src/clients/inst_lan.rb --- old/yast2-network-4.2.57/src/clients/inst_lan.rb 2020-02-26 12:14:43.000000000 +0100 +++ new/yast2-network-4.2.61/src/clients/inst_lan.rb 2020-03-10 16:13:28.000000000 +0100 @@ -1,73 +1,3 @@ -# *************************************************************************** -# -# Copyright (c) 2012 Novell, Inc. -# 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 Novell, Inc. -# -# To contact Novell about this file by physical or electronic mail, -# you may find current contact information at www.novell.com -# -# ************************************************************************** -# File: clients/lan.ycp -# Package: Network configuration -# Summary: Network cards main file -# Authors: Michal Svec <[email protected]> -# -# -# Main file for network card configuration. -# Uses all other files. -module Yast - class InstLanClient < Client - include Logger +require "network/clients/inst_lan" - def main - Yast.import "UI" - Yast.import "Lan" - Yast.import "GetInstArgs" - Yast.import "NetworkService" - - Yast.include self, "network/lan/wizards.rb" - - textdomain "network" - - log.info("----------------------------------------") - log.info("Lan module started") - - manual_conf_request = GetInstArgs.argmap["skip_detection"] || false - log.info("Lan module forces manual configuration: #{manual_conf_request}") - - # keep network configuration state in @@conf_net to gurantee same - # behavior when walking :back in installation workflow - if !defined?(@@network_configured) - @@network_configured = - NetworkService.network_manager? ? true : !Lan.yast_config.connections.empty? - end - - log.info("Configured network found: #{@@network_configured}") - - ret = if @@network_configured && !manual_conf_request - GetInstArgs.going_back ? :back : :next - else - LanSequence() - end - - log.info("Lan module finished, ret = #{ret}") - log.info("----------------------------------------") - - ret - end - end - - Yast::InstLanClient.new.main -end +Yast::InstLanClient.new.main diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.2.57/src/include/network/services/dns.rb new/yast2-network-4.2.61/src/include/network/services/dns.rb --- old/yast2-network-4.2.57/src/include/network/services/dns.rb 2020-02-26 12:14:43.000000000 +0100 +++ new/yast2-network-4.2.61/src/include/network/services/dns.rb 2020-03-10 16:13:28.000000000 +0100 @@ -257,6 +257,18 @@ deep_copy(settings) end + # Stores user's input from hostname field + # + # @param value [String] + # @return [String] stored hostname + def store_hostname(value) + hostname = Yast::Lan.yast_config.hostname + hostname.static = value + hostname.installer = value if Stage.initial + + value + end + # @param [Hash] settings map of settings to be stored to DNS:: def StoreSettings(settings) settings = deep_copy(settings) @@ -270,7 +282,8 @@ " ,\n\t" ) - DNS.hostname = Ops.get_string(settings, "HOSTNAME", "") + store_hostname(settings["HOSTNAME"] || "") + valid_nameservers = NonEmpty(nameservers).each_with_object([]) do |ip_str, all| all << IPAddr.new(ip_str) if IP.Check(ip_str) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.2.57/src/lib/network/clients/inst_lan.rb new/yast2-network-4.2.61/src/lib/network/clients/inst_lan.rb --- old/yast2-network-4.2.57/src/lib/network/clients/inst_lan.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-4.2.61/src/lib/network/clients/inst_lan.rb 2020-03-10 16:13:28.000000000 +0100 @@ -0,0 +1,119 @@ +# Copyright (c) [2020] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "yast" + +Yast.import "UI" +Yast.import "Lan" +Yast.import "GetInstArgs" +Yast.import "NetworkService" + +module Yast + # Client for configuring the network during installation. + # + # If the network configuration is managed by NetworkManager or some + # connection config is already present the client skip the configuration + # sequence. + # + # The configuration sequence can be forced passing the 'skip_detection' + # argument. + # + # @example calling the client forcing the configuration sequence + # Yast::WFM.CallFunction("inst_lan", [args.merge("skip_detection" => true)]) + # + # @example firsboot xml forcing the configuration sequence + # <module> + # <label>Network</label> + # <name>inst_lan</name> + # <arguments> + # <skip_detection>true</skip_detection> + # </arguments> + # </module> + class InstLanClient < Client + include Logger + + class << self + attr_accessor :configured + end + + def initialize + textdomain "network" + + Yast.include self, "network/lan/wizards.rb" + end + + def main + log_and_return do + manual_conf_request = GetInstArgs.argmap["skip_detection"] || false + log.info("Lan module forces manual configuration: #{manual_conf_request}") + + if manual_conf_request + LanSequence() + else + log.info("Configured network found: #{network_configured?}") + network_configured? ? :auto : LanSequence() + end + end + end + + private + + # It logs the start and finish of the given block call returning the + # result of the call. + def log_and_return(&block) + log.info("----------------------------------------") + log.info("Lan inst client started") + + ret = block.call + + log.info("Lan inst client finished, ret = #{ret}") + log.info("----------------------------------------") + + ret + end + + # Convenience method that checks whether there is some connection + # configuration present in the system + # + # @return [Boolean] true when there is some connection present in yast + # config; false otherwise + def connections_configured? + # Ensure we read the current network config + Lan.Read(:cache) + !(Lan.yast_config&.connections || []).empty? + end + + # It returns whether the network has been configured or not. It returns + # true in case NetworkManager is in use, otherwise returns whehter there is + # some connection configured + # + # @see connections_configured? + def network_configured? + # keep network configuration state to gurantee same behavior when + # walking :back in installation workflow + return self.class.configured unless self.class.configured.nil? + + self.class.configured = NetworkService.network_manager? ? true : connections_configured? + end + + def reset_config_state + self.class.configured = nil + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.2.57/src/lib/network/clients/save_network.rb new/yast2-network-4.2.61/src/lib/network/clients/save_network.rb --- old/yast2-network-4.2.57/src/lib/network/clients/save_network.rb 2020-02-26 12:14:43.000000000 +0100 +++ new/yast2-network-4.2.61/src/lib/network/clients/save_network.rb 2020-03-10 16:13:28.000000000 +0100 @@ -79,9 +79,9 @@ ) end - ETC = "/etc/".freeze - SYSCONFIG = "/etc/sysconfig/network/".freeze - NETWORK_MANAGER = "/etc/NetworkManager/".freeze + ETC = "/etc".freeze + SYSCONFIG = "/etc/sysconfig/network".freeze + NETWORK_MANAGER = "/etc/NetworkManager".freeze def CopyConfiguredNetworkFiles return if Mode.autoinst && !NetworkAutoYast.instance.keep_net_config? @@ -96,22 +96,25 @@ { dir: SYSCONFIG, file: "ifcfg-*" }, { dir: SYSCONFIG, file: "ifroute-*" }, { dir: SYSCONFIG, file: "routes" }, - { dir: ETC + "wicked/", file: "common.xml" }, - { dir: ETC, file: DNSClass::HOSTNAME_FILE } + { dir: ::File.join(ETC, "wicked"), file: "common.xml" }, + { dir: ETC, file: DNSClass::HOSTNAME_FILE }, + # Copy sysctl file as network writes there ip forwarding (bsc#1159295) + { dir: ::File.join(ETC, "sysctl.d"), file: "70-yast.conf" } ] # NetworkManager is usually the default in a live installation. Any # configuration applied during the installation should be present in the # target system. if Y2Network::ProposalSettings.instance.network_service == :network_manager - copy_recipes << { dir: NETWORK_MANAGER + "/system-connections/", file: "*" } + copy_recipes << { dir: ::File.join(NETWORK_MANAGER, "system-connections"), file: "*" } end # just copy files copy_recipes.each do |recipe| # can be shell pattern like ifcfg-* - file_pattern = recipe[:dir] + recipe[:file] - copy_to = inst_dir + recipe[:dir] + file_pattern = ::File.join(recipe[:dir], recipe[:file]) + copy_to = ::File.join(inst_dir, recipe[:dir]) + log.info("Processing copy recipe #{file_pattern.inspect}") Dir.glob(file_pattern).each do |file| adjust_for_network_disks(file) if file.include?("ifcfg-") @@ -127,12 +130,12 @@ end end - copy_to = String.Quote(inst_dir + SYSCONFIG) + copy_to = String.Quote(::File.join(inst_dir, SYSCONFIG)) # merge files with default installed by sysconfig ["dhcp", "config"].each do |file| - modified_file = SYSCONFIG + file - dest_file = copy_to + file + modified_file = ::File.join(SYSCONFIG, file) + dest_file = ::File.join(copy_to, file) CFA::GenericSysconfig.merge_files(dest_file, modified_file) end # FIXME: proxy diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.2.57/src/lib/y2network/autoinst/config_reader.rb new/yast2-network-4.2.61/src/lib/y2network/autoinst/config_reader.rb --- old/yast2-network-4.2.57/src/lib/y2network/autoinst/config_reader.rb 2020-02-26 12:14:43.000000000 +0100 +++ new/yast2-network-4.2.61/src/lib/y2network/autoinst/config_reader.rb 2020-03-10 16:13:28.000000000 +0100 @@ -22,6 +22,7 @@ require "y2network/config" require "y2network/autoinst/routing_reader" require "y2network/autoinst/dns_reader" +require "y2network/autoinst/hostname_reader" require "y2network/autoinst/interfaces_reader" require "y2network/autoinst/udev_rules_reader" require "y2network/autoinst_profile/networking_section" @@ -48,10 +49,13 @@ # @return [Y2Network::Config] Network configuration def config config = @original_config.copy + # apply at first udev rules, so interfaces names are correct UdevRulesReader.new(section.udev_rules).apply(config) if section.udev_rules config.routing = RoutingReader.new(section.routing).config if section.routing config.dns = DNSReader.new(section.dns).config if section.dns + config.hostname = HostnameReader.new(section.dns).config if section.dns + if section.interfaces interfaces = InterfacesReader.new(section.interfaces).config interfaces.each do |interface| diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.2.57/src/lib/y2network/autoinst/hostname_reader.rb new/yast2-network-4.2.61/src/lib/y2network/autoinst/hostname_reader.rb --- old/yast2-network-4.2.57/src/lib/y2network/autoinst/hostname_reader.rb 2020-02-26 12:14:43.000000000 +0100 +++ new/yast2-network-4.2.61/src/lib/y2network/autoinst/hostname_reader.rb 2020-03-10 16:13:28.000000000 +0100 @@ -40,7 +40,8 @@ def config Y2Network::Hostname.new( dhcp_hostname: section.dhcp_hostname, - hostname: section.hostname || default_hostname + static: section.hostname || default_hostname, + installer: section.hostname ) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.2.57/src/lib/y2network/hostname.rb new/yast2-network-4.2.61/src/lib/y2network/hostname.rb --- old/yast2-network-4.2.57/src/lib/y2network/hostname.rb 2020-02-26 12:14:43.000000000 +0100 +++ new/yast2-network-4.2.61/src/lib/y2network/hostname.rb 2020-03-10 16:13:28.000000000 +0100 @@ -31,7 +31,8 @@ # @return [String] dynamically defined hostname (e.g. from DHCP), defaults to static attr_accessor :transient - # @return [String, nil] hostname as read from linuxrc (if set) in installer, nil otherwise + # @return [String, nil] hostname as read from linuxrc (if set) or explicitly set + # in installer, nil otherwise attr_accessor :installer # @return [String,Symbol] Whether to take the hostname from DHCP. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.2.57/src/lib/y2network/interface.rb new/yast2-network-4.2.61/src/lib/y2network/interface.rb --- old/yast2-network-4.2.57/src/lib/y2network/interface.rb 2020-02-26 12:14:43.000000000 +0100 +++ new/yast2-network-4.2.61/src/lib/y2network/interface.rb 2020-03-10 16:13:28.000000000 +0100 @@ -74,7 +74,7 @@ # @param name [String] Interface name (e.g., "eth0") # @param type [InterfaceType] Interface type def initialize(name, type: InterfaceType::ETHERNET) - @name = name + @name = name.freeze @description = "" @type = type # TODO: move renaming logic to physical interfaces only @@ -109,7 +109,7 @@ def rename(new_name, mechanism) log.info "Rename interface '#{name}' to '#{new_name}' using the '#{mechanism}'" @old_name = name if name != new_name # same name, just set different mechanism - @name = new_name + @name = new_name.freeze @renaming_mechanism = mechanism end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.2.57/src/lib/y2network/sysconfig/hostname_writer.rb new/yast2-network-4.2.61/src/lib/y2network/sysconfig/hostname_writer.rb --- old/yast2-network-4.2.57/src/lib/y2network/sysconfig/hostname_writer.rb 2020-02-26 12:14:43.000000000 +0100 +++ new/yast2-network-4.2.61/src/lib/y2network/sysconfig/hostname_writer.rb 2020-03-10 16:13:28.000000000 +0100 @@ -76,7 +76,7 @@ hostname = hostname.static # 1) when user asked for erasing hostname from /etc/hostname, we keep runtime as it is # 2) we will write whatever user wants even FQDN - no changes under the hood - Yast::Execute.on_target!("/usr/bin/hostname", hostname) if !hostname.empty? + Yast::Execute.locally!("/usr/bin/hostname", hostname) if !hostname.empty? Yast::SCR.Write( Yast::Path.new(".target.string"), HOSTNAME_PATH, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.2.57/src/lib/y2network/widgets/slave_items.rb new/yast2-network-4.2.61/src/lib/y2network/widgets/slave_items.rb --- old/yast2-network-4.2.57/src/lib/y2network/widgets/slave_items.rb 2020-02-26 12:14:43.000000000 +0100 +++ new/yast2-network-4.2.61/src/lib/y2network/widgets/slave_items.rb 2020-03-10 16:13:28.000000000 +0100 @@ -52,7 +52,7 @@ description = Yast::NetworkInterfaces.GetDevTypeDescription(interface.type.short_name, true) else - description = interface.name + description = interface.name.dup # this conditions origin from bridge configuration # if enslaving a configured device then its configuration is rewritten @@ -64,7 +64,7 @@ selected = enslaved_ifaces.include?(interface.name) if physical_port_id?(interface.name) - description << " (Port ID: #{physical_port_id(interface.name)})" + description += " (Port ID: #{physical_port_id(interface.name)})" end result << Yast::Term.new(:item, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.2.57/src/modules/DNS.rb new/yast2-network-4.2.61/src/modules/DNS.rb --- old/yast2-network-4.2.57/src/modules/DNS.rb 2020-02-26 12:14:43.000000000 +0100 +++ new/yast2-network-4.2.61/src/modules/DNS.rb 2020-03-10 16:13:28.000000000 +0100 @@ -74,7 +74,6 @@ # for backward compatibility as long as old DNS module is used as an API # for new dns and hostname classes alias_method :hostname, :static - alias_method :hostname=, :static= def main Yast.import "UI" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.2.57/test/dns_test.rb new/yast2-network-4.2.61/test/dns_test.rb --- old/yast2-network-4.2.57/test/dns_test.rb 2020-02-26 12:14:43.000000000 +0100 +++ new/yast2-network-4.2.61/test/dns_test.rb 2020-03-10 16:13:28.000000000 +0100 @@ -257,15 +257,4 @@ expect(subject.hostname).to eq "install" end end - - describe "#hostname=" do - let(:hostname_config) do - Y2Network::Hostname.new - end - - it "sets static hostname" do - subject.hostname = "test" - expect(subject.hostname).to eq "test" - end - end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.2.57/test/inst_lan_test.rb new/yast2-network-4.2.61/test/inst_lan_test.rb --- old/yast2-network-4.2.57/test/inst_lan_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-4.2.61/test/inst_lan_test.rb 2020-03-10 16:13:28.000000000 +0100 @@ -0,0 +1,109 @@ +#!/usr/bin/env rspec + +# Copyright (c) [2020] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require_relative "test_helper" + +require "yast" +require "network/clients/inst_lan" + +describe Yast::InstLanClient do + describe "#main" do + let(:argmap) { { "skip_detection" => force_config } } + let(:force_config) { false } + let(:config) { nil } + let(:going_back) { false } + let(:using_nm) { false } + let(:connections) { Y2Network::ConnectionConfigsCollection.new([]) } + let(:fake_conn) { instance_double("Y2Network::ConnectionConfig") } + + before do + allow(Yast::GetInstArgs).to receive(:argmap).and_return(argmap) + allow(Yast::Lan).to receive(:yast_config).and_return(config) + allow(Yast::Lan).to receive(:Read) + allow(subject).to receive(:LanSequence) + allow(Yast::GetInstArgs).to receive(:going_back).and_return(going_back) + allow(Yast::NetworkService).to receive(:network_manager?).and_return(using_nm) + subject.send(:reset_config_state) + end + + context "when the network was already configured by the client" do + before do + allow(subject).to receive(:network_configured?).and_return(true) + end + + context "but a manual configuration is forced" do + let(:force_config) { true } + + it "runs the network configuration sequence" do + expect(subject).to receive(:LanSequence) + subject.main + end + end + + context "and a manual configuration is not forced" do + it "does not run the network configuration sequence" do + expect(subject).to_not receive(:LanSequence) + + subject.main + end + + it "returns :auto" do + expect(subject.main).to eq(:auto) + end + end + end + + context "when the NetworkService is NetworkManager" do + let(:using_nm) { true } + + it "does not run the network configuration sequence" do + expect(subject).to_not receive(:LanSequence) + subject.main + end + end + + context "when the NetworkService is wicked" do + it "reads the current network config" do + expect(Yast::Lan).to receive(:Read).with(:cache) + + subject.main + end + + context "and there is some connection config already present in yast" do + let(:connections) { Y2Network::ConnectionConfigsCollection.new([fake_conn]) } + let(:config) { instance_double("Y2Network::Config", connections: connections) } + + it "does not run the network configuration sequence" do + expect(subject).to_not receive(:LanSequence) + + subject.main + end + end + + context "and the network is unconfigured" do + it "runs the network configuration sequence" do + expect(subject).to receive(:LanSequence) + subject.main + end + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.2.57/test/y2network/hostname_writer_test.rb new/yast2-network-4.2.61/test/y2network/hostname_writer_test.rb --- old/yast2-network-4.2.57/test/y2network/hostname_writer_test.rb 2020-02-26 12:14:43.000000000 +0100 +++ new/yast2-network-4.2.61/test/y2network/hostname_writer_test.rb 2020-03-10 16:13:28.000000000 +0100 @@ -51,7 +51,7 @@ it "updates system with the new hostname" do expect(Yast::Execute) - .to receive(:on_target!) + .to receive(:locally!) .with("/usr/bin/hostname", hostname) expect(Yast::SCR) .to receive(:Write)
