From 44a56fca606d1a9171fd3e9ba55882d42e747695 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 3 Nov 2019 23:06:31 +0100 Subject: [PATCH] libnm/tests: fix stub implementation for remote-next-connection We cannot first remove the connection (and emit property changed signals), before replying with the newly added path (that already no longer exists). Fix the stub implementation. --- tools/test-networkmanager-service.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py index 1a8e2e6af5..03ed7bde52 100755 --- a/tools/test-networkmanager-service.py +++ b/tools/test-networkmanager-service.py @@ -1592,6 +1592,9 @@ class Connection(ExportedObj): @dbus.service.method(dbus_interface=IFACE_CONNECTION, in_signature='', out_signature='a{sa{sv}}') def GetSettings(self): + if hasattr(self, '_remove_next_connection_cb'): + self._remove_next_connection_cb() + raise BusErr.UnknownConnectionException("Connection not found") if not self.visible: raise BusErr.PermissionDeniedException() return self.con_hash @@ -1694,11 +1697,21 @@ class Settings(ExportedObj): self.NewConnection(con_inst.path) self._dbus_property_set(IFACE_SETTINGS, PRP_SETTINGS_CONNECTIONS, dbus.Array(self.get_connection_paths(), 'o')) + gl.manager.devices_available_connections_update() + if self.remove_next_connection: self.remove_next_connection = False - self.delete_connection(con_inst) - - gl.manager.devices_available_connections_update() + def cb(): + if hasattr(con_inst, '_remove_next_connection_cb'): + del con_inst._remove_next_connection_cb + self.delete_connection(con_inst) + return False + # We will delete the connection right away on an idle handler. However, + # the test races with initializing the connection (calling GetSettings()). + # To avoid the race, we will check in GetSettings() whether the profile + # is about to be deleted, and delete it first. + con_inst._remove_next_connection_cb = cb + GLib.idle_add(cb) return con_inst.path