Skip to content

Commit

Permalink
Merge pull request #1210 from yast/fix_no_hardware_hotplug
Browse files Browse the repository at this point in the history
Fix hotplug check when there is no hardware info
  • Loading branch information
teclator committed Apr 22, 2021
2 parents 8841321 + 17842e5 commit 2805ad6
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
7 changes: 7 additions & 0 deletions package/yast2-network.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Apr 22 09:12:38 UTC 2021 - Knut Anderssen <kanderssen@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 <kanderssen@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-network.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-network
Version: 4.4.4
Version: 4.4.5
Release: 0
Summary: YaST2 - Network Configuration
License: GPL-2.0-only
Expand Down
2 changes: 2 additions & 0 deletions src/lib/y2network/interface.rb
Expand Up @@ -135,6 +135,8 @@ def update_udev_rule

# @return [Boolean] true if the interface is hotplug
def hotplug?
return false unless hardware

["usb", "pcmcia"].include?(hardware.hotplug)
end
end
Expand Down
49 changes: 49 additions & 0 deletions test/y2network/interface_test.rb
Expand Up @@ -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

0 comments on commit 2805ad6

Please sign in to comment.