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_windows7vm(self):
ifcfg.distro = "Windows"
ifcfg.Parser = ifcfg.get_parser_class()
self.assertTrue(issubclass(ifcfg.Parser, WindowsParser))
parser = ifcfg.get_parser(ifconfig=ipconfig_out.WINDOWS_7_VM)
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_macosx(self):
ifcfg.distro = 'MacOSX'
ifcfg.Parser = ifcfg.get_parser_class()
parser = ifcfg.get_parser(ifconfig=ifconfig_out.MACOSX)
interfaces = parser.interfaces
self.assertEqual(len(interfaces.keys()), 2)
eq_(interfaces['en0']['ether'], '1a:2b:3c:4d:5e:6f')
eq_(interfaces['en0']['inet'], '192.168.0.1')
eq_(interfaces['en0']['broadcast'], '192.168.0.255')
eq_(interfaces['en0']['netmask'], '255.255.255.0')
def test_cp1252_encoding(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_unknown(self):
ifcfg.distro = 'Bogus'
ifcfg.Parser = ifcfg.get_parser_class()
self.assertTrue(issubclass(ifcfg.Parser, NullParser))
def test_windows10_w_2_ethernets(self):
ifcfg.distro = "Windows"
ifcfg.Parser = ifcfg.get_parser_class()
self.assertTrue(issubclass(ifcfg.Parser, WindowsParser))
parser = ifcfg.get_parser(
ifconfig=ipconfig_out.WINDOWS_10_WITH_2_ETHERNETS
)
interfaces = parser.interfaces
# Check that the first adapter is present
self.assertIn("Ethernet adapter Ethernet", interfaces.keys())
# Check that the second adapter is present
self.assertIn("Ethernet adapter Ethernet 2", interfaces.keys())
self.assertEqual(len(interfaces.keys()), 4)
def test_windows10(self):
ifcfg.distro = "Windows"
ifcfg.Parser = ifcfg.get_parser_class()
self.assertTrue(issubclass(ifcfg.Parser, WindowsParser))
parser = ifcfg.get_parser(ifconfig=ipconfig_out.WINDOWS_10_ETH)
interfaces = parser.interfaces
self.assertIn("Ethernet adapter Ethernet", interfaces.keys())
self.assertIn("Wireless LAN adapter Local Area Connection* 2", interfaces.keys())
self.assertIn("Wireless LAN adapter Local Area Connection* 3", interfaces.keys())
self.assertIn("Wireless LAN adapter Wi-Fi", 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()), 6)
eq_(interfaces['Ethernet adapter Ethernet']['inet'], '192.168.1.2')