diff --git a/plinth/network.py b/plinth/network.py index 67a846b8a..7f47f36f4 100644 --- a/plinth/network.py +++ b/plinth/network.py @@ -307,11 +307,22 @@ def _update_common_settings(connection, connection_uuid, common): connection.add_setting(settings) settings.set_property(nm.SETTING_CONNECTION_UUID, connection_uuid) - settings.set_property(nm.SETTING_CONNECTION_ID, common['name']) - settings.set_property(nm.SETTING_CONNECTION_TYPE, common['type']) - settings.set_property(nm.SETTING_CONNECTION_INTERFACE_NAME, - common['interface']) - settings.set_property(nm.SETTING_CONNECTION_ZONE, common['zone']) + if 'name' in common: + settings.set_property(nm.SETTING_CONNECTION_ID, common['name']) + + if 'type' in common: + settings.set_property(nm.SETTING_CONNECTION_TYPE, common['type']) + + if 'interface' in common: + settings.set_property(nm.SETTING_CONNECTION_INTERFACE_NAME, + common['interface']) + + if 'zone' in common: + settings.set_property(nm.SETTING_CONNECTION_ZONE, common['zone']) + + if 'autoconnect' in common: + settings.set_property(nm.SETTING_CONNECTION_AUTOCONNECT, + common['autoconnect']) return connection diff --git a/plinth/tests/test_network.py b/plinth/tests/test_network.py index 56b60cf76..fabf8bb57 100644 --- a/plinth/tests/test_network.py +++ b/plinth/tests/test_network.py @@ -174,6 +174,7 @@ def test_edit_ethernet_connection(network, ethernet_uuid): ethernet_settings2['common']['name'] = 'plinth_test_eth_new' ethernet_settings2['common']['interface'] = 'eth1' ethernet_settings2['common']['zone'] = 'external' + ethernet_settings2['common']['autoconnect'] = False ethernet_settings2['ipv4']['method'] = 'auto' network.edit_connection(connection, ethernet_settings2) @@ -183,6 +184,7 @@ def test_edit_ethernet_connection(network, ethernet_uuid): settings_connection = connection.get_setting_connection() assert settings_connection.get_interface_name() == 'eth1' assert settings_connection.get_zone() == 'external' + assert not settings_connection.get_autoconnect() settings_ipv4 = connection.get_setting_ip4_config() assert settings_ipv4.get_method() == 'auto' @@ -195,6 +197,7 @@ def test_edit_pppoe_connection(network, pppoe_uuid): pppoe_settings2['common']['name'] = 'plinth_test_pppoe_new' pppoe_settings2['common']['interface'] = 'eth2' pppoe_settings2['common']['zone'] = 'external' + pppoe_settings2['common']['autoconnect'] = False pppoe_settings2['pppoe']['username'] = 'x-user-new' pppoe_settings2['pppoe']['password'] = 'x-password-new' network.edit_connection(connection, pppoe_settings2) @@ -205,6 +208,7 @@ def test_edit_pppoe_connection(network, pppoe_uuid): settings_connection = connection.get_setting_connection() assert settings_connection.get_interface_name() == 'eth2' assert settings_connection.get_zone() == 'external' + assert not settings_connection.get_autoconnect() settings_pppoe = connection.get_setting_pppoe() assert settings_pppoe.get_username() == 'x-user-new' @@ -223,6 +227,7 @@ def test_edit_wifi_connection(network, wifi_uuid): wifi_settings2['common']['name'] = 'plinth_test_wifi_new' wifi_settings2['common']['interface'] = 'wlan1' wifi_settings2['common']['zone'] = 'external' + wifi_settings2['common']['autoconnect'] = False wifi_settings2['ipv4']['method'] = 'auto' wifi_settings2['wireless']['ssid'] = 'plinthtestwifi2' wifi_settings2['wireless']['mode'] = 'infrastructure' @@ -237,6 +242,7 @@ def test_edit_wifi_connection(network, wifi_uuid): settings_connection = connection.get_setting_connection() assert settings_connection.get_interface_name() == 'wlan1' assert settings_connection.get_zone() == 'external' + assert not settings_connection.get_autoconnect() settings_wireless = connection.get_setting_wireless() assert settings_wireless.get_ssid().get_data() == b'plinthtestwifi2'