commit yast2-network for openSUSE:Factory
Hello community, here is the log from the commit of package yast2-network for openSUSE:Factory checked in at 2019-02-28 21:48:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-network (Old) and /work/SRC/openSUSE:Factory/.yast2-network.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-network" Thu Feb 28 21:48:52 2019 rev:403 rq:680177 version:4.1.42 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-network/yast2-network.changes 2019-02-15 09:53:27.607796768 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-network.new.28833/yast2-network.changes 2019-02-28 21:48:54.929383865 +0100 @@ -1,0 +2,33 @@ +Wed Feb 27 15:08:09 UTC 2019 - knut.anderssen@suse.com + +- Installation proposal (bsc#1127228, bsc#1124478, bsc#1124498): + - Fixed issue refreshing the list of packages needed for the + default backend the first time the proposal is called. + - Do not cache the default network backend but only the current + one when modified by the user in the proposal + - Fallback to :wicked when saving the network if NetworkManager + is selected as the service to be used but not installed. +- 4.1.42 + +------------------------------------------------------------------- +Thu Feb 21 17:50:32 UTC 2019 - knut.anderssen@suse.com + +- When renaming an interface (bsc#1060207): + - Offer to the user the option to update device routes that + belongs to the previous interface name. + - Update the Routing devices list with the new one when needed. +- Do not drop configured elements from the list when canceling + an edition (bsc#998540) +- 4.1.41 + +------------------------------------------------------------------- +Tue Feb 19 09:31:26 UTC 2019 - knut.anderssen@suse.com + +- Installation proposal (bsc#1124478, bsc#1124498): + - Do not offer NetworkManager when the package is not available + - Respect the network backend selected in the proposal at the end + of the installation + - Removed the hostname write (127.0.0.2) from the summary +- 4.1.40 + +------------------------------------------------------------------- Old: ---- yast2-network-4.1.39.tar.bz2 New: ---- yast2-network-4.1.42.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-network.spec ++++++ --- /var/tmp/diff_new_pack.lkjlMu/_old 2019-02-28 21:48:55.525383610 +0100 +++ /var/tmp/diff_new_pack.lkjlMu/_new 2019-02-28 21:48:55.529383609 +0100 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 4.1.39 +Version: 4.1.42 Release: 0 BuildArch: noarch ++++++ yast2-network-4.1.39.tar.bz2 -> yast2-network-4.1.42.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/package/yast2-network.changes new/yast2-network-4.1.42/package/yast2-network.changes --- old/yast2-network-4.1.39/package/yast2-network.changes 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/package/yast2-network.changes 2019-02-28 17:21:23.000000000 +0100 @@ -1,4 +1,37 @@ ------------------------------------------------------------------- +Wed Feb 27 15:08:09 UTC 2019 - knut.anderssen@suse.com + +- Installation proposal (bsc#1127228, bsc#1124478, bsc#1124498): + - Fixed issue refreshing the list of packages needed for the + default backend the first time the proposal is called. + - Do not cache the default network backend but only the current + one when modified by the user in the proposal + - Fallback to :wicked when saving the network if NetworkManager + is selected as the service to be used but not installed. +- 4.1.42 + +------------------------------------------------------------------- +Thu Feb 21 17:50:32 UTC 2019 - knut.anderssen@suse.com + +- When renaming an interface (bsc#1060207): + - Offer to the user the option to update device routes that + belongs to the previous interface name. + - Update the Routing devices list with the new one when needed. +- Do not drop configured elements from the list when canceling + an edition (bsc#998540) +- 4.1.41 + +------------------------------------------------------------------- +Tue Feb 19 09:31:26 UTC 2019 - knut.anderssen@suse.com + +- Installation proposal (bsc#1124478, bsc#1124498): + - Do not offer NetworkManager when the package is not available + - Respect the network backend selected in the proposal at the end + of the installation + - Removed the hostname write (127.0.0.2) from the summary +- 4.1.40 + +------------------------------------------------------------------- Tue Feb 12 13:21:39 CET 2019 - schubi@suse.de - AutoYaST in running system: Do not reset /etc/hosts (bsc#1122658) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/package/yast2-network.spec new/yast2-network-4.1.42/package/yast2-network.spec --- old/yast2-network-4.1.39/package/yast2-network.spec 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/package/yast2-network.spec 2019-02-28 17:21:23.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 4.1.39 +Version: 4.1.42 Release: 0 BuildArch: noarch diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/src/include/network/lan/address.rb new/yast2-network-4.1.42/src/include/network/lan/address.rb --- old/yast2-network-4.1.39/src/include/network/lan/address.rb 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/src/include/network/lan/address.rb 2019-02-28 17:21:23.000000000 +0100 @@ -34,6 +34,7 @@ module NetworkLanAddressInclude include Y2Firewall::Helpers::Interfaces include Yast::Logger + include Yast::I18n include ::UI::TextHelpers def initialize_network_lan_address(include_target) @@ -1264,6 +1265,8 @@ end @settings["IFCFG"] = LanItems.device if LanItems.operation != :add + + # Firewall config firewall_zone = Y2Network::Widgets::FirewallZone.new(LanItems.device) wd["FWZONE"] = firewall_zone.cwm_definition firewall_zone.value = @settings["FWZONE"] if firewalld.installed? @@ -1367,6 +1370,10 @@ Routing.RemoveDefaultGw end end + + # When virtual interfaces are added the list of routing devices needs + # to be updated to offer them + LanItems.update_routing_devices! if LanItems.update_routing_devices? end if LanItems.type == "vlan" @@ -1390,8 +1397,6 @@ # proceed with WLAN settings if appropriate, #42420 ret = :wire if ret == :next && LanItems.type == "wlan" - Routing.SetDevices(NetworkInterfaces.List("")) if ret == :routing - deep_copy(ret) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/src/include/network/lan/complex.rb new/yast2-network-4.1.42/src/include/network/lan/complex.rb --- old/yast2-network-4.1.39/src/include/network/lan/complex.rb 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/src/include/network/lan/complex.rb 2019-02-28 17:21:23.000000000 +0100 @@ -454,6 +454,7 @@ end LanItems.DeleteItem + LanItems.update_routing_devices! initOverview("") end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/src/lib/network/clients/network_proposal.rb new/yast2-network-4.1.42/src/lib/network/clients/network_proposal.rb --- old/yast2-network-4.1.39/src/lib/network/clients/network_proposal.rb 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/src/lib/network/clients/network_proposal.rb 2019-02-28 17:21:23.000000000 +0100 @@ -1,5 +1,6 @@ require "cgi" require "installation/proposal_client" +require "y2network/proposal_settings" module Yast # Proposal client for Network configuration @@ -18,6 +19,8 @@ Yast.import "LanItems" textdomain "installation" + + settings.refresh_packages end def description @@ -53,8 +56,10 @@ private def preformatted_proposal + return lan_summary unless settings.network_manager_available? + proposal_text = switch_backend_link - proposal_text.prepend(Yast::Lan.Summary("proposal")) if wicked_backend? + proposal_text.prepend(lan_summary) if wicked_backend? proposal_text end @@ -88,17 +93,17 @@ end def switch_to_wicked - Yast::NetworkService.use_wicked + settings.enable_wicked! :next end def switch_to_network_manager - Yast::NetworkService.use_network_manager + settings.enable_network_manager! :next end def wicked_backend? - Yast::NetworkService.wicked? + settings.current_backend != :network_manager end # TODO: move to HTML.ycp @@ -106,4 +111,12 @@ Builtins.sformat("<a href=\"%1\">%2</a>", href, CGI.escapeHTML(text)) end end + + def lan_summary + Yast::Lan.Summary("proposal") + end + + def settings + Y2Network::ProposalSettings.instance + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/src/lib/network/clients/save_network.rb new/yast2-network-4.1.42/src/lib/network/clients/save_network.rb --- old/yast2-network-4.1.39/src/lib/network/clients/save_network.rb 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/src/lib/network/clients/save_network.rb 2019-02-28 17:21:23.000000000 +0100 @@ -2,6 +2,7 @@ require "network/install_inf_convertor" require "network/network_autoconfiguration" require "network/network_autoyast" +require "y2network/proposal_settings" require "cfa/generic_sysconfig" @@ -296,7 +297,8 @@ log.info("Setting network service according to product preferences") - if Lan.UseNetworkManager + case Y2Network::ProposalSettings.instance.network_service + when :network_manager log.info("- using NetworkManager") NetworkService.use_network_manager else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/src/lib/network/edit_nic_name.rb new/yast2-network-4.1.42/src/lib/network/edit_nic_name.rb --- old/yast2-network-4.1.39/src/lib/network/edit_nic_name.rb 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/src/lib/network/edit_nic_name.rb 2019-02-28 17:21:23.000000000 +0100 @@ -6,6 +6,7 @@ Yast.import "UI" Yast.import "LanItems" Yast.import "Popup" + Yast.import "Routing" # The class represents a simple dialog which allows user to input new NIC # name. It also allows to select a device attribute (MAC, Bus id, ...) which will @@ -14,6 +15,11 @@ include UIShortcuts include I18n + # @return [String] current udev name before modifying it + attr_accessor :old_name + # @return [String] current udev match criteria + attr_accessor :old_key + # udev rule attribute for MAC address MAC_UDEV_ATTR = "ATTR{address}".freeze @@ -68,11 +74,16 @@ # FIXME: it changes udev key used for device identification # and / or its value only, name is changed elsewhere LanItems.update_item_udev_rule!(udev_type) + + if new_name != old_name + LanItems.update_routing_devices! + LanItems.update_routes!(old_name) if update_routes?(old_name) + end end close - new_name || @old_name + new_name || old_name end private @@ -84,7 +95,7 @@ Left( HBox( Label(_("Device Name:")), - InputField(Id(:dev_name), Opt(:hstretch), "", @old_name) + InputField(Id(:dev_name), Opt(:hstretch), "", old_name) ) ), VSpacing(0.5), @@ -118,7 +129,7 @@ ) ) - case @old_key + case old_key when MAC_UDEV_ATTR UI.ChangeWidget(Id(:udev_type), :CurrentButton, :mac) when BUSID_UDEV_ATTR @@ -151,5 +162,24 @@ true end + + # When an interface name has changed, it returns whether the user wants to + # update the interface name in the related routes or not. + # + # return [Boolean] whether the routes have to be updated or not + def update_routes?(previous_name) + return false unless Routing.device_routes?(previous_name) + + Popup.YesNoHeadline( + Label.WarningMsg, + # TRANSLATORS: Ask for fixing a possible conflict after renaming + # an interface, %s are the previous and current interface names + format(_("The interface %s has been renamed to %s. There are \n" \ + "some routes that still use the previous name.\n\n" \ + "Would you like to update them now?\n"), + "'#{previous_name}'", + "'#{LanItems.current_name}'") + ) + end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/src/lib/network/network_autoyast.rb new/yast2-network-4.1.42/src/lib/network/network_autoyast.rb --- old/yast2-network-4.1.39/src/lib/network/network_autoyast.rb 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/src/lib/network/network_autoyast.rb 2019-02-28 17:21:23.000000000 +0100 @@ -334,20 +334,20 @@ key.downcase! # find item which matches to the given rule definition - item, matching_item = LanItems.Items.find do |_, i| + item_id, matching_item = LanItems.Items.find do |_, i| i["hwinfo"] && (i["hwinfo"]["busid"].downcase == key || i["hwinfo"]["mac"].downcase == key) end next if !matching_item - name_from = item_name(item) + name_from = LanItems.current_name_for(item_id) log.info("Matching device found - renaming <#{name_from}> -> <#{name_to}>") # rename item in collision - rename_lan_item(colliding_item(name_to), name_from) + rename_lan_item(LanItems.colliding_item(name_to), name_from) # rename matching item - rename_lan_item(item, name_to, attr, key) + rename_lan_item(item_id, name_to, attr, key) end end @@ -375,24 +375,5 @@ true end - - # Returns items id, taking into account that item could be renamed - # - # @return [String] device name - def item_name(item_id) - LanItems.renamed?(item_id) ? LanItems.renamed_to(item_id) : LanItems.GetDeviceName(item_id) - end - - # Finds a LanItem which name is in collision to the provided name - # - # @param name [String] a device name (eth0, ...) - # @return [Integer] item id (see LanItems::Items) - def colliding_item(name) - colliding_item, _item_map = LanItems.Items.find do |i, _| - name == item_name(i) - end - - colliding_item - end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/src/lib/y2network/proposal_settings.rb new/yast2-network-4.1.42/src/lib/y2network/proposal_settings.rb --- old/yast2-network-4.1.39/src/lib/y2network/proposal_settings.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-4.1.42/src/lib/y2network/proposal_settings.rb 2019-02-28 17:21:23.000000000 +0100 @@ -0,0 +1,164 @@ +# encoding: utf-8 +# +# Copyright (c) [2019] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "yast" +require "y2packager/package" + +module Y2Network + # Class that stores the proposal settings for network during installation. + class ProposalSettings + include Yast::Logger + include Yast::I18n + + # @return [Boolean] network service to be used after the installation + attr_accessor :selected_backend + + # Constructor + def initialize + Yast.import "Arch" + Yast.import "ProductFeatures" + Yast.import "Package" + Yast.import "PackagesProposal" + + @selected_backend = nil + end + + def current_backend + selected_backend || default_backend + end + + def default_backend + default = use_network_manager? ? :network_manager : :wicked + log.info "The default backend is: #{default}" + default + end + + # Adds the NetworkManager package to the {Yast::PackagesProposal} and sets + # NetworkManager as the backend to be used + def enable_network_manager! + log.info "Enabling NetworkManager" + self.selected_backend = :network_manager + refresh_packages + + selected_backend + end + + # Add the wicked package to the {Yast::PackagesProposal} and sets wicked + # as the backend to be used + def enable_wicked! + log.info "Enabling Wicked" + self.selected_backend = :wicked + refresh_packages + + selected_backend + end + + def refresh_packages + if current_backend == :network_manager + Yast::PackagesProposal.AddResolvables("network", :package, ["NetworkManager"]) + Yast::PackagesProposal.RemoveResolvables("network", :package, ["wicked"]) + else + Yast::PackagesProposal.AddResolvables("network", :package, ["wicked"]) + Yast::PackagesProposal.RemoveResolvables("network", :package, ["NetworkManager"]) + end + end + + # Convenience method to obtain whether the NetworkManager package is + # available or not. + # + # @return [Boolean] false if no package available, true otherwise + def network_manager_available? + p = Y2Packager::Package.find("NetworkManager").first + if p.nil? + log.info("The NetworkManager package is not available") + return false + end + log.info("The NetworkManager package status: #{p.status}") + true + end + + # Propose the network service to be use at the end of the installation + # depending on the backend selected during the proposal and the packages + # installed + def network_service + case current_backend + when :network_manager + network_manager_installed? ? :network_manager : :wicked + else + :wicked + end + end + + class << self + # Singleton instance + def instance + @instance ||= create_instance + end + + # Enforce a new clean instance + def create_instance + @instance = new + end + + # Make sure only .instance and .create_instance can be used to + # create objects + private :new, :allocate + end + + private + + # Convenienve method that verify if Network Manager should be used or not + # according to the control file defaults and package availability. + # + # @return [Boolean] true if should be used; false otherwise + def use_network_manager? + return false unless network_manager_available? + + network_manager_default? + end + + # Convenience method to determine if the NM package is installed or not + # + # @return [Boolean] true if NetworkManager is installed; false otherwise + def network_manager_installed? + Yast::Package.Installed("NetworkManager") + end + + # Determine whether NetworkManager should be selected by default according + # to the product control file + # + # @return [Boolean] true if NM should be enabled; false otherwise + def network_manager_default? + case Yast::ProductFeatures.GetStringFeature("network", "network_manager") + when "" + # compatibility: use the boolean feature + # (defaults to false) + Yast::ProductFeatures.GetBooleanFeature("network", "network_manager_is_default") + when "always" + true + when "laptop" + laptop = Yast::Arch.is_laptop + log.info("Is a laptop: #{laptop}") + laptop + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/src/modules/DNS.rb new/yast2-network-4.1.42/src/modules/DNS.rb --- old/yast2-network-4.1.39/src/modules/DNS.rb 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/src/modules/DNS.rb 2019-02-28 17:21:23.000000000 +0100 @@ -413,12 +413,6 @@ ) ) end - if !@write_hostname - summary = Summary.AddListItem( - summary, - _("Hostname will not be written to /etc/hosts") - ) - end # if (has_dhcp && NetworkConfig::DHCP["DHCLIENT_MODIFY_RESOLV_CONF"]:false) { # Summary text diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/src/modules/Lan.rb new/yast2-network-4.1.42/src/modules/Lan.rb --- old/yast2-network-4.1.39/src/modules/Lan.rb 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/src/modules/Lan.rb 2019-02-28 17:21:23.000000000 +0100 @@ -94,6 +94,8 @@ # Lan::Read (`cache) will do nothing if initialized already. @initialized = false + + @backend = nil end #------------------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/src/modules/LanItems.rb new/yast2-network-4.1.42/src/modules/LanItems.rb --- old/yast2-network-4.1.39/src/modules/LanItems.rb 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/src/modules/LanItems.rb 2019-02-28 17:21:23.000000000 +0100 @@ -58,6 +58,7 @@ Yast.import "UI" textdomain "network" + Yast.import "Routing" Yast.import "NetworkInterfaces" Yast.import "ProductFeatures" Yast.import "NetworkConfig" @@ -276,6 +277,20 @@ items.map { |itemId| GetDeviceName(itemId) }.reject(&:empty?) end + # Return the actual name of the current {LanItem} + # + # @return [String] the actual name for the current device + def current_name + current_name_for(@current) + end + + # Return the current device names + # + # @ return [Array<String>] + def current_device_names + GetNetcardInterfaces().map { |i| current_name_for(i) }.reject(&:empty?) + end + # Returns device name for current lan item (see LanItems::current) def GetCurrentName GetDeviceName(@current) @@ -2176,7 +2191,10 @@ # @return [true] so that this can be used for the :abort callback def Rollback log.info "rollback item #{@current}" - if getCurrentItem.fetch("hwinfo", {}).empty? + # Do not delete elements that are :edited but does not contain hwinfo + # yet (Add a virtual device and then edit it canceling the process during the + # edition) + if LanItems.operation == :add && getCurrentItem.fetch("hwinfo", {}).empty? LanItems.Items.delete(@current) elsif IsCurrentConfigured() if !getNetworkInterfaces.include?(getCurrentItem["ifcfg"]) @@ -2634,6 +2652,41 @@ false end + # Return the current name of the {LanItem} given + # + # @param item_id [Integer] a key for {#Items} + def current_name_for(item_id) + renamed?(item_id) ? renamed_to(item_id) : GetDeviceName(item_id) + end + + # Finds a LanItem which name is in collision to the provided name + # + # @param name [String] a device name (eth0, ...) + # @return [Integer, nil] item id (see LanItems::Items) + def colliding_item(name) + item_id, _item_map = Items().find { |i, _| name == current_name_for(i) } + item_id + end + + # Return wether the {Yast:Routing} devices list needs to be updated or not + # to include the current interface name + # + # @return [Boolean] false if the current interface name is already present + def update_routing_devices? + !Routing.devices.include?(current_name) + end + + # Convenience method to update the {Yast::Routing} devices list + def update_routing_devices! + Routing.SetDevices(current_device_names) + end + + # It modifies the interface name with the new one of all the routes + # that belongs to the current renamed {LanItem} + def update_routes!(previous_name) + Routing.device_routes(previous_name).each { |r| r["device"] = current_name } + end + private # Checks if given lladdr can be written into ifcfg diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/src/modules/Routing.rb new/yast2-network-4.1.42/src/modules/Routing.rb --- old/yast2-network-4.1.39/src/modules/Routing.rb 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/src/modules/Routing.rb 2019-02-28 17:21:23.000000000 +0100 @@ -147,6 +147,14 @@ true end + def device_routes(device) + @Routes.select { |r| r["device"] == device } + end + + def device_routes?(device) + @Routes.any? { |r| r["device"] == device } + end + # Remove route with default gateway from Routes list def RemoveDefaultGw route = [] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/test/address_test.rb new/yast2-network-4.1.42/test/address_test.rb --- old/yast2-network-4.1.39/test/address_test.rb 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/test/address_test.rb 2019-02-28 17:21:23.000000000 +0100 @@ -141,5 +141,4 @@ end end end - end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/test/edit_nic_name_test.rb new/yast2-network-4.1.42/test/edit_nic_name_test.rb --- old/yast2-network-4.1.39/test/edit_nic_name_test.rb 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/test/edit_nic_name_test.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,109 +0,0 @@ -#!/usr/bin/env rspec - -require_relative "test_helper" - -require "yast" -require "network/edit_nic_name" - -module Yast - Yast.import "UI" - - CURRENT_NAME = "spec0".freeze - NEW_NAME = "new1".freeze - EXISTING_NEW_NAME = "existing_new_name".freeze - - describe "#run" do - # general mocking stuff is placed here - before(:each) do - # NetworkInterfaces are too low level. Everything needed should be mocked - stub_const("NetworkInterfaces", double(adapt_old_config!: nil)) - - # mock devices configuration - allow(LanItems).to receive(:ReadHardware) { [{ "dev_name" => CURRENT_NAME, "mac" => "00:01:02:03:04:05" }] } - allow(LanItems).to receive(:getNetworkInterfaces) { [CURRENT_NAME] } - allow(LanItems).to receive(:GetItemUdev) { "" } - allow(LanItems).to receive(:GetItemUdev).with("NAME") { CURRENT_NAME } - allow(LanItems).to receive(:GetItemUdev).with("ATTR{address}") { "00:01:02:03:04:05" } - - # LanItems initialization - Yast.import "LanItems" - - LanItems.Read - LanItems.FindAndSelect(CURRENT_NAME) - - # create the dialog - @edit_name_dlg = EditNicName.new - - allow(LanItems) - .to receive(:GetNetcardNames) - .and_return([CURRENT_NAME]) - end - - context "when closed without any change" do - before(:each) do - # emulate UI work - allow(UI).to receive(:QueryWidget).with(:dev_name, :Value) { CURRENT_NAME } - allow(UI).to receive(:QueryWidget).with(:udev_type, :CurrentButton) { :mac } - end - - it "returns current name when used Ok button" do - allow(UI).to receive(:UserInput) { :ok } - - expect(@edit_name_dlg.run).to be_equal CURRENT_NAME - end - - it "returns current name when used Cancel button" do - allow(UI).to receive(:UserInput) { :cancel } - - expect(@edit_name_dlg.run).to be_equal CURRENT_NAME - end - end - - context "when closed after name change" do - before(:each) do - # emulate UI work - allow(UI).to receive(:QueryWidget).with(:dev_name, :Value) { NEW_NAME } - allow(UI).to receive(:QueryWidget).with(:udev_type, :CurrentButton) { :mac } - end - - it "returns new name when used Ok button" do - allow(UI).to receive(:UserInput) { :ok } - - expect(@edit_name_dlg.run).to be_equal NEW_NAME - end - - it "returns current name when used Cancel button" do - allow(UI).to receive(:UserInput) { :cancel } - - expect(@edit_name_dlg.run).to be_equal CURRENT_NAME - end - - it "asks for new user input when name already exists" do - allow(UI) - .to receive(:QueryWidget) - .with(:dev_name, :Value) - .and_return(EXISTING_NEW_NAME, NEW_NAME) - allow(UI) - .to receive(:UserInput) - .and_return(:ok) - - expect(@edit_name_dlg) - .to receive(:CheckUdevNicName) - .with(EXISTING_NEW_NAME) - .and_return(false) - expect(@edit_name_dlg) - .to receive(:CheckUdevNicName) - .with(NEW_NAME) - .and_return(true) - - expect(UI) - .to receive(:SetFocus) - expect(LanItems) - .to receive(:rename) - .with(NEW_NAME) - - expect(@edit_name_dlg.run).to eql NEW_NAME - end - end - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/test/lan_items_helpers_test.rb new/yast2-network-4.1.42/test/lan_items_helpers_test.rb --- old/yast2-network-4.1.39/test/lan_items_helpers_test.rb 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/test/lan_items_helpers_test.rb 2019-02-28 17:21:23.000000000 +0100 @@ -376,31 +376,6 @@ end end - describe "LanItems#dhcp_ntp_servers" do - it "lists ntp servers for every device which provides them" do - result = { - "eth0" => ["1.0.0.1"], - "eth1" => ["1.0.0.2", "1.0.0.3"] - } - - allow(Yast::LanItems) - .to receive(:parse_ntp_servers) - .and_return([]) - allow(Yast::LanItems) - .to receive(:parse_ntp_servers) - .with("eth0") - .and_return(["1.0.0.1"]) - allow(Yast::LanItems) - .to receive(:parse_ntp_servers) - .with("eth1") - .and_return(["1.0.0.2", "1.0.0.3"]) - allow(Yast::LanItems) - .to receive(:find_dhcp_ifaces) - .and_return(["eth0", "eth1", "eth2"]) - - expect(Yast::LanItems.dhcp_ntp_servers).to eql result - end - end end describe "LanItems#dhcp_ntp_servers" do @@ -590,3 +565,107 @@ end end end + +describe "LanItems renaming methods" do + let(:renamed_to) { nil } + let(:current) { 0 } + let(:item_0) do + { + "ifcfg" => "eth0", + "renamed_to" => renamed_to + } + end + + before do + allow(Yast::LanItems).to receive(:Items).and_return(0 => item_0) + Yast::Routing.SetDevices(["eth0"]) + end + + describe "LanItems#current_name_for" do + context "when the LanItem has not been renamed" do + it "returns the item name" do + expect(Yast::LanItems.current_name_for(0)).to eql "eth0" + end + end + + context "when the LanItem has been renamed" do + let(:renamed_to) { "new1" } + + it "returns the new name" do + expect(Yast::LanItems.current_name_for(0)).to eql "new1" + end + end + end + + describe "LanItems#colliding_item" do + it "returns nothing if no collision was found" do + expect(Yast::LanItems.colliding_item("enp0s3")).to be nil + end + + it "returns the Item index which is in collision" do + expect(Yast::LanItems.colliding_item("eth0")).to be 0 + end + + context "if some of the devices were renamed" do + let(:renamed_to) { "enp0s3" } + + it "uses the new name to detect the collision" do + expect(Yast::LanItems.colliding_item("enp0s3")).to be 0 + end + end + end + + describe "LanItems.update_routing_devices!" do + let(:renamed_to) { "new1" } + + it "updates the list of Routing devices with current device names" do + Yast::LanItems.update_routing_devices! + expect(Yast::Routing.devices).to eql([renamed_to]) + end + end + + describe "LanItems.update_routing_devices?" do + context "when there are no changes in the device names" do + it "returns false" do + expect(Yast::LanItems.update_routing_devices?).to eql(false) + end + end + + context "when some interface have been renaming and Routing device names differs" do + let(:renamed_to) { "new1" } + it "returns true" do + expect(Yast::LanItems.update_routing_devices?).to eql(true) + end + end + end + + describe "LanItems.update_routes" do + let(:renamed_to) { "new1" } + + let(:original_routes) do + [{ + "destination" => "192.168.1.0", + "device" => "eth0", + "gateway" => "10.1.188.1", + "netmask" => "255.255.255.0" + }, + { + "destination" => "default", + "device" => "eth0", + "gateway" => "172.24.88.1", + "netmask" => "-" + }] + end + + before do + Yast::Routing.Routes = original_routes + end + + it "modifies all existent device routes with the current device name" do + Yast::LanItems.update_routes!("eth0") + routes = Yast::Routing.Routes().select { |r| r["device"] == renamed_to } + expect(routes.size).to eql(2) + expect(routes.map { |r| r["destination"] }.sort).to eql(["default", "192.168.1.0"].sort) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/test/lan_items_rollback_test.rb new/yast2-network-4.1.42/test/lan_items_rollback_test.rb --- old/yast2-network-4.1.39/test/lan_items_rollback_test.rb 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/test/lan_items_rollback_test.rb 2019-02-28 17:21:23.000000000 +0100 @@ -29,8 +29,9 @@ end describe "#Rollback" do - context "when the current item is committed" do + context "when the current item is edited" do before do + Yast::LanItems.operation = :edit subject.Items = mocked_items subject.current = 1 end @@ -41,8 +42,9 @@ end end - context "when the current item is uncommitted; without hwinfo" do + context "when the current item is added (configured without hwinfo)" do before do + Yast::LanItems.operation = :add subject.Items = mocked_items subject.current = 2 end @@ -53,8 +55,9 @@ end end - context "when the current item is uncommitted; with hwinfo" do + context "when the current item is edited; (unconfigured but with hwinfo)" do before do + Yast::LanItems.operation = :edit subject.Items = mocked_items subject.current = 3 end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/test/lib/network/edit_nic_name_test.rb new/yast2-network-4.1.42/test/lib/network/edit_nic_name_test.rb --- old/yast2-network-4.1.39/test/lib/network/edit_nic_name_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-4.1.42/test/lib/network/edit_nic_name_test.rb 2019-02-28 17:21:23.000000000 +0100 @@ -0,0 +1,133 @@ +#!/usr/bin/env rspec + +require_relative "../../test_helper" + +require "yast" +require "network/edit_nic_name" + +Yast.import "LanItems" + +describe Yast::EditNicName do + let(:subject) { described_class.new } + let(:current_name) { "spec0" } + let(:new_name) { "new1" } + let(:existing_new_name) { "existing_new_name" } + let(:interface_hwinfo) { { "dev_name" => current_name, "mac" => "00:01:02:03:04:05" } } + + describe "#run" do + # general mocking stuff is placed here + before(:each) do + # NetworkInterfaces are too low level. Everything needed should be mocked + stub_const("NetworkInterfaces", double(adapt_old_config!: nil)) + + # mock devices configuration + allow(Yast::LanItems).to receive(:ReadHardware).and_return([interface_hwinfo]) + allow(Yast::LanItems).to receive(:getNetworkInterfaces).and_return([current_name]) + allow(Yast::LanItems).to receive(:GetItemUdev) { "" } + allow(Yast::LanItems).to receive(:current_udev_name).and_return(current_name) + allow(Yast::LanItems).to receive(:GetItemUdev).with("ATTR{address}") { "00:01:02:03:04:05" } + allow(Yast::LanItems).to receive(:GetNetcardNames).and_return([current_name]) + + # LanItems initialization + + Yast::LanItems.Read + Yast::LanItems.FindAndSelect(current_name) + end + + context "when closed without any change" do + before(:each) do + # emulate Yast::UI work + allow(Yast::UI).to receive(:QueryWidget).with(:dev_name, :Value) { current_name } + allow(Yast::UI).to receive(:QueryWidget).with(:udev_type, :CurrentButton) { :mac } + allow(Yast::UI).to receive(:UserInput) { :ok } + allow(Yast::LanItems).to receive(:update_item_udev_rule!) + end + + it "returns current name when used Ok button" do + expect(subject.run).to be_equal current_name + end + + it "returns current name when used Cancel button" do + allow(Yast::UI).to receive(:UserInput) { :cancel } + + expect(subject.run).to be_equal current_name + end + + it "does not execute any other callback" do + expect(Yast::Routing).to_not receive(:update_routing_devices!) + + subject.run + end + end + + context "when name changed" do + before(:each) do + # emulate Yast::UI work + allow(Yast::UI).to receive(:QueryWidget).with(:dev_name, :Value) { new_name } + allow(Yast::UI).to receive(:QueryWidget).with(:udev_type, :CurrentButton) { :mac } + allow(Yast::UI).to receive(:UserInput) { :ok } + allow(Yast::LanItems).to receive(:update_routing_devices!) + allow(subject).to receive(:update_routes?).and_return(false) + allow(Yast::LanItems).to receive(:update_routes!) + end + + context "and closed confirming the changes" do + it "returns the new name" do + expect(subject.run).to be_equal new_name + end + + it "asks for new user input when name already exists" do + allow(Yast::UI).to receive(:QueryWidget) + .with(:dev_name, :Value).and_return(existing_new_name, new_name) + expect(subject).to receive(:CheckUdevNicName).with(existing_new_name).and_return(false) + expect(subject).to receive(:CheckUdevNicName).with(new_name).and_return(true) + expect(Yast::UI).to receive(:SetFocus) + expect(Yast::LanItems).to receive(:rename).with(new_name) + subject.run + end + + it "updates the Routing devices list with the new name" do + expect(Yast::LanItems).to receive(:update_routing_devices!).and_call_original + subject.run + expect(Yast::Routing.devices).to include(new_name) + end + + context "and there are some routes referencing the previous name" do + before do + allow(Yast::Routing).to receive(:device_routes?).with(current_name).and_return(true) + expect(subject).to receive(:update_routes?).with(current_name).and_call_original + allow(Yast::LanItems).to receive(:update_routes!).with(current_name) + end + + it "asks the user about updating the routes device name" do + expect(Yast::Popup).to receive(:YesNoHeadline) + + subject.run + end + + it "updates the routes if the user accepts to do it" do + expect(Yast::Popup).to receive(:YesNoHeadline).and_return(true) + expect(Yast::LanItems).to receive(:update_routes!).with(current_name) + + subject.run + end + + it "does not touch the routes if the user does not want to touch them" do + expect(Yast::Popup).to receive(:YesNoHeadline).and_return(false) + expect(Yast::LanItems).to_not receive(:update_routes!) + subject.run + end + end + end + + context "and closed canceling the changes" do + it "returns current name when used Cancel button" do + allow(Yast::UI).to receive(:UserInput) { :cancel } + + expect(subject.run).to be_equal current_name + end + end + + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/test/lib/y2network/proposal_settings_test.rb new/yast2-network-4.1.42/test/lib/y2network/proposal_settings_test.rb --- old/yast2-network-4.1.39/test/lib/y2network/proposal_settings_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-4.1.42/test/lib/y2network/proposal_settings_test.rb 2019-02-28 17:21:23.000000000 +0100 @@ -0,0 +1,300 @@ +#!/usr/bin/env rspec + +require_relative "../../test_helper" +require "y2network/proposal_settings" + +describe Y2Network::ProposalSettings do + subject { described_class.create_instance } + let(:nm_available) { true } + let(:feature) { { "network" => { "network_manager" => "always" } } } + + before do + allow_any_instance_of(Y2Network::ProposalSettings) + .to receive(:network_manager_available?).and_return(nm_available) + stub_features(feature) + end + + def stub_features(features) + Yast.import "ProductFeatures" + Yast::ProductFeatures.Import(features) + end + + describe ".instance" do + context "no instance has been created yet" do + before do + described_class.instance_variable_set("@instance", nil) + end + + it "creates a new instance" do + expect(described_class).to receive(:new).and_call_original + described_class.instance + end + end + + context "when a instance has been already created" do + before do + described_class.instance + end + + it "does not create any new instance" do + expect(described_class).to_not receive(:new) + described_class.instance + end + + it "returns the existent instance" do + instance = described_class.instance + expect(instance.object_id).to eql(described_class.instance.object_id) + end + end + end + + describe ".create_instance" do + let(:created_instance) { described_class.create_instance } + let(:nm_available) { false } + + it "creates a new network proposal settings instance" do + instance = described_class.instance + expect(created_instance).to be_a(described_class) + expect(created_instance).to_not equal(instance) + end + end + + describe "#default_backend" do + let(:subject) { described_class.create_instance } + let(:logger) { double(info: true) } + let(:nm_available) { false } + + context "when the NetworkManager package is not available" do + it "returns :wicked as the default backend" do + expect(subject.default_backend).to eql(:wicked) + end + end + + context "when the NetworkManager package is available" do + let(:nm_available) { true } + + context "and the ProductFeature .network.network_manager is not defined" do + context "and neither .network.network_manager_is_default is" do + let(:feature) { { "network" => {} } } + + it "returns :wicked as the default backend" do + expect(subject.default_backend).to eql(:wicked) + end + end + + context "but .network.network_manager_is_default is" do + let(:feature) { { "network" => { "network_manager_is_default" => true } } } + + it "returns :network_manager as the default backend" do + expect(subject.default_backend).to eql(:network_manager) + end + end + end + + context "and the ProductFeature .network.network_manager is 'always'" do + it "returns :network_manager as the default backend" do + expect(subject.default_backend).to eql(:network_manager) + end + end + + context "and the ProductFeature .network.network_manager is 'laptop'" do + let(:is_laptop) { true } + let(:feature) { { "network" => { "network_manager" => "laptop" } } } + + before do + allow(Yast::Arch).to receive(:is_laptop).and_return(is_laptop) + end + + context "and the machine is a laptop" do + it "returns :network_manager as the default backend" do + expect(subject.default_backend).to eql(:network_manager) + end + end + + context "and the machine is not a laptop" do + let(:is_laptop) { false } + it "returns :wicked as the default backend" do + expect(subject.default_backend).to eql(:wicked) + end + end + end + + it "initializes the default network backend from the product control file" do + expect(subject.default_backend).to eql(:network_manager) + stub_features("network" => { "network_manager" => "" }) + expect(subject.default_backend).to eql(:wicked) + end + end + + it "logs which backend has been selected as the default" do + allow_any_instance_of(described_class).to receive(:log).and_return(logger) + expect(logger).to receive(:info).with(/backend is: wicked/) + subject.default_backend + end + end + + describe "#current_backend" do + let(:selected_backend) { :wicked } + let(:default_backend) { "wicked_or_nm_based_on_control_file" } + + before do + allow(subject).to receive(:default_backend).and_return(default_backend) + subject.selected_backend = selected_backend + end + + context "when a backend has been selected manually" do + it "returns the backend selected manually" do + expect(subject.current_backend).to eql(selected_backend) + end + end + + context "when no backend has been selected manually" do + let(:selected_backend) { nil } + + it "returns the default backend" do + expect(subject.current_backend).to eql(default_backend) + end + end + end + + describe "#enable_wicked!" do + it "adds the wicked package to the list of resolvables " do + expect(Yast::PackagesProposal).to receive(:AddResolvables) + .with("network", :package, ["wicked"]) + subject.enable_wicked! + end + + it "removes the NetworkManager package from the list of resolvables " do + expect(Yast::PackagesProposal).to receive(:RemoveResolvables) + .with("network", :package, ["NetworkManager"]) + subject.enable_wicked! + end + + it "sets :wicked as the user selected backend" do + expect(subject.selected_backend).to be_nil + subject.enable_wicked! + expect(subject.selected_backend).to eql(:wicked) + end + end + + describe "#refresh_packages" do + let(:backend) { :wicked } + + before do + allow(subject).to receive(:current_backend).and_return(backend) + end + + context "when :wicked is the current backend" do + it "adds the wicked package to the list of resolvables " do + expect(Yast::PackagesProposal).to receive(:AddResolvables) + .with("network", :package, ["wicked"]) + subject.refresh_packages + end + + it "removes the NetworkManager package from the list of resolvables " do + expect(Yast::PackagesProposal).to receive(:RemoveResolvables) + .with("network", :package, ["NetworkManager"]) + subject.refresh_packages + end + end + + context "when :network_manager is the current backend" do + let(:backend) { :network_manager } + + it "adds the NetworkManager package to the list of resolvables " do + expect(Yast::PackagesProposal).to receive(:AddResolvables) + .with("network", :package, ["NetworkManager"]) + subject.refresh_packages + end + + it "removes the wicked package from the list of resolvables " do + expect(Yast::PackagesProposal).to receive(:RemoveResolvables) + .with("network", :package, ["wicked"]) + subject.refresh_packages + end + end + end + + describe "#enable_network_manager!" do + before do + subject.selected_backend = nil + end + + it "sets :network_manager as the user selected backend" do + subject.enable_network_manager! + expect(subject.selected_backend).to eql(:network_manager) + end + end + + describe "#network_manager_available?" do + let(:package) { instance_double(Y2Packager::Package, status: :available) } + let(:packages) { [package] } + let(:settings) { described_class.instance } + + before do + allow(settings).to receive(:network_manager_available?).and_call_original + allow(Y2Packager::Package).to receive(:find).with("NetworkManager") + .and_return(packages) + end + + context "when there is no NetworkManager package available" do + let(:packages) { [] } + + it "returns false" do + expect(settings.network_manager_available?).to eql(false) + end + + it "logs that the package is no available" do + expect(settings.log).to receive(:info).with(/is not available/) + settings.network_manager_available? + end + end + + context "when there are some NetworkManager packages available" do + it "returns true" do + expect(settings.network_manager_available?).to eql(true) + end + + it "logs the status of the NetworkManager package" do + expect(settings.log).to receive(:info).with(/status: available/) + settings.network_manager_available? + end + end + end + + describe "#network_service" do + let(:settings) { described_class.instance } + let(:backend) { :wicked } + let(:nm_installed) { true } + + before do + allow(settings).to receive(:current_backend).and_return(backend) + allow(Yast::Package).to receive(:Installed) + .with("NetworkManager").and_return(nm_installed) + end + + context "when the backend selected is wicked" do + it "returns :wicked" do + expect(settings.network_service).to eql(:wicked) + end + end + + context "when the backend selected is NetworkManager" do + let(:backend) { :network_manager } + + context "and the NetworkManager package is installed" do + it "returns :network_manager" do + expect(settings.network_service).to eql(:network_manager) + end + end + + context "and the NetworkManager package is not installed" do + let(:nm_installed) { false } + + it "returns :wicked" do + expect(settings.network_service).to eql(:wicked) + end + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/test/network_autoyast_test.rb new/yast2-network-4.1.42/test/network_autoyast_test.rb --- old/yast2-network-4.1.39/test/network_autoyast_test.rb 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/test/network_autoyast_test.rb 2019-02-28 17:21:23.000000000 +0100 @@ -408,41 +408,6 @@ ) end - describe "#item_name" do - it "returns old name when the device has not been renamed" do - mock_lan_item - - expect(network_autoyast.send(:item_name, 0)).to eql "eth0" - end - - it "returns new name when the device has been renamed" do - new_name = "new1" - mock_lan_item(renamed_to: new_name) - - expect(network_autoyast.send(:item_name, 0)).to eql new_name - end - end - - describe "#colliding_item" do - it "returns nothing if no collision was found" do - mock_lan_item - - expect(network_autoyast.send(:colliding_item, "enp0s3")).to be nil - end - - it "returns device name which is in collision" do - mock_lan_item - - expect(network_autoyast.send(:colliding_item, "eth0")).to be 0 - end - - it "returns device name when the device was already renamed before and we new name is in collision" do - mock_lan_item(renamed_to: "enp0s3") - - expect(network_autoyast.send(:colliding_item, "enp0s3")).to be 0 - end - end - describe "#assign_udevs_to_devs" do Yast.import "LanItems" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.1.39/test/network_proposal_test.rb new/yast2-network-4.1.42/test/network_proposal_test.rb --- old/yast2-network-4.1.39/test/network_proposal_test.rb 2019-02-13 09:23:15.000000000 +0100 +++ new/yast2-network-4.1.42/test/network_proposal_test.rb 2019-02-28 17:21:23.000000000 +0100 @@ -20,17 +20,32 @@ end describe "#make_proposal" do - let(:using_wicked) { true } + let(:settings) { Y2Network::ProposalSettings.create_instance } + let(:current_backend) { :wicked } + let(:nm_available) { true } let(:proposal) { subject.make_proposal({}) } before do - allow(Yast::NetworkService).to receive(:wicked?).and_return(using_wicked) + settings.selected_backend = current_backend + allow(settings).to receive(:network_manager_available?).and_return(nm_available) end it "returns a hash describing the proposal" do expect(proposal).to include("label_proposal", "preformatted_proposal", "links") end + context "when NetworkManager is not available" do + let(:nm_available) { false } + + it "includes the Yast::Lan proposal summary" do + expect(proposal["preformatted_proposal"]).to include("rich_text_summary") + end + + it "does not include any link to switch between backends" do + expect(proposal["preformatted_proposal"]).to_not match(/.*Using*.*href.*.switch to*./) + end + end + context "when using the wicked backend" do it "includes the Yast::Lan proposal summary" do expect(proposal["preformatted_proposal"]).to include("rich_text_summary") @@ -46,7 +61,7 @@ end context "when using the NetworkManager backend" do - let(:using_wicked) { false } + let(:current_backend) { :network_manager } it "does not include the Yast::Lan proposal summary" do expect(proposal["preformatted_proposal"]).to_not include("rich_text_summary") @@ -63,6 +78,7 @@ end describe "#ask_user" do + let(:settings) { Y2Network::ProposalSettings.instance } let(:chosen_id) { "" } let(:args) do { @@ -103,8 +119,8 @@ expect(Yast::WFM).to_not receive(:CallFuntion).with("inst_lan", anything) end - it "changes the netwotk backend to wicked" do - expect(Yast::NetworkService).to receive(:use_wicked) + it "changes the network backend to wicked" do + expect(settings).to receive(:enable_wicked!) subject.ask_user(args) end @@ -122,7 +138,7 @@ end it "changes the netwotk backend to NetworkManager" do - expect(Yast::NetworkService).to receive(:use_network_manager) + expect(settings).to receive(:enable_network_manager!) subject.ask_user(args) end
participants (1)
-
root