2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "inspec/resources/bridge"
|
2015-10-09 13:07:58 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "Inspec::Resources::Bridge" do
|
2015-10-09 13:07:58 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "check linux bridge on ubuntu" do
|
|
|
|
resource = MockLoader.new(:ubuntu1404).load_resource("bridge", "br0")
|
2015-10-09 13:07:58 +00:00
|
|
|
_(resource.exists?).must_equal true
|
|
|
|
|
|
|
|
# check network interfaced attached to bridge
|
2019-06-11 22:24:35 +00:00
|
|
|
_(resource.has_interface?("eth0")).must_equal false
|
|
|
|
_(resource.has_interface?("eth1")).must_equal true
|
|
|
|
_(resource.has_interface?("eth2")).must_equal true
|
2015-10-09 13:07:58 +00:00
|
|
|
|
|
|
|
# get associated interfaces
|
|
|
|
_(resource.interfaces).must_equal %w{eth1 eth2}
|
|
|
|
end
|
2015-10-09 13:10:43 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "check linux bridge on centos 7" do
|
|
|
|
resource = MockLoader.new(:centos7).load_resource("bridge", "br0")
|
2015-10-09 13:10:43 +00:00
|
|
|
_(resource.exists?).must_equal true
|
|
|
|
|
|
|
|
# check network interfaced attached to bridge
|
2019-06-11 22:24:35 +00:00
|
|
|
_(resource.has_interface?("eth0")).must_equal false
|
|
|
|
_(resource.has_interface?("eth1")).must_equal true
|
|
|
|
_(resource.has_interface?("eth2")).must_equal true
|
2015-10-09 13:10:43 +00:00
|
|
|
|
|
|
|
# get associated interfaces
|
|
|
|
_(resource.interfaces).must_equal %w{eth1 eth2}
|
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "check windows bridge" do
|
|
|
|
resource = MockLoader.new(:windows).load_resource("bridge", "Network Bridge")
|
2015-10-09 13:26:59 +00:00
|
|
|
_(resource.exists?).must_equal true
|
|
|
|
|
|
|
|
# get associated interfaces is not supported on windows
|
2017-06-11 10:16:10 +00:00
|
|
|
_(resource.interfaces).must_be_nil
|
2015-10-09 13:26:59 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "check bridge on unsupported os" do
|
|
|
|
resource = MockLoader.new(:undefined).load_resource("bridge", "br0")
|
2015-10-09 13:10:43 +00:00
|
|
|
_(resource.exists?).must_equal false
|
|
|
|
|
|
|
|
# check network interfaced attached to bridge
|
2019-06-11 22:24:35 +00:00
|
|
|
_(resource.has_interface?("eth0")).must_equal false
|
|
|
|
_(resource.has_interface?("eth1")).must_equal false
|
|
|
|
_(resource.has_interface?("eth2")).must_equal false
|
2015-10-09 13:10:43 +00:00
|
|
|
|
|
|
|
# get associated interfaces
|
2017-06-11 10:16:10 +00:00
|
|
|
_(resource.interfaces).must_be_nil
|
2015-10-09 13:10:43 +00:00
|
|
|
end
|
2015-10-09 13:07:58 +00:00
|
|
|
end
|