diff --git a/tests/test_link.py b/tests/test_link.py index 9ef85d8..89bb7aa 100644 --- a/tests/test_link.py +++ b/tests/test_link.py @@ -139,6 +139,22 @@ class Connecting(unittest.TestCase): self.link.work = lambda: 0 self.assertEqual(self.link.active_device()["alias"], "frame-2") # idle: move on + def test_nothing_elsewhere_moves_a_running_install(self): + """A bare alias in use, then another server sets up and picks a headset.""" + self.link.override = None + self.hosts({"localhost": "ok"}) + with mock.patch.object(fl, "ssh_g", return_value=("localhost", self.port, "tester", False)): + self.link.connect(["start"]) + started = self.routes[-1] + other = fd.Registry(self.dir / "devices.json") + other.set_active(other.add_device("frame-2", hosts=["192.0.2.2"])["id"]) + self.link.work = lambda: 1 + with mock.patch.object(fl, "ssh_g", return_value=("localhost", self.port, "tester", False)): + self.link.close_master() + self.link.connect(["dropped"]) + self.assertEqual(self.routes[-1][0], started[0]) + self.assertTrue(self.link.deferred) + def listen6(self): """A "different device": the same port on IPv6 loopback.""" try: diff --git a/ui/frame_link.py b/ui/frame_link.py index dba31a5..51979c6 100644 --- a/ui/frame_link.py +++ b/ui/frame_link.py @@ -487,11 +487,11 @@ class Link: device = dict(device, user=device.get("user") or u, port=p, frozen_host=h, proxied=proxied, frozen=[ "-o", f"HostName={frame_devices.ssh_host(h)}", "-o", f"Port={p}", *(["-o", f"User={u}"] if u else [])]) - if self.routed and self.routed_device and device["alias"] == self.routed_device["alias"] \ - and self.route_key(device) != self.routed and self.work(): - # Set Up Connection changed this headset in ~/.ssh/config (its login, or a bare - # alias became a set-up headset) while an install runs: reconnect as it - # started; the change applies once it's done (see watch_config). + if self.routed and self.routed_device and self.route_key(device) != self.routed and self.work(): + # While an install runs, nothing moves it: not Set Up Connection changing this + # headset in ~/.ssh/config, nor another Frame Control server adding, choosing + # or removing headsets in devices.json. (Switching here is refused meanwhile.) + # Reconnect as it started; the change applies once it's done (see watch_config). device = self.routed_device self.deferred = True if self.route_key(device) != self.routed: