tests: simulate available-connections in test-networkmanager-service.py

This commit is contained in:
Thomas Haller 2018-06-06 15:02:13 +02:00
parent 3255a97b3a
commit 2a53555faa
7 changed files with 66 additions and 18 deletions

View file

@ -2,7 +2,7 @@ location: clients/tests/test-client.py:763:test_003()/30
cmd: $NMCLI -f ALL dev show eth0
lang: C
returncode: 0
stdout: 1487 bytes
stdout: 1793 bytes
>>>
GENERAL.DEVICE: eth0
GENERAL.TYPE: ethernet
@ -33,7 +33,10 @@ CAPABILITIES.SPEED: 100 Mb/s
CAPABILITIES.IS-SOFTWARE: no
CAPABILITIES.SRIOV: no
WIRED-PROPERTIES.CARRIER: off
CONNECTIONS.AVAILABLE-CONNECTION-PATHS: --
CONNECTIONS.AVAILABLE-CONNECTION-PATHS: /org/freedesktop/NetworkManager/Settings/{3,2,1}
CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-ethernet-REPLACED-REPLACED-REPL | ethernet
CONNECTIONS.AVAILABLE-CONNECTIONS[2]: UUID-con-xx1-REPLACED-REPLACED-REPLA | con-xx1
CONNECTIONS.AVAILABLE-CONNECTIONS[3]: 5fcfd6d7-1e63-3332-8826-a7eda103792d | con-1
<<<
stderr: 0 bytes

View file

@ -2,7 +2,7 @@ location: clients/tests/test-client.py:763:test_003()/31
cmd: $NMCLI -f ALL dev show eth0
lang: pl_PL.UTF-8
returncode: 0
stdout: 1510 bytes
stdout: 1816 bytes
>>>
GENERAL.DEVICE: eth0
GENERAL.TYPE: ethernet
@ -33,7 +33,10 @@ CAPABILITIES.SPEED: 100Mb/s
CAPABILITIES.IS-SOFTWARE: nie
CAPABILITIES.SRIOV: nie
WIRED-PROPERTIES.CARRIER: wyłączone
CONNECTIONS.AVAILABLE-CONNECTION-PATHS: --
CONNECTIONS.AVAILABLE-CONNECTION-PATHS: /org/freedesktop/NetworkManager/Settings/{3,2,1}
CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-ethernet-REPLACED-REPLACED-REPL | ethernet
CONNECTIONS.AVAILABLE-CONNECTIONS[2]: UUID-con-xx1-REPLACED-REPLACED-REPLA | con-xx1
CONNECTIONS.AVAILABLE-CONNECTIONS[3]: 5fcfd6d7-1e63-3332-8826-a7eda103792d | con-1
<<<
stderr: 0 bytes

View file

@ -2,7 +2,7 @@ location: clients/tests/test-client.py:763:test_003()/51
cmd: $NMCLI -f ALL dev show eth0
lang: C
returncode: 0
stdout: 1487 bytes
stdout: 1793 bytes
>>>
GENERAL.DEVICE: eth0
GENERAL.TYPE: ethernet
@ -33,7 +33,10 @@ CAPABILITIES.SPEED: 100 Mb/s
CAPABILITIES.IS-SOFTWARE: no
CAPABILITIES.SRIOV: no
WIRED-PROPERTIES.CARRIER: off
CONNECTIONS.AVAILABLE-CONNECTION-PATHS: --
CONNECTIONS.AVAILABLE-CONNECTION-PATHS: /org/freedesktop/NetworkManager/Settings/{3,2,1}
CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-ethernet-REPLACED-REPLACED-REPL | ethernet
CONNECTIONS.AVAILABLE-CONNECTIONS[2]: UUID-con-xx1-REPLACED-REPLACED-REPLA | con-xx1
CONNECTIONS.AVAILABLE-CONNECTIONS[3]: 5fcfd6d7-1e63-3332-8826-a7eda103792d | con-1
<<<
stderr: 0 bytes

