Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_cp1252_non_utf8_byte(self):
"""
Tests that things are still working when using this bizarre encoding
"""
ifcfg.distro = "Windows"
ifcfg.Parser = ifcfg.get_parser_class()
self.assertTrue(issubclass(ifcfg.Parser, WindowsParser))
parser = ifcfg.get_parser()
interfaces = parser.interfaces
self.assertIn("Ethernet adapter Local Area Connection 2", interfaces.keys())
self.assertIn("Tunnel adapter isatap.lan", interfaces.keys())
self.assertIn("Tunnel adapter Teredo Tunneling Pseudo-Interface", interfaces.keys())
self.assertEqual(len(interfaces.keys()), 3)
eq_(interfaces['Ethernet adapter Local Area Connection 2']['inet'], '10.0.2.15')
self.assertEqual(
len(interfaces['Ethernet adapter Local Area Connection 2']['inet6']),
0
def test_macosx2(self):
ifcfg.distro = 'MacOSX'
ifcfg.Parser = ifcfg.get_parser_class()
parser = ifcfg.get_parser(ifconfig=ifconfig_out.MACOSX2)
interfaces = parser.interfaces
self.assertEqual(len(interfaces.keys()), 9)
eq_(interfaces['lo0']['inet'], '127.0.0.1')
eq_(interfaces['lo0']['inet4'], ['127.0.0.1', '127.0.1.99'])
eq_(interfaces['lo0']['netmask'], '255.0.0.0')
def test_linux(self):
ifcfg.Parser = UnixIPParser
parser = ifcfg.get_parser(ifconfig=ip_out.LINUX)
interfaces = parser.interfaces
# Unconnected interface
eq_(interfaces['enp0s25']['ether'], 'a0:00:00:00:00:00')
eq_(interfaces['enp0s25']['inet'], None)
# Connected interface
eq_(interfaces['wlp3s0']['ether'], 'a0:00:00:00:00:00')
eq_(interfaces['wlp3s0']['inet'], '192.168.12.34')
eq_(interfaces['wlp3s0']['inet4'], ['192.168.12.34'])
eq_(interfaces['wlp3s0']['inet6'], ['fd37:a521:ada9::869', 'fd37:a521:ada9:0:b9f7:44f8:bb19:c78c', 'fd37:a521:ada9:0:9073:a91:d14f:8087', 'fe80::205f:5d09:d0da:7aed'])
eq_(interfaces['wlp3s0']['broadcast'], '192.168.12.255')
eq_(interfaces['wlp3s0']['netmask'], '/24')
eq_(interfaces['wlp3s0']['mtu'], '1500')
# Connected interface
eq_(interfaces['enp6s0.2']['ether'], '00:73:00:5c:09:9a')
eq_(interfaces['enp6s0.2']['inet'], '10.2.2.253')
def test_illegal(self):
ifcfg.distro = 'Linux'
ifcfg.Parser = LinuxParser
ifcfg.get_parser(ifconfig=ifconfig_out.ILLEGAL_OUTPUT)