Skip to content

Commit

Permalink
Use real connections objects in writers tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Jul 31, 2019
1 parent 82c4c43 commit 0d455dd
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 110 deletions.
20 changes: 9 additions & 11 deletions test/y2network/sysconfig/connection_config_writers/bonding_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,15 @@
subject(:handler) { described_class.new(file) }

let(:conn) do
instance_double(
Y2Network::ConnectionConfig::Bonding,
name: "bond0",
interface: "bond0",
description: "",
ip_configs: [],
startmode: Y2Network::Startmode.create("auto"),
bootproto: Y2Network::BootProtocol::DHCP,
slaves: ["eth0", "eth1"],
options: "mode=active-backup miimon=100"
)
Y2Network::ConnectionConfig::Bonding.new.tap do |c|
c.name = "bond0"
c.interface = "bond0"
c.description = ""
c.startmode = Y2Network::Startmode.create("auto")
c.bootproto = Y2Network::BootProtocol::DHCP
c.slaves = ["eth0", "eth1"]
c.options = "mode=active-backup miimon=100"
end
end

let(:file) { Y2Network::Sysconfig::InterfaceFile.new(conn.name) }
Expand Down
22 changes: 10 additions & 12 deletions test/y2network/sysconfig/connection_config_writers/bridge_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,16 @@
subject(:handler) { described_class.new(file) }

let(:conn) do
instance_double(
Y2Network::ConnectionConfig::Bridge,
name: "br1",
interface: "br1",
description: "",
startmode: Y2Network::Startmode.create("auto"),
bootproto: Y2Network::BootProtocol::DHCP,
ip_configs: [],
ports: ["eth0", "eth1"],
stp: false,
forward_delay: 5
)
Y2Network::ConnectionConfig::Bridge.new.tap do |c|
c.name = "br1"
c.interface = "br1"
c.description = ""
c.startmode = Y2Network::Startmode.create("auto")
c.bootproto = Y2Network::BootProtocol::DHCP
c.ports = ["eth0", "eth1"]
c.stp = false
c.forward_delay = 5
end
end

let(:file) { Y2Network::Sysconfig::InterfaceFile.new(conn.name) }
Expand Down
17 changes: 8 additions & 9 deletions test/y2network/sysconfig/connection_config_writers/dummy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,14 @@
end

let(:conn) do
instance_double(
Y2Network::ConnectionConfig::Dummy,
name: "dummy1",
interface: "dummy1",
description: "",
bootproto: Y2Network::BootProtocol::STATIC,
all_ips: [ip],
startmode: Y2Network::Startmode.create("auto")
)
Y2Network::ConnectionConfig::Dummy.new.tap do |c|
c.name = "dummy1"
c.interface = "dummy1"
c.description = ""
c.ip = ip
c.bootproto = Y2Network::BootProtocol::STATIC
c.startmode = Y2Network::Startmode.create("auto")
end
end

