def test_find_interfaces_for_dns_with_dynamic_ip_but_no_auto_dns(families): state = State(_get_test_desired_state_dynamic_ip_but_no_auto_dns(families)) expected_ifaces = [None, None] if Interface.IPV4 in families: expected_ifaces[0] = TEST_IFACE1 if Interface.IPV6 in families: expected_ifaces[1] = TEST_IFACE1 expected_ifaces = tuple(expected_ifaces) assert expected_ifaces == nm_dns.find_interfaces_for_name_servers(state)
def test_find_interfaces_for_dns_with_ipv4_static_gateway_only(): iface_routes = { TEST_IPV4_GATEWAY_IFACE: _get_test_ipv4_gateway(), TEST_STATIC_ROUTE_IFACE: _get_test_static_routes(), } assert ( TEST_IPV4_GATEWAY_IFACE, None, ) == nm_dns.find_interfaces_for_name_servers(iface_routes)
def test_find_interfaces_for_dns_with_static_gateways(families): state = _get_test_desired_state_static_gateway(families) expected_ifaces = [None, None] if Interface.IPV4 in families: expected_ifaces[0] = TEST_IPV4_GATEWAY_IFACE if Interface.IPV6 in families: expected_ifaces[1] = TEST_IPV6_GATEWAY_IFACE expected_ifaces = tuple(expected_ifaces) assert expected_ifaces == nm_dns.find_interfaces_for_name_servers( State(state))
def test_find_interfaces_for_dns_prefer_static_gateway(families): state = _get_test_desired_state_static_gateway(families) state2 = _get_test_desired_state_dynamic_ip_but_no_auto_dns(families) state[Interface.KEY].extend(state2[Interface.KEY]) state = State(state) expected_ifaces = [None, None] if Interface.IPV4 in families: expected_ifaces[0] = TEST_IPV4_GATEWAY_IFACE if Interface.IPV6 in families: expected_ifaces[1] = TEST_IPV6_GATEWAY_IFACE expected_ifaces = tuple(expected_ifaces) assert expected_ifaces == nm_dns.find_interfaces_for_name_servers(state)
def test_find_interfaces_for_dns_with_no_routes(): state = State({ Interface.KEY: [ { Interface.NAME: TEST_IPV4_GATEWAY_IFACE, Interface.STATE: InterfaceState.UP, }, { Interface.NAME: TEST_IPV6_GATEWAY_IFACE, Interface.STATE: InterfaceState.UP, }, ], }) assert (None, None) == nm_dns.find_interfaces_for_name_servers(state)
def test_find_interfaces_for_dns_with_dynamic_ip_and_auto_dns(families): iface_state = { Interface.NAME: TEST_IFACE1, Interface.STATE: InterfaceState.UP, Interface.IPV4: { InterfaceIPv4.ENABLED: False }, Interface.IPV6: { InterfaceIPv6.ENABLED: False }, } if Interface.IPV4 in families: iface_state[Interface.IPV4][InterfaceIPv4.ENABLED] = True iface_state[Interface.IPV4][InterfaceIPv4.DHCP] = True iface_state[Interface.IPV4][InterfaceIPv4.AUTO_DNS] = True if Interface.IPV6 in families: iface_state[Interface.IPV6][InterfaceIPv6.ENABLED] = True iface_state[Interface.IPV6][InterfaceIPv6.DHCP] = True iface_state[Interface.IPV6][InterfaceIPv6.AUTOCONF] = True iface_state[Interface.IPV6][InterfaceIPv6.AUTO_DNS] = True state = State({Interface.KEY: [iface_state]}) assert (None, None) == nm_dns.find_interfaces_for_name_servers(state)
def test_find_interfaces_for_dns_with_no_gateway(): state = State(_get_test_desired_state_static_gateway(())) assert (None, None) == nm_dns.find_interfaces_for_name_servers(state)
def test_find_interfaces_for_dns_with_no_gateway(): iface_routes = {TEST_STATIC_ROUTE_IFACE: _get_test_static_routes()} assert (None, None) == nm_dns.find_interfaces_for_name_servers(iface_routes)
def test_find_interfaces_for_dns_with_no_routes(): iface_routes = {} assert (None, None) == nm_dns.find_interfaces_for_name_servers(iface_routes)
def test_find_interfaces_for_dns_with_ipv6_and_ipv4_static_gateways(): iface_routes = _get_test_iface_routes() assert ( TEST_IPV4_GATEWAY_IFACE, TEST_IPV6_GATEWAY_IFACE, ) == nm_dns.find_interfaces_for_name_servers(iface_routes)