View file

@ -2,7 +2,7 @@ location: clients/tests/test-client.py:763:test_003()/52
cmd: $NMCLI -f ALL dev show eth0
lang: pl_PL.UTF-8
returncode: 0
stdout: 1510 bytes
stdout: 1816 bytes
>>>
GENERAL.DEVICE: eth0
GENERAL.TYPE: ethernet
@ -33,7 +33,10 @@ CAPABILITIES.SPEED: 100Mb/s
CAPABILITIES.IS-SOFTWARE: nie
CAPABILITIES.SRIOV: nie
WIRED-PROPERTIES.CARRIER: wyłączone
CONNECTIONS.AVAILABLE-CONNECTION-PATHS: --
CONNECTIONS.AVAILABLE-CONNECTION-PATHS: /org/freedesktop/NetworkManager/Settings/{3,2,1}
CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-ethernet-REPLACED-REPLACED-REPL | ethernet
CONNECTIONS.AVAILABLE-CONNECTIONS[2]: UUID-con-xx1-REPLACED-REPLACED-REPLA | con-xx1
CONNECTIONS.AVAILABLE-CONNECTIONS[3]: 5fcfd6d7-1e63-3332-8826-a7eda103792d | con-1
<<<
stderr: 0 bytes

View file

@ -2,7 +2,7 @@ location: clients/tests/test-client.py:874:test_004()/35
cmd: $NMCLI -f all dev show wlan0
lang: C
returncode: 0
stdout: 2948 bytes
stdout: 3077 bytes
>>>
GENERAL.DEVICE: wlan0
GENERAL.TYPE: wifi
@ -65,7 +65,8 @@ AP[3].RATE: 54 Mbit/s
AP[3].SIGNAL: 29
AP[3].BARS: *
AP[3].SECURITY: WPA1 WPA2
CONNECTIONS.AVAILABLE-CONNECTION-PATHS: --
CONNECTIONS.AVAILABLE-CONNECTION-PATHS: /org/freedesktop/NetworkManager/Settings/{2}
CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | con-xx1
<<<
stderr: 0 bytes

View file

@ -2,7 +2,7 @@ location: clients/tests/test-client.py:874:test_004()/36
cmd: $NMCLI -f all dev show wlan0
lang: pl_PL.UTF-8
returncode: 0
stdout: 2991 bytes
stdout: 3120 bytes
>>>
GENERAL.DEVICE: wlan0
GENERAL.TYPE: wifi
@ -65,7 +65,8 @@ AP[3].RATE: 54Mb/s
AP[3].SIGNAL: 29
AP[3].BARS: *
AP[3].SECURITY: WPA1 WPA2
CONNECTIONS.AVAILABLE-CONNECTION-PATHS: --
CONNECTIONS.AVAILABLE-CONNECTION-PATHS: /org/freedesktop/NetworkManager/Settings/{2}
CONNECTIONS.AVAILABLE-CONNECTIONS[1]: UUID-con-xx1-REPLACED-REPLACED-REPLA | con-xx1
<<<
stderr: 0 bytes

View file