let(:file) { Y2Network::Sysconfig::InterfaceFile.new(conn.name) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,15 @@
end

let(:conn) do
instance_double(
Y2Network::ConnectionConfig::Infiniband,
name: "ib0",
interface: "ib0",
description: "",
ipoib_mode: Y2Network::IpoibMode::CONNECTED,
all_ips: [ip],
startmode: Y2Network::Startmode.create("auto"),
bootproto: Y2Network::BootProtocol::STATIC
)
Y2Network::ConnectionConfig::Infiniband.new.tap do |c|
c.name = "ib0"
c.interface = "ib0"
c.description = ""
c.ipoib_mode = Y2Network::IpoibMode::CONNECTED
c.ip = ip
c.startmode = Y2Network::Startmode.create("auto")
c.bootproto = Y2Network::BootProtocol::STATIC
end
end

let(:file) { Y2Network::Sysconfig::InterfaceFile.new(conn.name) }
Expand Down
20 changes: 9 additions & 11 deletions test/y2network/sysconfig/connection_config_writers/tap_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,15 @@ def file_content(scr_root, file)
end

let(:conn) do
instance_double(
Y2Network::ConnectionConfig::Tap,
name: "tap1",
interface: "tap1",
owner: "nobody",
group: "nobody",
description: "",
bootproto: Y2Network::BootProtocol::STATIC,
ip_configs: [],
startmode: Y2Network::Startmode.create("auto")
)
Y2Network::ConnectionConfig::Tap.new.tap do |c|
c.name = "tap1"
c.interface = "tap1"
c.owner = "nobody"
c.group = "nobody"
c.description = ""
c.bootproto = Y2Network::BootProtocol::STATIC
c.startmode = Y2Network::Startmode.create("auto")
end
end

let(:file) { Y2Network::Sysconfig::InterfaceFile.new(conn.name) }
Expand Down
20 changes: 9 additions & 11 deletions test/y2network/sysconfig/connection_config_writers/tun_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,15 @@ def file_content(scr_root, file)
end

let(:conn) do
instance_double(
Y2Network::ConnectionConfig::Tun,
name: "tun1",
interface: "tun1",
owner: "nobody",
group: "nobody",
description: "",
bootproto: Y2Network::BootProtocol::STATIC,
ip_configs: [],
startmode: Y2Network::Startmode.create("auto")
)
Y2Network::ConnectionConfig::Tun.new.tap do |c|
c.name = "tun1"
c.interface = "tun1"
c.owner = "nobody"
c.group = "nobody"
c.description = ""
c.bootproto = Y2Network::BootProtocol::STATIC
c.startmode = Y2Network::Startmode.create("auto")
end
end

let(:file) { Y2Network::Sysconfig::InterfaceFile.new(conn.name) }
Expand Down
20 changes: 9 additions & 11 deletions test/y2network/sysconfig/connection_config_writers/vlan_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@
subject(:handler) { described_class.new(file) }

let(:conn) do
instance_double(
Y2Network::ConnectionConfig::Vlan,
name: "eth0.100",
interface: "eth0.100",
description: "",
parent_device: "eth0",
vlan_id: 100,
all_ips: [],
startmode: Y2Network::Startmode.create("auto"),
bootproto: Y2Network::BootProtocol::DHCP
)
Y2Network::ConnectionConfig::Vlan.new.tap do |c|
c.name = "eth0.100"
c.interface = "eth0.100"
c.description = ""
c.parent_device = "eth0"
c.vlan_id = 100
c.startmode = Y2Network::Startmode.create("auto")
c.bootproto = Y2Network::BootProtocol::DHCP
end
end

let(:file) { Y2Network::Sysconfig::InterfaceFile.new(conn.name) }
Expand Down
70 changes: 35 additions & 35 deletions test/y2network/sysconfig/connection_config_writers/wireless_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@
let(:file) { Y2Network::Sysconfig::InterfaceFile.new("wlan0") }

let(:conn) do
Y2Network::ConnectionConfig::Wireless.new.tap do |conn|
conn.interface = "wlan0"
conn.description = "Wireless Card 0"
conn.startmode = Y2Network::Startmode.create("auto")
conn.bootproto = Y2Network::BootProtocol::STATIC
conn.ip = ip
conn.ip_aliases = [ip_alias]
conn.mode = "managed"
conn.essid = "example_essid"
conn.auth_mode = :open
conn.ap = "00:11:22:33:44:55"
conn.ap_scanmode = "1"
Y2Network::ConnectionConfig::Wireless.new.tap do |c|
c.interface = "wlan0"
c.description = "Wireless Card 0"
c.startmode = Y2Network::Startmode.create("auto")
c.bootproto = Y2Network::BootProtocol::STATIC
c.ip = ip
c.ip_aliases = [ip_alias]
c.mode = "managed"
c.essid = "example_essid"
c.auth_mode = :open
c.ap = "00:11:22:33:44:55"
c.ap_scanmode = "1"
end
end

Expand Down Expand Up @@ -84,15 +84,15 @@

context "WPA-EAP network configuration" do
let(:conn) do
Y2Network::ConnectionConfig::Wireless.new.tap do |conn|
conn.startmode = Y2Network::Startmode.create("auto")
conn.bootproto = Y2Network::BootProtocol::STATIC
conn.mode = "managed"
conn.essid = "example_essid"
conn.auth_mode = "eap"
conn.eap_mode = "PEAP"
conn.essid = "example_essid"
conn.wpa_password = "example_passwd"
Y2Network::ConnectionConfig::Wireless.new.tap do |c|
c.startmode = Y2Network::Startmode.create("auto")
c.bootproto = Y2Network::BootProtocol::STATIC
c.mode = "managed"
c.essid = "example_essid"
c.auth_mode = "eap"
c.eap_mode = "PEAP"
c.essid = "example_essid"
c.wpa_password = "example_passwd"
end
end

Expand All @@ -109,12 +109,12 @@

context "WPA-PSK network configuration" do
let(:conn) do
Y2Network::ConnectionConfig::Wireless.new.tap do |conn|
conn.startmode = Y2Network::Startmode.create("auto")
conn.bootproto = Y2Network::BootProtocol::STATIC
conn.mode = "managed"
conn.auth_mode = "psk"
conn.wpa_psk = "example_psk"
Y2Network::ConnectionConfig::Wireless.new.tap do |c|
c.startmode = Y2Network::Startmode.create("auto")
c.bootproto = Y2Network::BootProtocol::STATIC
c.mode = "managed"
c.auth_mode = "psk"
c.wpa_psk = "example_psk"
end
end

Expand All @@ -129,14 +129,14 @@

context "WEP network configuration" do
let(:conn) do
Y2Network::ConnectionConfig::Wireless.new.tap do |conn|
conn.startmode = Y2Network::Startmode.create("auto")
conn.bootproto = Y2Network::BootProtocol::STATIC
conn.mode = "managed"
conn.auth_mode = "shared"
conn.keys = ["123456", "abcdef"]
conn.key_length = 128
conn.default_key = 1
Y2Network::ConnectionConfig::Wireless.new.tap do |c|
c.startmode = Y2Network::Startmode.create("auto")
c.bootproto = Y2Network::BootProtocol::STATIC
c.mode = "managed"
c.auth_mode = "shared"
c.keys = ["123456", "abcdef"]
c.key_length = 128
c.default_key = 1
end
end

Expand Down

0 comments on commit 0d455dd

Please sign in to comment.