mirror of
https://github.com/inspec/inspec
synced 2024-11-10 07:04:15 +00:00
Updated test files to use Ubuntu latest version while mocking the OS instead of Ubuntu1804
Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
This commit is contained in:
parent
86391be836
commit
ff65112ab5
2 changed files with 12 additions and 13 deletions
|
@ -19,7 +19,6 @@ class MockLoader
|
|||
macos10_10: { name: "mac_os_x", family: "darwin", release: "10.10.4", arch: nil },
|
||||
macos10_16: { name: "darwin", family: "darwin", release: "10.16", arch: nil },
|
||||
ubuntu1404: { name: "ubuntu", family: "debian", release: "14.04", arch: "x86_64" },
|
||||
ubuntu1804: { name: "ubuntu", family: "debian", release: "18.04", arch: "x86_64" },
|
||||
ubuntu: { name: "ubuntu", family: "debian", release: "20.04", arch: "x86_64" },
|
||||
mint17: { name: "linuxmint", family: "debian", release: "17.3", arch: "x86_64" },
|
||||
mint18: { name: "linuxmint", family: "debian", release: "18", arch: "x86_64" },
|
||||
|
@ -38,7 +37,7 @@ class MockLoader
|
|||
undefined: { name: nil, family: nil, release: nil, arch: nil },
|
||||
}
|
||||
|
||||
OPERATING_SYSTEMS[:linux] = OPERATING_SYSTEMS[:ubuntu1604]
|
||||
OPERATING_SYSTEMS[:linux] = OPERATING_SYSTEMS[:ubuntu]
|
||||
|
||||
# pass the os identifier to emulate a specific operating system
|
||||
def initialize(os = :ubuntu)
|
||||
|
|
|
@ -3,8 +3,8 @@ require "inspec/resource"
|
|||
require "inspec/resources/port"
|
||||
|
||||
describe "Inspec::Resources::Port" do
|
||||
it "verify port on Ubuntu 14.04" do
|
||||
resource = MockLoader.new(:ubuntu1804).load_resource("port", 22)
|
||||
it "verify port on Ubuntu" do
|
||||
resource = MockLoader.new(:ubuntu).load_resource("port", 22)
|
||||
_(resource.listening?).must_equal true
|
||||
_(resource.protocols).must_equal %w{ tcp tcp6 }
|
||||
_(resource.pids).must_equal [1222]
|
||||
|
@ -13,7 +13,7 @@ describe "Inspec::Resources::Port" do
|
|||
end
|
||||
|
||||
it "lists all ports" do
|
||||
resource = MockLoader.new(:ubuntu1804).load_resource("port")
|
||||
resource = MockLoader.new(:ubuntu).load_resource("port")
|
||||
_(resource.entries.length).must_equal 9
|
||||
_(resource.listening?).must_equal true
|
||||
_(resource.protocols).must_equal %w{ udp tcp tcp6 }
|
||||
|
@ -23,7 +23,7 @@ describe "Inspec::Resources::Port" do
|
|||
end
|
||||
|
||||
it "filter ports by conditions" do
|
||||
resource = MockLoader.new(:ubuntu1804).load_resource("port").where { protocol =~ /udp/i }
|
||||
resource = MockLoader.new(:ubuntu).load_resource("port").where { protocol =~ /udp/i }
|
||||
_(resource.entries.length).must_equal 1
|
||||
_(resource.listening?).must_equal true
|
||||
_(resource.protocols).must_equal ["udp"]
|
||||
|
@ -32,8 +32,8 @@ describe "Inspec::Resources::Port" do
|
|||
_(resource.addresses).must_equal ["0.0.0.0"]
|
||||
end
|
||||
|
||||
it "verify UDP port on Ubuntu 14.04" do
|
||||
resource = MockLoader.new(:ubuntu1804).load_resource("port", 68)
|
||||
it "verify UDP port on Ubuntu" do
|
||||
resource = MockLoader.new(:ubuntu).load_resource("port", 68)
|
||||
_(resource.entries.length).must_equal 1
|
||||
_(resource.listening?).must_equal true
|
||||
_(resource.protocols).must_equal ["udp"]
|
||||
|
@ -43,7 +43,7 @@ describe "Inspec::Resources::Port" do
|
|||
end
|
||||
|
||||
it "accepts the port as a string" do
|
||||
resource = MockLoader.new(:ubuntu1804).load_resource("port", "68")
|
||||
resource = MockLoader.new(:ubuntu).load_resource("port", "68")
|
||||
_(resource.entries.length).must_equal 1
|
||||
_(resource.listening?).must_equal true
|
||||
_(resource.protocols).must_equal ["udp"]
|
||||
|
@ -53,7 +53,7 @@ describe "Inspec::Resources::Port" do
|
|||
end
|
||||
|
||||
it "properly handles multiple processes using one fd" do
|
||||
resource = MockLoader.new(:ubuntu1804).load_resource("port", "80")
|
||||
resource = MockLoader.new(:ubuntu).load_resource("port", "80")
|
||||
_(resource.entries.length).must_equal 1
|
||||
_(resource.listening?).must_equal true
|
||||
_(resource.protocols).must_equal ["tcp"]
|
||||
|
@ -63,7 +63,7 @@ describe "Inspec::Resources::Port" do
|
|||
end
|
||||
|
||||
it "properly handles a IPv4 address in a v6 listing" do
|
||||
resource = MockLoader.new(:ubuntu1804).load_resource("port", 9200)
|
||||
resource = MockLoader.new(:ubuntu).load_resource("port", 9200)
|
||||
_(resource.protocols).must_equal %w{ tcp tcp6 }
|
||||
_(resource.addresses).must_equal ["10.0.2.15", "fe80::a00:27ff:fe32:ed09"]
|
||||
end
|
||||
|
@ -185,7 +185,7 @@ describe "Inspec::Resources::Port" do
|
|||
end
|
||||
|
||||
it "verify port and interface on Ubuntu 14.04" do
|
||||
resource = MockLoader.new(:ubuntu1804).load_resource("port", "0.0.0.0", 22)
|
||||
resource = MockLoader.new(:ubuntu).load_resource("port", "0.0.0.0", 22)
|
||||
_(resource.listening?).must_equal true
|
||||
_(resource.protocols).must_equal %w{ tcp }
|
||||
_(resource.pids).must_equal [1222]
|
||||
|
@ -194,7 +194,7 @@ describe "Inspec::Resources::Port" do
|
|||
end
|
||||
|
||||
it "verify not listening port on interface on Ubuntu 14.04" do
|
||||
resource = MockLoader.new(:ubuntu1804).load_resource("port", "127.0.0.1", 22)
|
||||
resource = MockLoader.new(:ubuntu).load_resource("port", "127.0.0.1", 22)
|
||||
_(resource.listening?).must_equal false
|
||||
_(resource.addresses).must_equal []
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue