def test_add_ipv4_address_with_gateway(self): ip = address.IPv4(address=IPV4_ADDRESS, netmask=IPV4_NETMASK, gateway=IPV4_GATEWAY, defaultRoute=True) with dummy_device() as nic: with preserve_default_route(): address.add(nic, ipv4=ip, ipv6=None) self.assertTrue(routes.is_default_route(IPV4_GATEWAY))
def test_add_ipv6_address_with_gateway(self): ip = address.IPv6(address=IPV6_ADDRESS, gateway=IPV6_GATEWAY, defaultRoute=True) with dummy_device() as nic: with preserve_default_route(): address.add(nic, ipv4=None, ipv6=ip) self.assertTrue(routes.is_ipv6_default_route(IPV6_GATEWAY))
def test_add_ipv4_address(self): ip = address.IPv4(address=IPV4_ADDRESS, netmask=IPV4_NETMASK) with dummy_device() as nic: address.add(nic, ipv4=ip, ipv6=None) addr, netmask, _, _ = address.addrs_info(nic) self.assertEqual(IPV4_ADDRESS, addr) self.assertEqual(IPV4_NETMASK, netmask)
def setIfaceConfigAndUp(self, iface): if iface.ipv4 or iface.ipv6: address.flush(iface.name) address.add(iface.name, iface.ipv4, iface.ipv6) if iface.mtu: self.setIfaceMtu(iface.name, iface.mtu) self.ifup(iface)
def test_add_ipv4_address(self): ip = address.IPv4(address=IPV4_A_ADDRESS, netmask=IPV4_NETMASK) with dummy_device() as nic: address.add(nic, ipv4=ip, ipv6=None) addr, netmask, _, _ = address.addrs_info(nic) self.assertEqual(IPV4_A_ADDRESS, addr) self.assertEqual(IPV4_NETMASK, netmask)
def test_add_ipv6_address_with_gateway(self): ip = address.IPv6(address=IPV6_A_WITH_PREFIXLEN, gateway=IPV6_GATEWAY, defaultRoute=True) with dummy_device() as nic: with preserve_default_route(): address.add(nic, ipv4=None, ipv6=ip) self.assertTrue(routes.is_ipv6_default_route(IPV6_GATEWAY))
def test_add_ipv4_and_ipv6_address(self, nic0): ipv4 = address.IPv4(address=IPV4_A_ADDRESS, netmask=IPV4_NETMASK) ipv6 = address.IPv6(address=IPV6_A_WITH_PREFIXLEN) address.add(nic0, ipv4=ipv4, ipv6=ipv6) addr, netmask, _, ipv6addresses = address.addrs_info(nic0) assert IPV4_A_ADDRESS == addr assert IPV4_NETMASK == netmask assert IPV6_A_WITH_PREFIXLEN == ipv6addresses[0]
def test_add_ipv4_address_with_gateway(self): ip = address.IPv4(address=IPV4_A_ADDRESS, netmask=IPV4_NETMASK, gateway=IPV4_GATEWAY, defaultRoute=True) with dummy_device() as nic: with preserve_default_route(): address.add(nic, ipv4=ip, ipv6=None) self.assertTrue(routes.is_default_route(IPV4_GATEWAY))
def test_add_ipv4_and_ipv6_address(self): ipv4 = address.IPv4(address=IPV4_A_ADDRESS, netmask=IPV4_NETMASK) ipv6 = address.IPv6(address=IPV6_A_WITH_PREFIXLEN) with dummy_device() as nic: address.add(nic, ipv4=ipv4, ipv6=ipv6) addr, netmask, _, ipv6addresses = address.addrs_info(nic) self.assertEqual(IPV4_A_ADDRESS, addr) self.assertEqual(IPV4_NETMASK, netmask) self.assertEqual(IPV6_A_WITH_PREFIXLEN, ipv6addresses[0])
def test_add_ipv4_and_ipv6_address(self): ipv4 = address.IPv4(address=IPV4_ADDRESS, netmask=IPV4_NETMASK) ipv6 = address.IPv6(address=IPV6_ADDRESS) with dummy_device() as nic: address.add(nic, ipv4=ipv4, ipv6=ipv6) addr, netmask, _, ipv6addresses = address.addrs_info(nic) self.assertEqual(IPV4_ADDRESS, addr) self.assertEqual(IPV4_NETMASK, netmask) self.assertEqual(IPV6_ADDRESS, ipv6addresses[0])
def test_add_ipv4_and_ipv6_address_with_gateways(self): ipv4 = address.IPv4(address=IPV4_ADDRESS, netmask=IPV4_NETMASK, gateway=IPV4_GATEWAY, defaultRoute=True) ipv6 = address.IPv6(address=IPV6_ADDRESS, gateway=IPV6_GATEWAY, defaultRoute=True) with dummy_device() as nic: with preserve_default_route(): address.add(nic, ipv4=ipv4, ipv6=ipv6) addr, netmask, _, ipv6addresses = address.addrs_info(nic) self.assertTrue(routes.is_default_route(IPV4_GATEWAY)) self.assertTrue(routes.is_ipv6_default_route(IPV6_GATEWAY))
def test_add_ipv4_and_ipv6_address_with_gateways(self): ipv4 = address.IPv4(address=IPV4_A_ADDRESS, netmask=IPV4_NETMASK, gateway=IPV4_GATEWAY, defaultRoute=True) ipv6 = address.IPv6(address=IPV6_A_WITH_PREFIXLEN, gateway=IPV6_GATEWAY, defaultRoute=True) with dummy_device() as nic: with preserve_default_route(): address.add(nic, ipv4=ipv4, ipv6=ipv6) addr, netmask, _, ipv6addresses = address.addrs_info(nic) self.assertTrue(routes.is_default_route(IPV4_GATEWAY)) self.assertTrue(routes.is_ipv6_default_route(IPV6_GATEWAY))
def test_add_ipv6_gateway_given_existing_ipv4_and_ipv6_gateways( self, nic0, ipv4_address, ipv6_address): with preserve_default_route(): address.add(nic0, ipv4=ipv4_address, ipv6=None) address.add(nic0, ipv4=None, ipv6=ipv6_address) address.add(nic0, ipv4=None, ipv6=ipv6_address) assert routes.is_default_route(IPV4_GATEWAY, routes.get_routes()) assert routes.is_ipv6_default_route(IPV6_GATEWAY)
def test_add_ipv6_gateway_given_existing_ipv4_and_ipv6_gateways(self): ipv4 = address.IPv4(address=IPV4_ADDRESS, netmask=IPV4_NETMASK, gateway=IPV4_GATEWAY, defaultRoute=True) ipv6 = address.IPv6(address=IPV6_ADDRESS, gateway=IPV6_GATEWAY, defaultRoute=True) with dummy_device() as nic: with preserve_default_route(): address.add(nic, ipv4=ipv4, ipv6=None) address.add(nic, ipv4=None, ipv6=ipv6) address.add(nic, ipv4=None, ipv6=ipv6) self.assertTrue(routes.is_default_route(IPV4_GATEWAY)) self.assertTrue(routes.is_ipv6_default_route(IPV6_GATEWAY))
def _set_static_ip_config(iface, attrs): address.flush(iface) ipv4 = address.IPv4(*_ipv4_conf_params(attrs)) ipv6 = address.IPv6(*_ipv6_conf_params(attrs)) address.add(iface, ipv4, ipv6)
def test_add_ipv6_address(self): ip = address.IPv6(address=IPV6_ADDRESS) with dummy_device() as nic: address.add(nic, ipv4=None, ipv6=ip) _, _, _, ipv6addresses = address.addrs_info(nic) self.assertEqual(IPV6_ADDRESS, ipv6addresses[0])
def test_add_ipv6_address(self, nic0): ip = address.IPv6(address=IPV6_A_WITH_PREFIXLEN) address.add(nic0, ipv4=None, ipv6=ip) _, _, _, ipv6addresses = address.addrs_info(nic0) assert IPV6_A_WITH_PREFIXLEN == ipv6addresses[0]
def test_add_ipv4_address(self, nic0): ip = address.IPv4(address=IPV4_A_ADDRESS, netmask=IPV4_NETMASK) address.add(nic0, ipv4=ip, ipv6=None) addr, netmask, _, _ = address.addrs_info(nic0) assert IPV4_A_ADDRESS == addr assert IPV4_NETMASK == netmask
def test_add_ipv4_and_ipv6_address_with_gateways(self, nic0, ipv4_address, ipv6_address): with preserve_default_route(): address.add(nic0, ipv4=ipv4_address, ipv6=ipv6_address) assert routes.is_default_route(IPV4_GATEWAY, routes.get_routes()) assert routes.is_ipv6_default_route(IPV6_GATEWAY)
def test_add_ipv6_address_with_gateway(self, nic0, ipv6_address): with preserve_default_route(): address.add(nic0, ipv4=None, ipv6=ipv6_address) assert routes.is_ipv6_default_route(IPV6_GATEWAY)
def test_add_ipv6_address(self): ip = address.IPv6(address=IPV6_A_WITH_PREFIXLEN) with dummy_device() as nic: address.add(nic, ipv4=None, ipv6=ip) _, _, _, ipv6addresses = address.addrs_info(nic) self.assertEqual(IPV6_A_WITH_PREFIXLEN, ipv6addresses[0])