mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
network: Convert tests to pytest style
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
parent
13ed080003
commit
67539e05fc
@ -20,14 +20,9 @@ Test module for network configuration utilities.
|
||||
"""
|
||||
|
||||
import copy
|
||||
import os
|
||||
import time
|
||||
import unittest
|
||||
|
||||
|
||||
euid = os.geteuid()
|
||||
if euid == 0:
|
||||
from plinth import network
|
||||
import pytest
|
||||
|
||||
ethernet_settings = {
|
||||
'common': {
|
||||
@ -88,240 +83,246 @@ pppoe_settings = {
|
||||
},
|
||||
}
|
||||
|
||||
@pytest.fixture(name='network')
|
||||
def fixture_network(needs_root):
|
||||
"""Return the network module. Load it conservatively."""
|
||||
from plinth import network as network_module
|
||||
return network_module
|
||||
|
||||
class TestNetwork(unittest.TestCase):
|
||||
"""Verify that the network module performs as expected."""
|
||||
|
||||
ethernet_uuid = None
|
||||
wifi_uuid = None
|
||||
pppoe_uuid = None
|
||||
def _connection(network, settings):
|
||||
"""Create, yield and delete a connection."""
|
||||
uuid = network.add_connection(settings)
|
||||
time.sleep(0.1)
|
||||
yield uuid
|
||||
network.delete_connection(uuid)
|
||||
|
||||
@classmethod
|
||||
def setUp(cls):
|
||||
cls.ethernet_uuid = network.add_connection(ethernet_settings)
|
||||
cls.wifi_uuid = network.add_connection(wifi_settings)
|
||||
cls.pppoe_uuid = network.add_connection(pppoe_settings)
|
||||
# XXX: Handle this properly by waiting for asynchronous add_connection
|
||||
# to complete.
|
||||
time.sleep(0.1)
|
||||
|
||||
@classmethod
|
||||
def tearDown(cls):
|
||||
network.delete_connection(cls.ethernet_uuid)
|
||||
network.delete_connection(cls.wifi_uuid)
|
||||
network.delete_connection(cls.pppoe_uuid)
|
||||
@pytest.fixture(name='ethernet_uuid')
|
||||
def fixture_ethernet_uuid(network):
|
||||
"""Test fixture to setup and teardown an Ethernet connection."""
|
||||
yield from _connection(network, ethernet_settings)
|
||||
|
||||
@unittest.skipUnless(euid == 0, 'Needs to be root')
|
||||
def test_get_connection_list(self):
|
||||
"""Check that we can get a list of available connections."""
|
||||
connections = network.get_connection_list()
|
||||
|
||||
self.assertTrue('plinth_test_eth' in [x['name'] for x in connections])
|
||||
self.assertTrue('plinth_test_wifi' in [x['name'] for x in connections])
|
||||
self.assertTrue('plinth_test_pppoe' in
|
||||
[x['name'] for x in connections])
|
||||
@pytest.fixture(name='wifi_uuid')
|
||||
def fixture_wifi_uuid(network):
|
||||
"""Test fixture to setup and teardown an Wi-Fi connection."""
|
||||
yield from _connection(network, wifi_settings)
|
||||
|
||||
@unittest.skipUnless(euid == 0, 'Needs to be root')
|
||||
def test_get_connection(self):
|
||||
"""Check that we can get a connection by name."""
|
||||
connection = network.get_connection(self.ethernet_uuid)
|
||||
self.assertEqual(
|
||||
connection.get_id(), 'plinth_test_eth')
|
||||
|
||||
connection = network.get_connection(self.wifi_uuid)
|
||||
self.assertEqual(
|
||||
connection.get_id(), 'plinth_test_wifi')
|
||||
@pytest.fixture(name='pppoe_uuid')
|
||||
def fixture_pppoe_uuid(network):
|
||||
"""Test fixture to setup and teardown an PPPoE connection."""
|
||||
yield from _connection(network, pppoe_settings)
|
||||
|
||||
self.assertRaises(network.ConnectionNotFound, network.get_connection,
|
||||
'x-invalid-network-id')
|
||||
|
||||
@unittest.skipUnless(euid == 0, 'Needs to be root')
|
||||
def test_edit_ethernet_connection(self):
|
||||
"""Check that we can update an ethernet connection."""
|
||||
connection = network.get_connection(self.ethernet_uuid)
|
||||
ethernet_settings2 = copy.deepcopy(ethernet_settings)
|
||||
ethernet_settings2['common']['name'] = 'plinth_test_eth_new'
|
||||
ethernet_settings2['common']['interface'] = 'eth1'
|
||||
ethernet_settings2['common']['zone'] = 'external'
|
||||
ethernet_settings2['ipv4']['method'] = 'auto'
|
||||
network.edit_connection(connection, ethernet_settings2)
|
||||
|
||||
connection = network.get_connection(self.ethernet_uuid)
|
||||
self.assertEqual(connection.get_id(), 'plinth_test_eth_new')
|
||||
@pytest.mark.usefixtures('ethernet_uuid', 'wifi_uuid', 'pppoe_uuid')
|
||||
def test_get_connection_list(network):
|
||||
"""Check that we can get a list of available connections."""
|
||||
connections = network.get_connection_list()
|
||||
|
||||
settings_connection = connection.get_setting_connection()
|
||||
self.assertEqual(settings_connection.get_interface_name(), 'eth1')
|
||||
self.assertEqual(settings_connection.get_zone(), 'external')
|
||||
assert 'plinth_test_eth' in [x['name'] for x in connections]
|
||||
assert 'plinth_test_wifi' in [x['name'] for x in connections]
|
||||
assert 'plinth_test_pppoe' in [x['name'] for x in connections]
|
||||
|
||||
settings_ipv4 = connection.get_setting_ip4_config()
|
||||
self.assertEqual(settings_ipv4.get_method(), 'auto')
|
||||
|
||||
@unittest.skipUnless(euid == 0, 'Needs to be root')
|
||||
def test_edit_pppoe_connection(self):
|
||||
"""Check that we can update a PPPoE connection."""
|
||||
connection = network.get_connection(self.ethernet_uuid)
|
||||
pppoe_settings2 = copy.deepcopy(pppoe_settings)
|
||||
pppoe_settings2['common']['name'] = 'plinth_test_pppoe_new'
|
||||
pppoe_settings2['common']['interface'] = 'eth2'
|
||||
pppoe_settings2['common']['zone'] = 'external'
|
||||
pppoe_settings2['pppoe']['username'] = 'x-user-new'
|
||||
pppoe_settings2['pppoe']['password'] = 'x-password-new'
|
||||
network.edit_connection(connection, pppoe_settings2)
|
||||
|
||||
connection = network.get_connection(self.ethernet_uuid)
|
||||
self.assertEqual(connection.get_id(), 'plinth_test_pppoe_new')
|
||||
def test_get_connection(network, ethernet_uuid, wifi_uuid):
|
||||
"""Check that we can get a connection by name."""
|
||||
connection = network.get_connection(ethernet_uuid)
|
||||
assert connection.get_id() == 'plinth_test_eth'
|
||||
|
||||
settings_connection = connection.get_setting_connection()
|
||||
self.assertEqual(settings_connection.get_interface_name(), 'eth2')
|
||||
self.assertEqual(settings_connection.get_zone(), 'external')
|
||||
connection = network.get_connection(wifi_uuid)
|
||||
assert connection.get_id() == 'plinth_test_wifi'
|
||||
|
||||
settings_pppoe = connection.get_setting_pppoe()
|
||||
self.assertEqual(settings_pppoe.get_username(), 'x-user-new')
|
||||
secrets = connection.get_secrets('pppoe')
|
||||
self.assertEqual(secrets['pppoe']['password'], 'x-password-new')
|
||||
with pytest.raises(network.ConnectionNotFound):
|
||||
network.get_connection('x-invalid-network-id')
|
||||
|
||||
settings_ppp = connection.get_setting_ppp()
|
||||
self.assertEqual(settings_ppp.get_lcp_echo_failure(), 5)
|
||||
self.assertEqual(settings_ppp.get_lcp_echo_interval(), 30)
|
||||
|
||||
@unittest.skipUnless(euid == 0, 'Needs to be root')
|
||||
def test_edit_wifi_connection(self):
|
||||
"""Check that we can update a wifi connection."""
|
||||
connection = network.get_connection(self.wifi_uuid)
|
||||
wifi_settings2 = copy.deepcopy(wifi_settings)
|
||||
wifi_settings2['common']['name'] = 'plinth_test_wifi_new'
|
||||
wifi_settings2['common']['interface'] = 'wlan1'
|
||||
wifi_settings2['common']['zone'] = 'external'
|
||||
wifi_settings2['ipv4']['method'] = 'auto'
|
||||
wifi_settings2['wireless']['ssid'] = 'plinthtestwifi2'
|
||||
wifi_settings2['wireless']['mode'] = 'infrastructure'
|
||||
wifi_settings2['wireless']['auth_mode'] = 'wpa'
|
||||
wifi_settings2['wireless']['passphrase'] = 'secretpassword'
|
||||
network.edit_connection(connection, wifi_settings2)
|
||||
def test_edit_ethernet_connection(network, ethernet_uuid):
|
||||
"""Check that we can update an ethernet connection."""
|
||||
connection = network.get_connection(ethernet_uuid)
|
||||
ethernet_settings2 = copy.deepcopy(ethernet_settings)
|
||||
ethernet_settings2['common']['name'] = 'plinth_test_eth_new'
|
||||
ethernet_settings2['common']['interface'] = 'eth1'
|
||||
ethernet_settings2['common']['zone'] = 'external'
|
||||
ethernet_settings2['ipv4']['method'] = 'auto'
|
||||
network.edit_connection(connection, ethernet_settings2)
|
||||
|
||||
connection = network.get_connection(self.wifi_uuid)
|
||||
connection = network.get_connection(ethernet_uuid)
|
||||
assert connection.get_id() == 'plinth_test_eth_new'
|
||||
|
||||
self.assertEqual(connection.get_id(), 'plinth_test_wifi_new')
|
||||
settings_connection = connection.get_setting_connection()
|
||||
assert settings_connection.get_interface_name() == 'eth1'
|
||||
assert settings_connection.get_zone() == 'external'
|
||||
|
||||
settings_connection = connection.get_setting_connection()
|
||||
self.assertEqual(settings_connection.get_interface_name(), 'wlan1')
|
||||
self.assertEqual(settings_connection.get_zone(), 'external')
|
||||
settings_ipv4 = connection.get_setting_ip4_config()
|
||||
assert settings_ipv4.get_method() == 'auto'
|
||||
|
||||
settings_wireless = connection.get_setting_wireless()
|
||||
self.assertEqual(settings_wireless.get_ssid().get_data(),
|
||||
b'plinthtestwifi2')
|
||||
self.assertEqual(settings_wireless.get_mode(), 'infrastructure')
|
||||
|
||||
wifi_sec = connection.get_setting_wireless_security()
|
||||
self.assertEqual(wifi_sec.get_key_mgmt(), 'wpa-psk')
|
||||
def test_edit_pppoe_connection(network, pppoe_uuid):
|
||||
"""Check that we can update a PPPoE connection."""
|
||||
connection = network.get_connection(pppoe_uuid)
|
||||
pppoe_settings2 = copy.deepcopy(pppoe_settings)
|
||||
pppoe_settings2['common']['name'] = 'plinth_test_pppoe_new'
|
||||
pppoe_settings2['common']['interface'] = 'eth2'
|
||||
pppoe_settings2['common']['zone'] = 'external'
|
||||
pppoe_settings2['pppoe']['username'] = 'x-user-new'
|
||||
pppoe_settings2['pppoe']['password'] = 'x-password-new'
|
||||
network.edit_connection(connection, pppoe_settings2)
|
||||
|
||||
secrets = connection.get_secrets('802-11-wireless-security')
|
||||
self.assertEqual(
|
||||
secrets['802-11-wireless-security']['psk'],
|
||||
'secretpassword')
|
||||
connection = network.get_connection(pppoe_uuid)
|
||||
assert connection.get_id() == 'plinth_test_pppoe_new'
|
||||
|
||||
@unittest.skipUnless(euid == 0, 'Needs to be root')
|
||||
def test_ethernet_manual_ipv4_address(self):
|
||||
"""Check that we can manually set IPv4 address on ethernet."""
|
||||
connection = network.get_connection(self.ethernet_uuid)
|
||||
ethernet_settings2 = copy.deepcopy(ethernet_settings)
|
||||
ethernet_settings2['ipv4']['method'] = 'manual'
|
||||
ethernet_settings2['ipv4']['address'] = '169.254.0.1'
|
||||
ethernet_settings2['ipv4']['netmask'] = '255.255.254.0'
|
||||
ethernet_settings2['ipv4']['gateway'] = '169.254.0.254'
|
||||
ethernet_settings2['ipv4']['dns'] = '1.2.3.4'
|
||||
ethernet_settings2['ipv4']['second_dns'] = '1.2.3.5'
|
||||
network.edit_connection(connection, ethernet_settings2)
|
||||
settings_connection = connection.get_setting_connection()
|
||||
assert settings_connection.get_interface_name() == 'eth2'
|
||||
assert settings_connection.get_zone() == 'external'
|
||||
|
||||
connection = network.get_connection(self.ethernet_uuid)
|
||||
settings_ipv4 = connection.get_setting_ip4_config()
|
||||
self.assertEqual(settings_ipv4.get_method(), 'manual')
|
||||
settings_pppoe = connection.get_setting_pppoe()
|
||||
assert settings_pppoe.get_username() == 'x-user-new'
|
||||
secrets = connection.get_secrets('pppoe')
|
||||
assert secrets['pppoe']['password'] == 'x-password-new'
|
||||
|
||||
address = settings_ipv4.get_address(0)
|
||||
self.assertEqual(address.get_address(), '169.254.0.1')
|
||||
self.assertEqual(address.get_prefix(), 23)
|
||||
self.assertEqual(settings_ipv4.get_gateway(), '169.254.0.254')
|
||||
self.assertEqual(settings_ipv4.get_num_dns(), 2)
|
||||
self.assertEqual(settings_ipv4.get_dns(0), '1.2.3.4')
|
||||
self.assertEqual(settings_ipv4.get_dns(1), '1.2.3.5')
|
||||
settings_ppp = connection.get_setting_ppp()
|
||||
assert settings_ppp.get_lcp_echo_failure() == 5
|
||||
assert settings_ppp.get_lcp_echo_interval() == 30
|
||||
|
||||
@unittest.skipUnless(euid == 0, 'Needs to be root')
|
||||
def test_ethernet_manual_ipv6_address(self):
|
||||
"""Check that we can manually set IPv6 address on ethernet."""
|
||||
connection = network.get_connection(self.ethernet_uuid)
|
||||
ethernet_settings2 = copy.deepcopy(ethernet_settings)
|
||||
ethernet_settings2['ipv6']['method'] = 'manual'
|
||||
ethernet_settings2['ipv6']['address'] = '::ffff:169.254.0.1'
|
||||
ethernet_settings2['ipv6']['prefix'] = '63'
|
||||
ethernet_settings2['ipv6']['gateway'] = '::ffff:169.254.0.254'
|
||||
ethernet_settings2['ipv6']['dns'] = '::ffff:1.2.3.4'
|
||||
ethernet_settings2['ipv6']['second_dns'] = '::ffff:1.2.3.5'
|
||||
network.edit_connection(connection, ethernet_settings2)
|
||||
|
||||
connection = network.get_connection(self.ethernet_uuid)
|
||||
settings_ipv6 = connection.get_setting_ip6_config()
|
||||
self.assertEqual(settings_ipv6.get_method(), 'manual')
|
||||
def test_edit_wifi_connection(network, wifi_uuid):
|
||||
"""Check that we can update a wifi connection."""
|
||||
connection = network.get_connection(wifi_uuid)
|
||||
wifi_settings2 = copy.deepcopy(wifi_settings)
|
||||
wifi_settings2['common']['name'] = 'plinth_test_wifi_new'
|
||||
wifi_settings2['common']['interface'] = 'wlan1'
|
||||
wifi_settings2['common']['zone'] = 'external'
|
||||
wifi_settings2['ipv4']['method'] = 'auto'
|
||||
wifi_settings2['wireless']['ssid'] = 'plinthtestwifi2'
|
||||
wifi_settings2['wireless']['mode'] = 'infrastructure'
|
||||
wifi_settings2['wireless']['auth_mode'] = 'wpa'
|
||||
wifi_settings2['wireless']['passphrase'] = 'secretpassword'
|
||||
network.edit_connection(connection, wifi_settings2)
|
||||
|
||||
address = settings_ipv6.get_address(0)
|
||||
self.assertEqual(address.get_address(), '::ffff:169.254.0.1')
|
||||
self.assertEqual(address.get_prefix(), 63)
|
||||
self.assertEqual(settings_ipv6.get_gateway(), '::ffff:169.254.0.254')
|
||||
self.assertEqual(settings_ipv6.get_num_dns(), 2)
|
||||
self.assertEqual(settings_ipv6.get_dns(0), '::ffff:1.2.3.4')
|
||||
self.assertEqual(settings_ipv6.get_dns(1), '::ffff:1.2.3.5')
|
||||
connection = network.get_connection(wifi_uuid)
|
||||
|
||||
@unittest.skipUnless(euid == 0, 'Needs to be root')
|
||||
def test_wifi_manual_ipv4_address(self):
|
||||
"""Check that we can manually set IPv4 address on wifi."""
|
||||
connection = network.get_connection(self.wifi_uuid)
|
||||
wifi_settings2 = copy.deepcopy(wifi_settings)
|
||||
wifi_settings2['ipv4']['method'] = 'manual'
|
||||
wifi_settings2['ipv4']['address'] = '169.254.0.2'
|
||||
wifi_settings2['ipv4']['netmask'] = '255.255.254.0'
|
||||
wifi_settings2['ipv4']['gateway'] = '169.254.0.254'
|
||||
wifi_settings2['ipv4']['dns'] = '1.2.3.4'
|
||||
wifi_settings2['ipv4']['second_dns'] = '1.2.3.5'
|
||||
wifi_settings2['wireless']['ssid'] = 'plinthtestwifi'
|
||||
wifi_settings2['wireless']['mode'] = 'adhoc'
|
||||
wifi_settings2['wireless']['auth_mode'] = 'open'
|
||||
network.edit_connection(connection, wifi_settings2)
|
||||
assert connection.get_id() == 'plinth_test_wifi_new'
|
||||
|
||||
connection = network.get_connection(self.wifi_uuid)
|
||||
settings_ipv4 = connection.get_setting_ip4_config()
|
||||
self.assertEqual(settings_ipv4.get_method(), 'manual')
|
||||
settings_connection = connection.get_setting_connection()
|
||||
assert settings_connection.get_interface_name() == 'wlan1'
|
||||
assert settings_connection.get_zone() == 'external'
|
||||
|
||||
address = settings_ipv4.get_address(0)
|
||||
self.assertEqual(address.get_address(), '169.254.0.2')
|
||||
self.assertEqual(address.get_prefix(), 23)
|
||||
self.assertEqual(settings_ipv4.get_gateway(), '169.254.0.254')
|
||||
self.assertEqual(settings_ipv4.get_num_dns(), 2)
|
||||
self.assertEqual(settings_ipv4.get_dns(0), '1.2.3.4')
|
||||
self.assertEqual(settings_ipv4.get_dns(1), '1.2.3.5')
|
||||
settings_wireless = connection.get_setting_wireless()
|
||||
assert settings_wireless.get_ssid().get_data() == b'plinthtestwifi2'
|
||||
assert settings_wireless.get_mode() == 'infrastructure'
|
||||
|
||||
@unittest.skipUnless(euid == 0, 'Needs to be root')
|
||||
def test_wifi_manual_ipv6_address(self):
|
||||
"""Check that we can manually set IPv6 address on wifi."""
|
||||
connection = network.get_connection(self.wifi_uuid)
|
||||
wifi_settings2 = copy.deepcopy(wifi_settings)
|
||||
wifi_settings2['ipv6']['method'] = 'manual'
|
||||
wifi_settings2['ipv6']['address'] = '::ffff:169.254.0.2'
|
||||
wifi_settings2['ipv6']['prefix'] = 63
|
||||
wifi_settings2['ipv6']['gateway'] = '::ffff:169.254.0.254'
|
||||
wifi_settings2['ipv6']['dns'] = '::ffff:1.2.3.4'
|
||||
wifi_settings2['ipv6']['second_dns'] = '::ffff:1.2.3.5'
|
||||
wifi_settings2['wireless']['ssid'] = 'plinthtestwifi'
|
||||
wifi_settings2['wireless']['mode'] = 'adhoc'
|
||||
wifi_settings2['wireless']['auth_mode'] = 'open'
|
||||
network.edit_connection(connection, wifi_settings2)
|
||||
wifi_sec = connection.get_setting_wireless_security()
|
||||
assert wifi_sec.get_key_mgmt() == 'wpa-psk'
|
||||
|
||||
connection = network.get_connection(self.wifi_uuid)
|
||||
settings_ipv6 = connection.get_setting_ip6_config()
|
||||
self.assertEqual(settings_ipv6.get_method(), 'manual')
|
||||
secrets = connection.get_secrets('802-11-wireless-security')
|
||||
assert secrets['802-11-wireless-security']['psk'] == 'secretpassword'
|
||||
|
||||
address = settings_ipv6.get_address(0)
|
||||
self.assertEqual(address.get_address(), '::ffff:169.254.0.2')
|
||||
self.assertEqual(address.get_prefix(), 63)
|
||||
self.assertEqual(settings_ipv6.get_gateway(), '::ffff:169.254.0.254')
|
||||
self.assertEqual(settings_ipv6.get_num_dns(), 2)
|
||||
self.assertEqual(settings_ipv6.get_dns(0), '::ffff:1.2.3.4')
|
||||
self.assertEqual(settings_ipv6.get_dns(1), '::ffff:1.2.3.5')
|
||||
|
||||
def test_ethernet_manual_ipv4_address(network, ethernet_uuid):
|
||||
"""Check that we can manually set IPv4 address on ethernet."""
|
||||
connection = network.get_connection(ethernet_uuid)
|
||||
ethernet_settings2 = copy.deepcopy(ethernet_settings)
|
||||
ethernet_settings2['ipv4']['method'] = 'manual'
|
||||
ethernet_settings2['ipv4']['address'] = '169.254.0.1'
|
||||
ethernet_settings2['ipv4']['netmask'] = '255.255.254.0'
|
||||
ethernet_settings2['ipv4']['gateway'] = '169.254.0.254'
|
||||
ethernet_settings2['ipv4']['dns'] = '1.2.3.4'
|
||||
ethernet_settings2['ipv4']['second_dns'] = '1.2.3.5'
|
||||
network.edit_connection(connection, ethernet_settings2)
|
||||
|
||||
connection = network.get_connection(ethernet_uuid)
|
||||
settings_ipv4 = connection.get_setting_ip4_config()
|
||||
assert settings_ipv4.get_method() == 'manual'
|
||||
|
||||
address = settings_ipv4.get_address(0)
|
||||
assert address.get_address() == '169.254.0.1'
|
||||
assert address.get_prefix() == 23
|
||||
assert settings_ipv4.get_gateway() == '169.254.0.254'
|
||||
assert settings_ipv4.get_num_dns() == 2
|
||||
assert settings_ipv4.get_dns(0) == '1.2.3.4'
|
||||
assert settings_ipv4.get_dns(1) == '1.2.3.5'
|
||||
|
||||
|
||||
def test_ethernet_manual_ipv6_address(network, ethernet_uuid):
|
||||
"""Check that we can manually set IPv6 address on ethernet."""
|
||||
connection = network.get_connection(ethernet_uuid)
|
||||
ethernet_settings2 = copy.deepcopy(ethernet_settings)
|
||||
ethernet_settings2['ipv6']['method'] = 'manual'
|
||||
ethernet_settings2['ipv6']['address'] = '::ffff:169.254.0.1'
|
||||
ethernet_settings2['ipv6']['prefix'] = '63'
|
||||
ethernet_settings2['ipv6']['gateway'] = '::ffff:169.254.0.254'
|
||||
ethernet_settings2['ipv6']['dns'] = '::ffff:1.2.3.4'
|
||||
ethernet_settings2['ipv6']['second_dns'] = '::ffff:1.2.3.5'
|
||||
network.edit_connection(connection, ethernet_settings2)
|
||||
|
||||
connection = network.get_connection(ethernet_uuid)
|
||||
settings_ipv6 = connection.get_setting_ip6_config()
|
||||
assert settings_ipv6.get_method() == 'manual'
|
||||
|
||||
address = settings_ipv6.get_address(0)
|
||||
assert address.get_address() == '::ffff:169.254.0.1'
|
||||
assert address.get_prefix() == 63
|
||||
assert settings_ipv6.get_gateway() == '::ffff:169.254.0.254'
|
||||
assert settings_ipv6.get_num_dns() == 2
|
||||
assert settings_ipv6.get_dns(0) == '::ffff:1.2.3.4'
|
||||
assert settings_ipv6.get_dns(1) == '::ffff:1.2.3.5'
|
||||
|
||||
|
||||
def test_wifi_manual_ipv4_address(network, wifi_uuid):
|
||||
"""Check that we can manually set IPv4 address on wifi."""
|
||||
connection = network.get_connection(wifi_uuid)
|
||||
wifi_settings2 = copy.deepcopy(wifi_settings)
|
||||
wifi_settings2['ipv4']['method'] = 'manual'
|
||||
wifi_settings2['ipv4']['address'] = '169.254.0.2'
|
||||
wifi_settings2['ipv4']['netmask'] = '255.255.254.0'
|
||||
wifi_settings2['ipv4']['gateway'] = '169.254.0.254'
|
||||
wifi_settings2['ipv4']['dns'] = '1.2.3.4'
|
||||
wifi_settings2['ipv4']['second_dns'] = '1.2.3.5'
|
||||
wifi_settings2['wireless']['ssid'] = 'plinthtestwifi'
|
||||
wifi_settings2['wireless']['mode'] = 'adhoc'
|
||||
wifi_settings2['wireless']['auth_mode'] = 'open'
|
||||
network.edit_connection(connection, wifi_settings2)
|
||||
|
||||
connection = network.get_connection(wifi_uuid)
|
||||
settings_ipv4 = connection.get_setting_ip4_config()
|
||||
assert settings_ipv4.get_method() == 'manual'
|
||||
|
||||
address = settings_ipv4.get_address(0)
|
||||
assert address.get_address() == '169.254.0.2'
|
||||
assert address.get_prefix() == 23
|
||||
assert settings_ipv4.get_gateway() == '169.254.0.254'
|
||||
assert settings_ipv4.get_num_dns() == 2
|
||||
assert settings_ipv4.get_dns(0) == '1.2.3.4'
|
||||
assert settings_ipv4.get_dns(1) == '1.2.3.5'
|
||||
|
||||
|
||||
def test_wifi_manual_ipv6_address(network, wifi_uuid):
|
||||
"""Check that we can manually set IPv6 address on wifi."""
|
||||
connection = network.get_connection(wifi_uuid)
|
||||
wifi_settings2 = copy.deepcopy(wifi_settings)
|
||||
wifi_settings2['ipv6']['method'] = 'manual'
|
||||
wifi_settings2['ipv6']['address'] = '::ffff:169.254.0.2'
|
||||
wifi_settings2['ipv6']['prefix'] = 63
|
||||
wifi_settings2['ipv6']['gateway'] = '::ffff:169.254.0.254'
|
||||
wifi_settings2['ipv6']['dns'] = '::ffff:1.2.3.4'
|
||||
wifi_settings2['ipv6']['second_dns'] = '::ffff:1.2.3.5'
|
||||
wifi_settings2['wireless']['ssid'] = 'plinthtestwifi'
|
||||
wifi_settings2['wireless']['mode'] = 'adhoc'
|
||||
wifi_settings2['wireless']['auth_mode'] = 'open'
|
||||
network.edit_connection(connection, wifi_settings2)
|
||||
|
||||
connection = network.get_connection(wifi_uuid)
|
||||
settings_ipv6 = connection.get_setting_ip6_config()
|
||||
assert settings_ipv6.get_method() == 'manual'
|
||||
|
||||
address = settings_ipv6.get_address(0)
|
||||
assert address.get_address() == '::ffff:169.254.0.2'
|
||||
assert address.get_prefix() == 63
|
||||
assert settings_ipv6.get_gateway() == '::ffff:169.254.0.254'
|
||||
assert settings_ipv6.get_num_dns() == 2
|
||||
assert settings_ipv6.get_dns(0) == '::ffff:1.2.3.4'
|
||||
assert settings_ipv6.get_dns(1) == '::ffff:1.2.3.5'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user