mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-08-06 22:32:54 +02:00
add linux netstat -r tests
This commit is contained in:
1
tests/fixtures/centos-7.7/netstat-r.json
vendored
Normal file
1
tests/fixtures/centos-7.7/netstat-r.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"destination": "default", "gateway": "gateway", "genmask": "0.0.0.0", "route_flags": "UG", "mss": 0, "window": 0, "irtt": 0, "iface": "ens33", "kind": "route"}, {"destination": "172.17.0.0", "gateway": "0.0.0.0", "genmask": "255.255.0.0", "route_flags": "U", "mss": 0, "window": 0, "irtt": 0, "iface": "docker0", "kind": "route"}, {"destination": "192.168.71.0", "gateway": "0.0.0.0", "genmask": "255.255.255.0", "route_flags": "U", "mss": 0, "window": 0, "irtt": 0, "iface": "ens33", "kind": "route"}]
|
1
tests/fixtures/centos-7.7/netstat-rne.json
vendored
Normal file
1
tests/fixtures/centos-7.7/netstat-rne.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"destination": "0.0.0.0", "gateway": "192.168.71.2", "genmask": "0.0.0.0", "route_flags": "UG", "metric": 100, "route_refs": 0, "use": 0, "iface": "ens33", "kind": "route"}, {"destination": "172.17.0.0", "gateway": "0.0.0.0", "genmask": "255.255.0.0", "route_flags": "U", "metric": 0, "route_refs": 0, "use": 0, "iface": "docker0", "kind": "route"}, {"destination": "192.168.71.0", "gateway": "0.0.0.0", "genmask": "255.255.255.0", "route_flags": "U", "metric": 100, "route_refs": 0, "use": 0, "iface": "ens33", "kind": "route"}]
|
1
tests/fixtures/centos-7.7/netstat-rnee.json
vendored
Normal file
1
tests/fixtures/centos-7.7/netstat-rnee.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"destination": "0.0.0.0", "gateway": "192.168.71.2", "genmask": "0.0.0.0", "route_flags": "UG", "metric": 100, "route_refs": 0, "use": 0, "iface": "ens33", "mss": 0, "window": 0, "irtt": 0, "kind": "route"}, {"destination": "172.17.0.0", "gateway": "0.0.0.0", "genmask": "255.255.0.0", "route_flags": "U", "metric": 0, "route_refs": 0, "use": 0, "iface": "docker", "mss": 0, "window": 0, "irtt": 0, "kind": "route"}, {"destination": "192.168.71.0", "gateway": "0.0.0.0", "genmask": "255.255.255.0", "route_flags": "U", "metric": 100, "route_refs": 0, "use": 0, "iface": "ens33", "mss": 0, "window": 0, "irtt": 0, "kind": "route"}]
|
1
tests/fixtures/ubuntu-18.04/netstat-r.json
vendored
Normal file
1
tests/fixtures/ubuntu-18.04/netstat-r.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"destination": "default", "gateway": "_gateway", "genmask": "0.0.0.0", "route_flags": "UG", "mss": 0, "window": 0, "irtt": 0, "iface": "ens33", "kind": "route"}, {"destination": "192.168.71.0", "gateway": "0.0.0.0", "genmask": "255.255.255.0", "route_flags": "U", "mss": 0, "window": 0, "irtt": 0, "iface": "ens33", "kind": "route"}, {"destination": "_gateway", "gateway": "0.0.0.0", "genmask": "255.255.255.255", "route_flags": "UH", "mss": 0, "window": 0, "irtt": 0, "iface": "ens33", "kind": "route"}]
|
5
tests/fixtures/ubuntu-18.04/netstat-r.out
vendored
Normal file
5
tests/fixtures/ubuntu-18.04/netstat-r.out
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
Kernel IP routing table
|
||||
Destination Gateway Genmask Flags MSS Window irtt Iface
|
||||
default _gateway 0.0.0.0 UG 0 0 0 ens33
|
||||
192.168.71.0 0.0.0.0 255.255.255.0 U 0 0 0 ens33
|
||||
_gateway 0.0.0.0 255.255.255.255 UH 0 0 0 ens33
|
1
tests/fixtures/ubuntu-18.04/netstat-rne.json
vendored
Normal file
1
tests/fixtures/ubuntu-18.04/netstat-rne.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"destination": "0.0.0.0", "gateway": "192.168.71.2", "genmask": "0.0.0.0", "route_flags": "UG", "metric": 100, "route_refs": 0, "use": 0, "iface": "ens33", "kind": "route"}, {"destination": "192.168.71.0", "gateway": "0.0.0.0", "genmask": "255.255.255.0", "route_flags": "U", "metric": 0, "route_refs": 0, "use": 0, "iface": "ens33", "kind": "route"}, {"destination": "192.168.71.2", "gateway": "0.0.0.0", "genmask": "255.255.255.255", "route_flags": "UH", "metric": 100, "route_refs": 0, "use": 0, "iface": "ens33", "kind": "route"}]
|
5
tests/fixtures/ubuntu-18.04/netstat-rne.out
vendored
Normal file
5
tests/fixtures/ubuntu-18.04/netstat-rne.out
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
Kernel IP routing table
|
||||
Destination Gateway Genmask Flags Metric Ref Use Iface
|
||||
0.0.0.0 192.168.71.2 0.0.0.0 UG 100 0 0 ens33
|
||||
192.168.71.0 0.0.0.0 255.255.255.0 U 0 0 0 ens33
|
||||
192.168.71.2 0.0.0.0 255.255.255.255 UH 100 0 0 ens33
|
1
tests/fixtures/ubuntu-18.04/netstat-rnee.json
vendored
Normal file
1
tests/fixtures/ubuntu-18.04/netstat-rnee.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
[{"destination": "0.0.0.0", "gateway": "192.168.71.2", "genmask": "0.0.0.0", "route_flags": "UG", "metric": 100, "route_refs": 0, "use": 0, "iface": "ens33", "mss": 0, "window": 0, "irtt": 0, "kind": "route"}, {"destination": "192.168.71.0", "gateway": "0.0.0.0", "genmask": "255.255.255.0", "route_flags": "U", "metric": 0, "route_refs": 0, "use": 0, "iface": "ens33", "mss": 0, "window": 0, "irtt": 0, "kind": "route"}, {"destination": "192.168.71.2", "gateway": "0.0.0.0", "genmask": "255.255.255.255", "route_flags": "UH", "metric": 100, "route_refs": 0, "use": 0, "iface": "ens33", "mss": 0, "window": 0, "irtt": 0, "kind": "route"}]
|
5
tests/fixtures/ubuntu-18.04/netstat-rnee.out
vendored
Normal file
5
tests/fixtures/ubuntu-18.04/netstat-rnee.out
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
Kernel IP routing table
|
||||
Destination Gateway Genmask Flags Metric Ref Use Iface MSS Window irtt
|
||||
0.0.0.0 192.168.71.2 0.0.0.0 UG 100 0 0 ens33 0 0 0
|
||||
192.168.71.0 0.0.0.0 255.255.255.0 U 0 0 0 ens33 0 0 0
|
||||
192.168.71.2 0.0.0.0 255.255.255.255 UH 100 0 0 ens33 0 0 0
|
@ -9,7 +9,11 @@ THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
class MyTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
#
|
||||
# input
|
||||
#
|
||||
|
||||
# netstat
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/netstat.out'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_netstat = f.read()
|
||||
|
||||
@ -52,6 +56,24 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/netstat-Abn.out'), 'r', encoding='utf-8') as f:
|
||||
self.osx_14_6_netstat_Abn = f.read()
|
||||
|
||||
# netstat -r
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/netstat-r.out'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_netstat_r = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/netstat-rne.out'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_netstat_rne = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/netstat-rnee.out'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_netstat_rnee = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/netstat-r.out'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_netstat_r = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/netstat-rne.out'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_netstat_rne = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/netstat-rnee.out'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_netstat_rnee = f.read()
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/netstat-r.out'), 'r', encoding='utf-8') as f:
|
||||
self.osx_14_6_netstat_r = f.read()
|
||||
@ -59,7 +81,11 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/netstat-rnl.out'), 'r', encoding='utf-8') as f:
|
||||
self.osx_14_6_netstat_rnl = f.read()
|
||||
|
||||
#
|
||||
# output
|
||||
#
|
||||
|
||||
# netstat
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/netstat.json'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_netstat_json = json.loads(f.read())
|
||||
|
||||
@ -102,6 +128,25 @@ class MyTests(unittest.TestCase):
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/netstat-Abn.json'), 'r', encoding='utf-8') as f:
|
||||
self.osx_14_6_netstat_Abn_json = json.loads(f.read())
|
||||
|
||||
# netsat -r
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/netstat-r.json'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_netstat_r_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/netstat-rne.json'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_netstat_rne_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/netstat-rnee.json'), 'r', encoding='utf-8') as f:
|
||||
self.centos_7_7_netstat_rnee_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/netstat-r.json'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_netstat_r_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/netstat-rne.json'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_netstat_rne_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-18.04/netstat-rnee.json'), 'r', encoding='utf-8') as f:
|
||||
self.ubuntu_18_4_netstat_rnee_json = json.loads(f.read())
|
||||
|
||||
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/osx-10.14.6/netstat-r.json'), 'r', encoding='utf-8') as f:
|
||||
self.osx_14_6_netstat_r_json = json.loads(f.read())
|
||||
|
||||
@ -192,6 +237,42 @@ class MyTests(unittest.TestCase):
|
||||
"""
|
||||
self.assertEqual(jc.parsers.netstat.parse(self.osx_14_6_netstat_Abn, quiet=True), self.osx_14_6_netstat_Abn_json)
|
||||
|
||||
def test_netstat_r_centos_7_7(self):
|
||||
"""
|
||||
Test 'netstat -r' on Centos 7.7
|
||||
"""
|
||||
self.assertEqual(jc.parsers.netstat.parse(self.centos_7_7_netstat_r, quiet=True), self.centos_7_7_netstat_r_json)
|
||||
|
||||
def test_netstat_rne_centos_7_7(self):
|
||||
"""
|
||||
Test 'netstat -rne' on Centos 7.7
|
||||
"""
|
||||
self.assertEqual(jc.parsers.netstat.parse(self.centos_7_7_netstat_rne, quiet=True), self.centos_7_7_netstat_rne_json)
|
||||
|
||||
def test_netstat_rnee_centos_7_7(self):
|
||||
"""
|
||||
Test 'netstat -rnee' on Centos 7.7
|
||||
"""
|
||||
self.assertEqual(jc.parsers.netstat.parse(self.centos_7_7_netstat_rnee, quiet=True), self.centos_7_7_netstat_rnee_json)
|
||||
|
||||
def test_netstat_r_ubuntu_18_4(self):
|
||||
"""
|
||||
Test 'netstat -r' on Ubuntu 18.4
|
||||
"""
|
||||
self.assertEqual(jc.parsers.netstat.parse(self.ubuntu_18_4_netstat_r, quiet=True), self.ubuntu_18_4_netstat_r_json)
|
||||
|
||||
def test_netstat_rne_ubuntu_18_4(self):
|
||||
"""
|
||||
Test 'netstat -rne' on Ubuntu 18.4
|
||||
"""
|
||||
self.assertEqual(jc.parsers.netstat.parse(self.ubuntu_18_4_netstat_rne, quiet=True), self.ubuntu_18_4_netstat_rne_json)
|
||||
|
||||
def test_netstat_rnee_ubuntu_18_4(self):
|
||||
"""
|
||||
Test 'netstat -rnee' on Ubuntu 18.4
|
||||
"""
|
||||
self.assertEqual(jc.parsers.netstat.parse(self.ubuntu_18_4_netstat_rnee, quiet=True), self.ubuntu_18_4_netstat_rnee_json)
|
||||
|
||||
def test_netstat_r_osx_16_4(self):
|
||||
"""
|
||||
Test 'netstat -r' on OSX 16.4
|
||||
|
Reference in New Issue
Block a user