From 339238ab364d8735892a11cb16a62a651edae169 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Mon, 27 Jul 2020 20:37:33 -0700 Subject: [PATCH] version bump and add route -6 tests --- changelog.txt | 3 +++ jc/cli.py | 2 +- setup.py | 2 +- tests/fixtures/centos-7.7/route-6-n.json | 1 + tests/fixtures/centos-7.7/route-6-n.out | 24 ++++++++++++++++++++++++ tests/fixtures/centos-7.7/route-6.json | 1 + tests/fixtures/centos-7.7/route-6.out | 24 ++++++++++++++++++++++++ tests/test_route.py | 24 ++++++++++++++++++++++++ 8 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 tests/fixtures/centos-7.7/route-6-n.json create mode 100644 tests/fixtures/centos-7.7/route-6-n.out create mode 100644 tests/fixtures/centos-7.7/route-6.json create mode 100644 tests/fixtures/centos-7.7/route-6.out diff --git a/changelog.txt b/changelog.txt index 3a1d3f7a..a5c9ceb9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ jc changelog +20200727 v1.13.1 +- Add route -6 tests + 20200727 v1.13.0 - Add ping and ping6 command parser tested on linux, macos, and freebsd - Add traceroute and traceroute6 command parser tested on linux, macos, and freebsd diff --git a/jc/cli.py b/jc/cli.py index a68ddeb1..7eeeba24 100644 --- a/jc/cli.py +++ b/jc/cli.py @@ -21,7 +21,7 @@ import jc.appdirs as appdirs class info(): - version = '1.13.0' + version = '1.13.1' description = 'JSON CLI output utility' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' diff --git a/setup.py b/setup.py index d23701b8..903dc6dc 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open('README.md', 'r') as f: setuptools.setup( name='jc', - version='1.13.0', + version='1.13.1', author='Kelly Brazil', author_email='kellyjonbrazil@gmail.com', description='Converts the output of popular command-line tools and file-types to JSON.', diff --git a/tests/fixtures/centos-7.7/route-6-n.json b/tests/fixtures/centos-7.7/route-6-n.json new file mode 100644 index 00000000..2906de00 --- /dev/null +++ b/tests/fixtures/centos-7.7/route-6-n.json @@ -0,0 +1 @@ +[{"destination": "::/96", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "0.0.0.0/96", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:a00::/24", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:7f00::/24", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:a9fe::/32", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:ac10::/28", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:c0a8::/32", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:e000::/19", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2600:1700:bab0:d40::16/128", "next_hop": "::", "flags": "U", "metric": 100, "ref": 0, "use": 0, "iface": "ens33", "flags_pretty": ["UP"]}, {"destination": "2600:1700:bab0:d40::/64", "next_hop": "::", "flags": "U", "metric": 100, "ref": 1, "use": 45, "iface": "ens33", "flags_pretty": ["UP"]}, {"destination": "2600:1700:bab0:d40::/60", "next_hop": "fe80::feae:34ff:fea1:3a80", "flags": "UG", "metric": 100, "ref": 0, "use": 0, "iface": "ens33", "flags_pretty": ["UP", "GATEWAY"]}, {"destination": "3ffe:ffff::/32", "next_hop": "::", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "fe80::/64", "next_hop": "::", "flags": "U", "metric": 100, "ref": 0, "use": 4, "iface": "ens33", "flags_pretty": ["UP"]}, {"destination": "::/0", "next_hop": "fe80::feae:34ff:fea1:3a80", "flags": "UG", "metric": 100, "ref": 1, "use": 4, "iface": "ens33", "flags_pretty": ["UP", "GATEWAY"]}, {"destination": "::/0", "next_hop": "::", "flags": "!n", "metric": -1, "ref": 1, "use": 86, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "::1/128", "next_hop": "::", "flags": "Un", "metric": 0, "ref": 2, "use": 30, "iface": "lo", "flags_pretty": ["UP"]}, {"destination": "2600:1700:bab0:d40::16/128", "next_hop": "::", "flags": "Un", "metric": 0, "ref": 2, "use": 4, "iface": "lo", "flags_pretty": ["UP"]}, {"destination": "2600:1700:bab0:d40:884b:cf32:dbd6:f640/128", "next_hop": "::", "flags": "Un", "metric": 0, "ref": 1, "use": 0, "iface": "lo", "flags_pretty": ["UP"]}, {"destination": "fe80::c1cb:715d:bc3e:b8a0/128", "next_hop": "::", "flags": "Un", "metric": 0, "ref": 2, "use": 8, "iface": "lo", "flags_pretty": ["UP"]}, {"destination": "ff00::/8", "next_hop": "::", "flags": "U", "metric": 256, "ref": 1, "use": 4, "iface": "ens33", "flags_pretty": ["UP"]}, {"destination": "::/0", "next_hop": "::", "flags": "!n", "metric": -1, "ref": 1, "use": 86, "iface": "lo", "flags_pretty": ["REJECT"]}, {}] diff --git a/tests/fixtures/centos-7.7/route-6-n.out b/tests/fixtures/centos-7.7/route-6-n.out new file mode 100644 index 00000000..8de4eac7 --- /dev/null +++ b/tests/fixtures/centos-7.7/route-6-n.out @@ -0,0 +1,24 @@ +Kernel IPv6 routing table +Destination Next Hop Flag Met Ref Use If +::/96 :: !n 1024 0 0 lo +0.0.0.0/96 :: !n 1024 0 0 lo +2002:a00::/24 :: !n 1024 0 0 lo +2002:7f00::/24 :: !n 1024 0 0 lo +2002:a9fe::/32 :: !n 1024 0 0 lo +2002:ac10::/28 :: !n 1024 0 0 lo +2002:c0a8::/32 :: !n 1024 0 0 lo +2002:e000::/19 :: !n 1024 0 0 lo +2600:1700:bab0:d40::16/128 :: U 100 0 0 ens33 +2600:1700:bab0:d40::/64 :: U 100 1 45 ens33 +2600:1700:bab0:d40::/60 fe80::feae:34ff:fea1:3a80 UG 100 0 0 ens33 +3ffe:ffff::/32 :: !n 1024 0 0 lo +fe80::/64 :: U 100 0 4 ens33 +::/0 fe80::feae:34ff:fea1:3a80 UG 100 1 4 ens33 +::/0 :: !n -1 1 86 lo +::1/128 :: Un 0 2 30 lo +2600:1700:bab0:d40::16/128 :: Un 0 2 4 lo +2600:1700:bab0:d40:884b:cf32:dbd6:f640/128 :: Un 0 1 0 lo +fe80::c1cb:715d:bc3e:b8a0/128 :: Un 0 2 8 lo +ff00::/8 :: U 256 1 4 ens33 +::/0 :: !n -1 1 86 lo + diff --git a/tests/fixtures/centos-7.7/route-6.json b/tests/fixtures/centos-7.7/route-6.json new file mode 100644 index 00000000..44aee8bd --- /dev/null +++ b/tests/fixtures/centos-7.7/route-6.json @@ -0,0 +1 @@ +[{"destination": "[::]/96", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "0.0.0.0/96", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:a00::/24", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:7f00::/24", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:a9fe::/32", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:ac10::/28", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:c0a8::/32", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "2002:e000::/19", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "unknown000c293b580e.attlocal.net/128", "next_hop": "[::]", "flags": "U", "metric": 100, "ref": 0, "use": 0, "iface": "ens33", "flags_pretty": ["UP"]}, {"destination": "2600:1700:bab0:d40::/64", "next_hop": "[::]", "flags": "U", "metric": 100, "ref": 1, "use": 43, "iface": "ens33", "flags_pretty": ["UP"]}, {"destination": "2600:1700:bab0:d40::/60", "next_hop": "gateway", "flags": "UG", "metric": 100, "ref": 0, "use": 0, "iface": "ens33", "flags_pretty": ["UP", "GATEWAY"]}, {"destination": "3ffe:ffff::/32", "next_hop": "[::]", "flags": "!n", "metric": 1024, "ref": 0, "use": 0, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "fe80::/64", "next_hop": "[::]", "flags": "U", "metric": 100, "ref": 0, "use": 4, "iface": "ens33", "flags_pretty": ["UP"]}, {"destination": "[::]/0", "next_hop": "gateway", "flags": "UG", "metric": 100, "ref": 1, "use": 4, "iface": "ens33", "flags_pretty": ["UP", "GATEWAY"]}, {"destination": "[::]/0", "next_hop": "[::]", "flags": "!n", "metric": -1, "ref": 1, "use": 86, "iface": "lo", "flags_pretty": ["REJECT"]}, {"destination": "localhost/128", "next_hop": "[::]", "flags": "Un", "metric": 0, "ref": 2, "use": 30, "iface": "lo", "flags_pretty": ["UP"]}, {"destination": "unknown000c293b580e.attlocal.net/128", "next_hop": "[::]", "flags": "Un", "metric": 0, "ref": 2, "use": 4, "iface": "lo", "flags_pretty": ["UP"]}, {"destination": "unknown000c293b580e.attlocal.net/128", "next_hop": "[::]", "flags": "Un", "metric": 0, "ref": 1, "use": 0, "iface": "lo", "flags_pretty": ["UP"]}, {"destination": "unknown000c293b580e.attlocal.net/128", "next_hop": "[::]", "flags": "Un", "metric": 0, "ref": 2, "use": 8, "iface": "lo", "flags_pretty": ["UP"]}, {"destination": "ff00::/8", "next_hop": "[::]", "flags": "U", "metric": 256, "ref": 1, "use": 4, "iface": "ens33", "flags_pretty": ["UP"]}, {"destination": "[::]/0", "next_hop": "[::]", "flags": "!n", "metric": -1, "ref": 1, "use": 86, "iface": "lo", "flags_pretty": ["REJECT"]}, {}] diff --git a/tests/fixtures/centos-7.7/route-6.out b/tests/fixtures/centos-7.7/route-6.out new file mode 100644 index 00000000..012155a1 --- /dev/null +++ b/tests/fixtures/centos-7.7/route-6.out @@ -0,0 +1,24 @@ +Kernel IPv6 routing table +Destination Next Hop Flag Met Ref Use If +[::]/96 [::] !n 1024 0 0 lo +0.0.0.0/96 [::] !n 1024 0 0 lo +2002:a00::/24 [::] !n 1024 0 0 lo +2002:7f00::/24 [::] !n 1024 0 0 lo +2002:a9fe::/32 [::] !n 1024 0 0 lo +2002:ac10::/28 [::] !n 1024 0 0 lo +2002:c0a8::/32 [::] !n 1024 0 0 lo +2002:e000::/19 [::] !n 1024 0 0 lo +unknown000c293b580e.attlocal.net/128 [::] U 100 0 0 ens33 +2600:1700:bab0:d40::/64 [::] U 100 1 43 ens33 +2600:1700:bab0:d40::/60 gateway UG 100 0 0 ens33 +3ffe:ffff::/32 [::] !n 1024 0 0 lo +fe80::/64 [::] U 100 0 4 ens33 +[::]/0 gateway UG 100 1 4 ens33 +[::]/0 [::] !n -1 1 86 lo +localhost/128 [::] Un 0 2 30 lo +unknown000c293b580e.attlocal.net/128 [::] Un 0 2 4 lo +unknown000c293b580e.attlocal.net/128 [::] Un 0 1 0 lo +unknown000c293b580e.attlocal.net/128 [::] Un 0 2 8 lo +ff00::/8 [::] U 256 1 4 ens33 +[::]/0 [::] !n -1 1 86 lo + diff --git a/tests/test_route.py b/tests/test_route.py index 711e528a..19b319df 100644 --- a/tests/test_route.py +++ b/tests/test_route.py @@ -25,6 +25,12 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/nixos/route-ee.out'), 'r', encoding='utf-8') as f: self.nixos_route_ee = f.read() + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/route-6.out'), 'r', encoding='utf-8') as f: + self.centos_7_7_route_6 = f.read() + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/route-6-n.out'), 'r', encoding='utf-8') as f: + self.centos_7_7_route_6_n = f.read() + # output with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/route.json'), 'r', encoding='utf-8') as f: self.centos_7_7_route_json = json.loads(f.read()) @@ -41,6 +47,12 @@ class MyTests(unittest.TestCase): with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/nixos/route-ee.json'), 'r', encoding='utf-8') as f: self.nixos_route_ee_json = json.loads(f.read()) + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/route-6.json'), 'r', encoding='utf-8') as f: + self.centos_7_7_route_6_json = json.loads(f.read()) + + with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/route-6-n.json'), 'r', encoding='utf-8') as f: + self.centos_7_7_route_6_n_json = json.loads(f.read()) + def test_route_nodata(self): """ Test 'route' with no data @@ -77,6 +89,18 @@ class MyTests(unittest.TestCase): """ self.assertEqual(jc.parsers.route.parse(self.nixos_route_ee, quiet=True), self.nixos_route_ee_json) + def test_route_6_centos_7_7(self): + """ + Test 'route -6' on Centos 7.7 + """ + self.assertEqual(jc.parsers.route.parse(self.centos_7_7_route_6, quiet=True), self.centos_7_7_route_6_json) + + def test_route_6_n_centos_7_7(self): + """ + Test 'route -6 -n' on Centos 7.7 + """ + self.assertEqual(jc.parsers.route.parse(self.centos_7_7_route_6_n, quiet=True), self.centos_7_7_route_6_n_json) + if __name__ == '__main__': unittest.main()