@ -395,7 +395,7 @@ class ExportedObj(dbus.service.Object):
return self._dbus_interface_get_property(self._dbus_interface_get(dbus_iface),
propname)
def _dbus_property_set(self, dbus_iface, propname, value, allow_detect_dbus_iface = False, dry_run = False):
def _dbus_property_set(self, dbus_iface, propname, value, allow_detect_dbus_iface = False, dry_run = False, force_update = False):
if allow_detect_dbus_iface and not dbus_iface:
props = None
for p, dbus_interface in self._dbus_ifaces.items():
@ -436,6 +436,10 @@ class ExportedObj(dbus.service.Object):
assert propname in props
if not force_update:
if props[propname] == value:
return
props[propname] = value
self._dbus_property_notify(dbus_iface, propname)
@ -536,6 +540,24 @@ class Device(ExportedObj):
def set_active_connection(self, ac):
self._dbus_property_set(IFACE_DEVICE, PRP_DEVICE_ACTIVE_CONNECTION, ac)
def connection_is_available(self, con_inst):
if con_inst.is_vpn():
return False
if isinstance(self, WiredDevice):
if con_inst.get_type() == NM.SETTING_WIRED_SETTING_NAME:
return True
elif isinstance(self, WifiDevice):
if con_inst.get_type() == NM.SETTING_WIRELESS_SETTING_NAME:
return True
return False
def available_connections_get(self):
return [c for c in gl.settings.connections.values() if self.connection_is_available(c)]
def available_connections_update(self):
self._dbus_property_set(IFACE_DEVICE, PRP_DEVICE_AVAILABLE_CONNECTIONS,
ExportedObj.to_path_array(self.available_connections_get()))
###############################################################################
PRP_WIRED_HW_ADDRESS = "HwAddress"
@ -873,13 +895,11 @@ class ActiveConnection(ExportedObj):
def __init__(self, device, con_inst, specific_object):
is_vpn = (NmUtil.con_hash_get_type(con_inst.con_hash) == NM.SETTING_VPN_SETTING_NAME)
ExportedObj.__init__(self, ExportedObj.create_path(ActiveConnection))
self.device = device
self.con_inst = con_inst
self.is_vpn = is_vpn
self.is_vpn = con_inst.is_vpn()
self._activation_id = None
@ -899,13 +919,13 @@ class ActiveConnection(ExportedObj):
PRP_ACTIVE_CONNECTION_DEFAULT6: False,
PRP_ACTIVE_CONNECTION_IP6CONFIG: ExportedObj.to_path(None),
PRP_ACTIVE_CONNECTION_DHCP6CONFIG: ExportedObj.to_path(None),
PRP_ACTIVE_CONNECTION_VPN: is_vpn,
PRP_ACTIVE_CONNECTION_VPN: self.is_vpn,
PRP_ACTIVE_CONNECTION_MASTER: ExportedObj.to_path(None),
}
self.dbus_interface_add(IFACE_ACTIVE_CONNECTION, props, ActiveConnection.PropertiesChanged)
if is_vpn:
if self.is_vpn:
props = {
PRP_VPN_CONNECTION_VPN_STATE: dbus.UInt32(NM.VpnConnectionState.UNKNOWN),
PRP_VPN_CONNECTION_BANNER: '*** VPN connection %s ***' % (con_inst.get_id()),
@ -1200,6 +1220,10 @@ class NetworkManager(ExportedObj):
self.DeviceRemoved(ExportedObj.to_path(device))
device.unexport()
def devices_available_connections_update(self):
for d in self.devices:
d.available_connections_update()
@dbus.service.signal(IFACE_NM, signature='o')
def DeviceRemoved(self, devpath):
pass
@ -1350,6 +1374,12 @@ class Connection(ExportedObj):
def get_uuid(self):
return NmUtil.con_hash_get_uuid(self.con_hash)
def get_type(self):
return NmUtil.con_hash_get_type(self.con_hash)
def is_vpn(self):
return self.get_type() == NM.SETTING_VPN_SETTING_NAME
def update_connection(self, con_hash, do_verify_strict):
NmUtil.con_hash_verify(con_hash, do_verify_strict = do_verify_strict)
@ -1461,6 +1491,8 @@ class Settings(ExportedObj):
self.remove_next_connection = False
self.delete_connection(con_inst)
gl.manager.devices_available_connections_update()
return con_inst.path
def update_connection(self, con_hash, path=None, do_verify_strict=True):
@ -1474,6 +1506,8 @@ class Settings(ExportedObj):
con_inst.Removed()
con_inst.unexport()
gl.manager.devices_available_connections_update()
@dbus.service.method(dbus_interface=IFACE_SETTINGS, in_signature='s', out_signature='')
def SaveHostname(self, hostname):
# Arbitrary requirement to test error handling