Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package yast2-network for openSUSE:Factory checked in at 2021-04-23 17:50:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-network (Old) and /work/SRC/openSUSE:Factory/.yast2-network.new.12324 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-network" Fri Apr 23 17:50:33 2021 rev:450 rq:887860 version:4.4.5 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-network/yast2-network.changes 2021-04-14 10:09:37.749356926 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-network.new.12324/yast2-network.changes 2021-04-23 17:50:48.170812454 +0200 @@ -1,0 +2,22 @@ +Thu Apr 22 12:22:47 UTC 2021 - Knut Anderssen <kanders...@suse.com> + +- bsc#1185106 + - Initialize correctly the netmask when using the static bootproto + without an IP address defined. + - Fix MTU write when using wicked. + +------------------------------------------------------------------- +Thu Apr 22 09:12:38 UTC 2021 - Knut Anderssen <kanders...@suse.com> + +- Do not crash when modifying a virtual interface and checking if + it is hotplug (bsc#1184623, bsc#1185106) +- 4.4.5 + +------------------------------------------------------------------- +Wed Apr 14 11:05:02 UTC 2021 - Knut Anderssen <kanders...@suse.com> + +- Do not require a MAC address when activating a qeth device + with layer2 support (bsc#1184474). +- 4.4.4 + +------------------------------------------------------------------- Old: ---- yast2-network-4.4.3.tar.bz2 New: ---- yast2-network-4.4.5.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-network.spec ++++++ --- /var/tmp/diff_new_pack.e2pniI/_old 2021-04-23 17:50:48.734813423 +0200 +++ /var/tmp/diff_new_pack.e2pniI/_new 2021-04-23 17:50:48.734813423 +0200 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 4.4.3 +Version: 4.4.5 Release: 0 Summary: YaST2 - Network Configuration License: GPL-2.0-only ++++++ yast2-network-4.4.3.tar.bz2 -> yast2-network-4.4.5.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.4.3/package/yast2-network.changes new/yast2-network-4.4.5/package/yast2-network.changes --- old/yast2-network-4.4.3/package/yast2-network.changes 2021-04-13 15:07:47.000000000 +0200 +++ new/yast2-network-4.4.5/package/yast2-network.changes 2021-04-22 18:43:00.000000000 +0200 @@ -1,4 +1,26 @@ ------------------------------------------------------------------- +Thu Apr 22 12:22:47 UTC 2021 - Knut Anderssen <kanders...@suse.com> + +- bsc#1185106 + - Initialize correctly the netmask when using the static bootproto + without an IP address defined. + - Fix MTU write when using wicked. + +------------------------------------------------------------------- +Thu Apr 22 09:12:38 UTC 2021 - Knut Anderssen <kanders...@suse.com> + +- Do not crash when modifying a virtual interface and checking if + it is hotplug (bsc#1184623, bsc#1185106) +- 4.4.5 + +------------------------------------------------------------------- +Wed Apr 14 11:05:02 UTC 2021 - Knut Anderssen <kanders...@suse.com> + +- Do not require a MAC address when activating a qeth device + with layer2 support (bsc#1184474). +- 4.4.4 + +------------------------------------------------------------------- Tue Apr 13 12:32:16 UTC 2021 - Knut Anderssen <kanders...@suse.com> - Do not crash when checking if an interface is a hotplug one and diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.4.3/package/yast2-network.spec new/yast2-network-4.4.5/package/yast2-network.spec --- old/yast2-network-4.4.3/package/yast2-network.spec 2021-04-13 15:07:47.000000000 +0200 +++ new/yast2-network-4.4.5/package/yast2-network.spec 2021-04-22 18:43:00.000000000 +0200 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 4.4.3 +Version: 4.4.5 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.4.3/src/lib/y2network/dialogs/add_interface.rb new/yast2-network-4.4.5/src/lib/y2network/dialogs/add_interface.rb --- old/yast2-network-4.4.3/src/lib/y2network/dialogs/add_interface.rb 2021-04-13 15:07:47.000000000 +0200 +++ new/yast2-network-4.4.5/src/lib/y2network/dialogs/add_interface.rb 2021-04-22 18:43:00.000000000 +0200 @@ -51,24 +51,9 @@ ) end - # initialize legacy stuff, that should be removed soon - def legacy_init - # FIXME: This is for backward compatibility only - # dhclient needs to set just one dhcp enabled interface to - # DHCLIENT_SET_DEFAULT_ROUTE=yes. Otherwise interface is selected more - # or less randomly (bnc#868187). However, UI is not ready for such change yet. - # As it could easily happen that all interfaces are set to "no" (and - # default route is unreachable in such case) this explicit setup was - # added. - # FIXME: not implemented in network-ng - Yast::LanItems.set_default_route = true - end - # @return [Y2Network::InterfaceConfigBuilder, nil] returns new builder when type selected # or nil if canceled def run - legacy_init - ret = super log.info "AddInterface result #{ret}" ret = :back if ret == :abort diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.4.3/src/lib/y2network/interface.rb new/yast2-network-4.4.5/src/lib/y2network/interface.rb --- old/yast2-network-4.4.3/src/lib/y2network/interface.rb 2021-04-13 15:07:47.000000000 +0200 +++ new/yast2-network-4.4.5/src/lib/y2network/interface.rb 2021-04-22 18:43:00.000000000 +0200 @@ -135,6 +135,8 @@ # @return [Boolean] true if the interface is hotplug def hotplug? + return false unless hardware + ["usb", "pcmcia"].include?(hardware.hotplug) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.4.3/src/lib/y2network/interface_config_builder.rb new/yast2-network-4.4.5/src/lib/y2network/interface_config_builder.rb --- old/yast2-network-4.4.3/src/lib/y2network/interface_config_builder.rb 2021-04-13 15:07:47.000000000 +0200 +++ new/yast2-network-4.4.5/src/lib/y2network/interface_config_builder.rb 2021-04-22 18:43:00.000000000 +0200 @@ -397,7 +397,7 @@ def ip_config_default return @connection_config.ip if @connection_config.ip - @connection_config.ip = ConnectionConfig::IPConfig.new(IPAddress.new("0.0.0.0")) + @connection_config.ip = ConnectionConfig::IPConfig.new(IPAddress.from_string("0.0.0.0/32")) end # Returns the connection config class for a given type diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.4.3/src/lib/y2network/virtualization_config.rb new/yast2-network-4.4.5/src/lib/y2network/virtualization_config.rb --- old/yast2-network-4.4.3/src/lib/y2network/virtualization_config.rb 2021-04-13 15:07:47.000000000 +0200 +++ new/yast2-network-4.4.5/src/lib/y2network/virtualization_config.rb 2021-04-22 18:43:00.000000000 +0200 @@ -20,8 +20,6 @@ require "yast" require "y2network/interface_config_builder" -Yast.import "LanItems" - module Y2Network # This class is responsible for creating a bridge configuration for # virtualization from the interfaces that are connected and bridgeable. @@ -72,7 +70,7 @@ bridge_builder.save # Move routes from the port member to the bridge (bsc#903889) - Yast::LanItems.move_routes(builder.name, bridge_builder.name) + move_routes(builder.name, bridge_builder.name) end true @@ -80,6 +78,30 @@ private + # Adds a new interface with the given name + def add_device_to_routing(name) + return if !config + return if config.interfaces.any? { |i| i.name == name } + + config.interfaces << Y2Network::Interface.new(name) + end + + # Assigns all the routes from one interface to another + # + # @param from [String] interface belonging the routes to be moved + # @param to [String] target interface + def move_routes(from, to) + return unless config&.routing + + routing = config.routing + add_device_to_routing(to) + target_interface = config.interfaces.by_name(to) + return unless target_interface + + routing.routes.select { |r| r.interface && r.interface.name == from } + .each { |r| r.interface = target_interface } + end + # Convenience method that returns true if the interface given is connected # and can be added as a bridge port. # diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.4.3/src/lib/y2network/wicked/connection_config_writers/base.rb new/yast2-network-4.4.5/src/lib/y2network/wicked/connection_config_writers/base.rb --- old/yast2-network-4.4.3/src/lib/y2network/wicked/connection_config_writers/base.rb 2021-04-13 15:07:47.000000000 +0200 +++ new/yast2-network-4.4.5/src/lib/y2network/wicked/connection_config_writers/base.rb 2021-04-22 18:43:00.000000000 +0200 @@ -51,7 +51,7 @@ file.ifplugd_priority = conn.startmode.priority if conn.startmode.to_s == "ifplugd" file.ethtool_options = value_as_string(conn.ethtool_options) file.zone = value_as_string(conn.firewall_zone) - file.mtu = value_as_string(conn.mtu) + file.mtu = conn.mtu unless conn.mtu.to_i.zero? add_ips(conn) update_file(conn) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.4.3/src/lib/y2network/widgets/s390_common.rb new/yast2-network-4.4.5/src/lib/y2network/widgets/s390_common.rb --- old/yast2-network-4.4.3/src/lib/y2network/widgets/s390_common.rb 2021-04-13 15:07:47.000000000 +0200 +++ new/yast2-network-4.4.5/src/lib/y2network/widgets/s390_common.rb 2021-04-22 18:43:00.000000000 +0200 @@ -19,6 +19,7 @@ require "cwm/common_widgets" require "cwm/custom_widget" +require "ui/text_helpers" module Y2Network module Widgets @@ -212,6 +213,7 @@ # and an input field for setting the mac address to be used in case of # enablement. class S390Layer2 < CWM::CustomWidget + include ::UI::TextHelpers # Constructor # # @param settings [Y2Network::InterfaceConfigBuilder] @@ -244,15 +246,41 @@ nil end + # @see CWM::AbstractWidget def validate - return true if !layer2? || valid_mac?(mac_address_widget.value) + return true if !layer2? || !lladdress_for(mac_address_widget.value) + + unless valid_mac?(mac_address_widget.value) + report_mac_error + + return false + end + + use_selected_mac? + end - report_mac_error - false + # @see CWM::AbstractWidget + def store + @settings.layer2 = layer2? + @settings.lladdress = layer2? ? lladdress_for(mac_address_widget.value) : nil end private + def use_selected_mac? + Yast::Popup.YesNoHeadline( + Yast::Label.WarningMsg, + wrap_text(format( + # TRANSLATORS: Popup trying to prevent the user to set an specific MAC address + _("Specifying a MAC address is optional.\n\n" \ + "In most cases, leaving it empty and taking the default " \ + "assigned by the system is the correct choice.\n\n" \ + "Do you really want to set it to '%s'?"), + mac_address_widget.value + )) + ) + end + def report_mac_error # TRANSLATORS: Popup error about not valid MAC address provided msg = _("The MAC address provided is not valid, please provide a valid one.") @@ -272,12 +300,23 @@ # @return [Boolean] true when valid; false otherwise # @param mac_address [String] def valid_mac?(mac_address) - return false if mac_address.to_s.empty? - return false if mac_address == "00:00:00:00:00:00" + return true unless lladdress_for(mac_address) !!(mac_address =~ /^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/i) end + # Return the MAC address in case it is not empty or a zero's MAC address + # otherwise it returns nil. + # + # @param mac_widget_value [String] + # @return [String, nil] the MAC address in case it is not empty or a + # zero's MAC address; nil otherwise + def lladdress_for(mac_widget_value) + return if ["", "00:00:00:00:00:00"].include?(mac_widget_value.to_s) + + mac_widget_value + end + # Convenience method to enable or disable the mac address widget when the # layer2 support is modified def refresh @@ -326,11 +365,6 @@ "<p>Select <b>Enable Layer 2 Support</b> if this card has been " \ "configured with layer 2 support.</p>" end - - # @see CWM::AbstractWidget - def store - @settings.layer2 = value - end end # Widget for setting the mac address to be used in case of layer2 supported @@ -350,18 +384,13 @@ # @see CWM::AbstractWidget def label - _("Layer2 MAC Address") + _("Layer2 MAC Address (optional)") end # @see CWM::AbstractWidget def help _("<p>Enter the <b>Layer 2 MAC Address</b> if this card has been " \ - "configured with layer 2 support.</p>") - end - - # @see CWM::AbstractWidget - def store - @settings.lladdress = value + "configured with layer 2 support <b>(optional)</b>.</p>") end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.4.3/src/modules/LanItems.rb new/yast2-network-4.4.5/src/modules/LanItems.rb --- old/yast2-network-4.4.3/src/modules/LanItems.rb 2021-04-13 15:07:47.000000000 +0200 +++ new/yast2-network-4.4.5/src/modules/LanItems.rb 2021-04-22 18:43:00.000000000 +0200 @@ -323,35 +323,6 @@ publish variable: name, type: type end - # Adds a new interface with the given name - # - # @todo This method exists just to keep some compatibility during - # the migration to network-ng. - def add_device_to_routing(name = current_name) - config = yast_config - return if config.nil? - return if config.interfaces.any? { |i| i.name == name } - - yast_config.interfaces << Y2Network::Interface.new(name) - end - - # Assigns all the routes from one interface to another - # - # @param from [String] interface belonging the routes to be moved - # @param to [String] target interface - def move_routes(from, to) - config = yast_config - return unless config&.routing - - routing = config.routing - add_device_to_routing(to) - target_interface = config.interfaces.by_name(to) - return unless target_interface - - routing.routes.select { |r| r.interface && r.interface.name == from } - .each { |r| r.interface = target_interface } - end - private # Searches available items according sysconfig option diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.4.3/test/lan_items_helpers_test.rb new/yast2-network-4.4.5/test/lan_items_helpers_test.rb --- old/yast2-network-4.4.3/test/lan_items_helpers_test.rb 2021-04-13 15:07:47.000000000 +0200 +++ new/yast2-network-4.4.5/test/lan_items_helpers_test.rb 2021-04-22 18:43:00.000000000 +0200 @@ -204,87 +204,3 @@ 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) - end - - describe "LanItems.add_device_to_routing" do - let(:eth0) { Y2Network::Interface.new("eth0") } - let(:wlan0) { Y2Network::Interface.new("wlan0") } - let(:interfaces) { Y2Network::InterfacesCollection.new([eth0, wlan0]) } - - let(:yast_config) do - instance_double(Y2Network::Config, interfaces: interfaces, routing: double("routing")) - end - - before do - allow(Y2Network::Config).to receive(:find).with(:yast).and_return(yast_config) - allow(Yast::LanItems).to receive(:current_name).and_return("wlan1") - end - - context "when a device name is given" do - it "adds a new device with the given name" do - Yast::LanItems.add_device_to_routing("br0") - names = yast_config.interfaces.map(&:name) - expect(names).to include("br0") - end - end - - context "when no device name is given" do - it "adds a new device with the current device name" do - Yast::LanItems.add_device_to_routing - names = yast_config.interfaces.map(&:name) - expect(names).to include("wlan1") - end - end - - context "when the interface already exists" do - before do - allow(Yast::LanItems).to receive(:current_name).and_return("wlan0") - end - - it "does not add any interface" do - Yast::LanItems.add_device_to_routing - names = yast_config.interfaces.map(&:name) - expect(names).to eq(["eth0", "wlan0"]) - end - end - end - - describe "LanItems.move_routes" do - let(:routing) { Y2Network::Routing.new(tables: [table1]) } - let(:table1) { Y2Network::RoutingTable.new(routes) } - let(:routes) { [route] } - let(:route) do - Y2Network::Route.new(to: :default, - gateway: IPAddr.new("192.168.122.1"), - interface: eth0) - end - let(:eth0) { Y2Network::Interface.new("eth0") } - let(:br0) { Y2Network::Interface.new("br0") } - let(:interfaces) { Y2Network::InterfacesCollection.new([eth0, br0]) } - let(:yast_config) do - instance_double(Y2Network::Config, interfaces: interfaces, routing: routing) - end - - before do - allow(Y2Network::Config).to receive(:find).with(:yast).and_return(yast_config) - end - - it "assigns all the 'from' routes to the 'to' interface" do - expect { Yast::LanItems.move_routes("eth0", "br0") } - .to change { route.interface }.from(eth0).to(br0) - end - end -end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.4.3/test/y2network/interface_test.rb new/yast2-network-4.4.5/test/y2network/interface_test.rb --- old/yast2-network-4.4.3/test/y2network/interface_test.rb 2021-04-13 15:07:47.000000000 +0200 +++ new/yast2-network-4.4.5/test/y2network/interface_test.rb 2021-04-22 18:43:00.000000000 +0200 @@ -155,4 +155,53 @@ end end end + + describe "#hotplug?" do + context "when the interface does not contain hardware information" do + subject(:interface) { Y2Network::PhysicalInterface.new("br0") } + + it "returns false" do + expect(interface.hotplug?).to eql(false) + end + end + + context "when the interface contains hardware information" do + let(:hardware) do + Y2Network::Hwinfo.new(name: "Ethernet Connection I217-LM", + dev_name: "enp0s25", mac: "01:23:45:67:89:ab") + end + + subject(:interface) do + Y2Network::PhysicalInterface.new("eth0", hardware: hardware) + end + + context "and it is not a hotplug interface" do + it "returns false" do + expect(interface.hotplug?).to eql(false) + end + end + + context "and it is an usb hotplug interface" do + let(:hardware) do + Y2Network::Hwinfo.new(name: "100Mbps Network Card Adapter", + dev_name: "enp0s20u5c2", mac: "01:23:45:67:89:ab", hotplug: "usb") + end + + it "returns true" do + expect(interface.hotplug?).to eql(true) + end + end + + context "and it is a pcmcia hotplug interface" do + let(:hardware) do + Y2Network::Hwinfo.new(name: "100Mbps Network Card Adapter", + dev_name: "enp0s20u5c2", mac: "01:23:45:67:89:ab", hotplug: "pcmcia") + end + + it "returns true" do + expect(interface.hotplug?).to eql(true) + end + end + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.4.3/test/y2network/virtualization_config_test.rb new/yast2-network-4.4.5/test/y2network/virtualization_config_test.rb --- old/yast2-network-4.4.3/test/y2network/virtualization_config_test.rb 2021-04-13 15:07:47.000000000 +0200 +++ new/yast2-network-4.4.5/test/y2network/virtualization_config_test.rb 2021-04-22 18:43:00.000000000 +0200 @@ -105,4 +105,53 @@ end end end + + describe ".add_device_to_routing" do + let(:eth0) { Y2Network::Interface.new("eth0") } + let(:wlan0) { Y2Network::Interface.new("wlan0") } + let(:interfaces) { Y2Network::InterfacesCollection.new([eth0, wlan0]) } + + let(:config) do + Y2Network::Config.new(interfaces: interfaces, source: :testing) + end + + context "when a device name is given" do + it "adds a new device with the given name" do + virt_config.send(:add_device_to_routing, "br0") + names = config.interfaces.map(&:name) + expect(names).to include("br0") + end + end + + context "when the interface already exists" do + it "does not add any interface" do + virt_config.send(:add_device_to_routing, "wlan0") + names = config.interfaces.map(&:name) + expect(names).to eq(["eth0", "wlan0"]) + end + end + end + + describe ".move_routes" do + let(:routing) { Y2Network::Routing.new(tables: [table1]) } + let(:table1) { Y2Network::RoutingTable.new(routes) } + let(:routes) { [route] } + let(:route) do + Y2Network::Route.new(to: :default, + gateway: IPAddr.new("192.168.122.1"), + interface: eth0) + end + let(:eth0) { Y2Network::Interface.new("eth0") } + let(:br0) { Y2Network::Interface.new("br0") } + let(:interfaces) { Y2Network::InterfacesCollection.new([eth0, br0]) } + + let(:config) do + Y2Network::Config.new(interfaces: interfaces, routing: routing, source: :testing) + end + + it "assigns all the 'from' routes to the 'to' interface" do + expect { virt_config.send(:move_routes, "eth0", "br0") } + .to change { route.interface }.from(eth0).to(br0) + end + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.4.3/test/y2network/wicked/connection_config_writers/bonding_test.rb new/yast2-network-4.4.5/test/y2network/wicked/connection_config_writers/bonding_test.rb --- old/yast2-network-4.4.3/test/y2network/wicked/connection_config_writers/bonding_test.rb 2021-04-13 15:07:47.000000000 +0200 +++ new/yast2-network-4.4.5/test/y2network/wicked/connection_config_writers/bonding_test.rb 2021-04-22 18:43:00.000000000 +0200 @@ -36,6 +36,7 @@ c.bootproto = Y2Network::BootProtocol::DHCP c.slaves = ["eth0", "eth1"] c.options = "mode=active-backup miimon=100" + c.mtu = 9000 end end @@ -46,7 +47,8 @@ handler.write(conn) expect(file).to have_attributes( startmode: "auto", - bootproto: "dhcp" + bootproto: "dhcp", + mtu: 9000 ) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.4.3/test/y2network/wicked/connection_config_writers/ethernet_test.rb new/yast2-network-4.4.5/test/y2network/wicked/connection_config_writers/ethernet_test.rb --- old/yast2-network-4.4.3/test/y2network/wicked/connection_config_writers/ethernet_test.rb 2021-04-13 15:07:47.000000000 +0200 +++ new/yast2-network-4.4.5/test/y2network/wicked/connection_config_writers/ethernet_test.rb 2021-04-22 18:43:00.000000000 +0200 @@ -79,7 +79,8 @@ name: conn.description, bootproto: "static", startmode: "auto", - dhclient_set_hostname: "yes" + dhclient_set_hostname: "yes", + mtu: nil ) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-4.4.3/test/y2network/widgets/s390_common_test.rb new/yast2-network-4.4.5/test/y2network/widgets/s390_common_test.rb --- old/yast2-network-4.4.3/test/y2network/widgets/s390_common_test.rb 2021-04-13 15:07:47.000000000 +0200 +++ new/yast2-network-4.4.5/test/y2network/widgets/s390_common_test.rb 2021-04-22 18:43:00.000000000 +0200 @@ -121,15 +121,42 @@ end context "when the layer2 support is enabled" do - context "and the MAC provided is valid" do - let(:layer2_address) { "02:00:00:00:01:FD" } + context "and the MAC address is empty" do + let(:layer2_address) { "" } it "returns true" do expect(subject.validate).to eql(true) end end + context "and the MAC address is '00:00:00:00:00:00'" do + it "returns true" do + expect(subject.validate).to eql(true) + end + end + + context "and the MAC provided is a valid one" do + let(:layer2_address) { "02:00:00:00:01:FD" } + + it "requests user confirmation before storing the defined MAC" do + expect(subject).to receive(:use_selected_mac?) + subject.validate + end + + it "returns true if the user accepts" do + allow(subject).to receive(:use_selected_mac?).and_return(true) + expect(subject.validate).to eql(true) + end + + it "returns false if the user reject" do + allow(subject).to receive(:use_selected_mac?).and_return(false) + expect(subject.validate).to eql(false) + end + end + context "and the MAC address provided is invalid" do + let(:layer2_address) { "02:00:00:00:01" } + it "returns false" do allow(Yast::Popup).to receive(:Error) expect(subject.validate).to eql(false) @@ -142,6 +169,45 @@ end end end + + describe "#store" do + context "when the layer2 support checkbox is checked" do + it "sets the builder layer2 attribute to true" do + expect(builder).to receive("layer2=").with(true) + subject.store + end + + context "and the MAC address is not empty and neither it is '00:00:00:00:00:00'" do + let(:layer2_address) { "02:00:00:00:01" } + + it "sets the builder lladdress attribute to the MAC address widget value" do + expect(builder).to receive("lladdress=").with("02:00:00:00:01") + subject.store + end + end + + context "and the MAC address is empty or '00:00:00:00:00:00'" do + it "sets the builder lladdress attribute to nil" do + expect(builder).to receive("lladdress=").with(nil) + subject.store + end + end + end + + context "when the layer2 support checkbox is not checked" do + let(:layer2_support) { false } + + it "sets the builder layer2 attribute to false" do + expect(builder).to receive("layer2=").with(false) + subject.store + end + + it "sets the builder lladdress attribute to nil" do + expect(builder).to receive("lladdress=").with(nil) + subject.store + end + end + end end describe Y2Network::Widgets::S390Layer2Support do