Removed old ubuntu version from mock_loader file as it's not getting used and added new version of Ubuntu in mock_loader file.

Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
This commit is contained in:
Vasu1105 2021-05-17 11:28:39 +05:30
parent 7990b31f5f
commit da75f0ce33
3 changed files with 20 additions and 10 deletions

10
test/fixtures/cmd/ss-tulpen-port vendored Normal file
View file

@ -0,0 +1,10 @@
Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port
udp UNCONN 0 0 *:68 *:* users:(("dhclient",pid=1146,fd=6)) ino:15168 sk:1 <->
tcp LISTEN 0 128 *:22 *:* users:(("sshd",pid=1222,fd=3)) ino:15973 sk:2 <->
tcp LISTEN 0 128 ::ffff:10.0.2.15:9200 :::* users:(("java",pid=1722,fd=125)) uid:112 ino:19543 sk:8 v6only:0 <->
tcp LISTEN 0 128 fe80::a00:27ff:fe32:ed09%enp0s3:9200 :::* users:(("java",pid=1722,fd=124)) uid:112 ino:19542 sk:9 v6only:1 <->
tcp LISTEN 0 128 ::ffff:10.0.2.15:9300 :::* users:(("java",pid=1722,fd=117)) uid:112 ino:19502 sk:a v6only:0 <->
tcp LISTEN 0 128 fe80::a00:27ff:fe32:ed09%enp0s3:9300 :::* users:(("java",pid=1722,fd=115)) uid:112 ino:19494 sk:b v6only:1 <->
tcp LISTEN 0 128 :::22 :::* users:(("sshd",pid=1222,fd=4)) ino:15982 sk:3 v6only:1 <->
tcp LISTEN 0 128 *:80 *:* users:(("nginx",pid=583,fd=8),("nginx",pid=582,fd=8),("nginx",pid=580,fd=8),("nginx",pid=579,fd=8)) ino:14427 sk:ffff8800baf12080 <->
tcp 0 128 *:25 *:* users:(("sendmail",3965,4)) ino:11604 sk:ffff88013a3b5800

View file

@ -18,10 +18,10 @@ class MockLoader
freebsd12: { name: "freebsd", family: "bsd", release: "12", arch: "amd64" },
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 },
ubuntu1204: { name: "ubuntu", family: "debian", release: "12.04", arch: "x86_64" },
ubuntu1404: { name: "ubuntu", family: "debian", release: "14.04", arch: "x86_64" },
ubuntu1504: { name: "ubuntu", family: "debian", release: "15.04", arch: "x86_64" },
ubuntu1604: { name: "ubuntu", family: "debian", release: "16.04", arch: "x86_64" },
ubuntu1804: { name: "ubuntu", family: "debian", release: "18.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" },
windows: { name: "windows", family: "windows", release: "6.2.9200", arch: "x86_64" },

View file

@ -4,7 +4,7 @@ require "inspec/resources/port"
describe "Inspec::Resources::Port" do
it "verify port on Ubuntu 14.04" do
resource = MockLoader.new(:ubuntu1604).load_resource("port", 22)
resource = MockLoader.new(:ubuntu1804).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(:ubuntu1604).load_resource("port")
resource = MockLoader.new(:ubuntu1804).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(:ubuntu1604).load_resource("port").where { protocol =~ /udp/i }
resource = MockLoader.new(:ubuntu1804).load_resource("port").where { protocol =~ /udp/i }
_(resource.entries.length).must_equal 1
_(resource.listening?).must_equal true
_(resource.protocols).must_equal ["udp"]
@ -33,7 +33,7 @@ describe "Inspec::Resources::Port" do
end
it "verify UDP port on Ubuntu 14.04" do
resource = MockLoader.new(:ubuntu1604).load_resource("port", 68)
resource = MockLoader.new(:ubuntu1804).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(:ubuntu1604).load_resource("port", "68")
resource = MockLoader.new(:ubuntu1804).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(:ubuntu1604).load_resource("port", "80")
resource = MockLoader.new(:ubuntu1804).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(:ubuntu1604).load_resource("port", 9200)
resource = MockLoader.new(:ubuntu1804).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(:ubuntu1604).load_resource("port", "0.0.0.0", 22)
resource = MockLoader.new(:ubuntu1804).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(:ubuntu1604).load_resource("port", "127.0.0.1", 22)
resource = MockLoader.new(:ubuntu1804).load_resource("port", "127.0.0.1", 22)
_(resource.listening?).must_equal false
_(resource.addresses).must_equal []
end