From 1dbcd012ecd521271d7e3b0f9739c2c03a4728e7 Mon Sep 17 00:00:00 2001 From: Josiah Baldwin Date: Wed, 5 Feb 2025 12:16:01 -0800 Subject: [PATCH 1/4] Added test to check for issue with mulitple meshes --- tests/test_session.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_session.py b/tests/test_session.py index 3bc6b7e..344d887 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -200,15 +200,17 @@ async def test_mesh_device(env): assert r[0].description == "New description", "Description either failed to change, or was changed by a user without permission to do so" + # There once was a bug that occured whenever running run_commands with multiple meshes. We need to add devices to both meshes to be sure that bug is squashed. with env.create_agent(mesh.short_meshid) as agent,\ - env.create_agent(mesh.short_meshid) as agent2: + env.create_agent(mesh.short_meshid) as agent2,\ + env.create_agent(mesh2.short_meshid) as agent3: # Test agent added to device group being propagated correctly # Create agent isn't so good at waiting for the agent to show in the sessions. Give it a couple seconds to appear. for i in range(3): try: r = await admin_session.list_devices(timeout=10) print("\ninfo list_devices: {}\n".format(r)) - assert len(r) == 2, "Incorrect number of agents connected" + assert len(r) == 3, "Incorrect number of agents connected" except: if i == 2: raise From 79554ebad6ebf8b732d609328d85c7deffc11788 Mon Sep 17 00:00:00 2001 From: Josiah Baldwin Date: Wed, 5 Feb 2025 12:28:06 -0800 Subject: [PATCH 2/4] Added differintiation between admin device info and unprivileged device info for tests, as unprivileged doesn't have any mesh info at the time of testing --- tests/test_session.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_session.py b/tests/test_session.py index 344d887..197220a 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -229,6 +229,9 @@ async def test_mesh_device(env): r = await admin_session.list_devices(meshid=mesh.meshid, timeout=10) print("\ninfo list_devices_meshid: {}\n".format(r)) + r = await admin_session.device_info(agent.nodeid, timeout=10) + print("\ninfo admin_device_info: {}\n".format(r)) + # Test editing device info propagating correctly assert await admin_session.edit_device(agent.nodeid, name="new_name", description="New Description", tags="device", consent=meshctrl.constants.ConsentFlags.all, timeout=10), "Failed to edit device info" @@ -271,7 +274,7 @@ async def test_mesh_device(env): # Test getting individual device info r = await unprivileged_session.device_info(agent.nodeid, timeout=10) - print("\ninfo device_info: {}\n".format(r)) + print("\ninfo unprivileged_device_info: {}\n".format(r)) # This device info includes the mesh ID of the device, even though the user doesn't have acces to that mesh. That's odd. # assert r.meshid is None, "Individual device is exposing its meshid" From 5393321f7bb2188985c268d72003d1d0be9617a2 Mon Sep 17 00:00:00 2001 From: Josiah Baldwin Date: Wed, 5 Feb 2025 12:30:13 -0800 Subject: [PATCH 3/4] Fixed issue with getting device_info when multiple meshes are available --- src/meshctrl/session.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/meshctrl/session.py b/src/meshctrl/session.py index 0672715..119b05f 100644 --- a/src/meshctrl/session.py +++ b/src/meshctrl/session.py @@ -1363,10 +1363,10 @@ class Session(object): node["meshid"] = meshid if _mesh is not None: node["mesh"] = _mesh - sysinfo["node"] = node - sysinfo["nodeid"] = nodeid - del sysinfo["result"] - del sysinfo["noinfo"] + break + else: + continue + break if node is None: raise ValueError("Invalid device id") if lastconnect is not None: From 77e76aeb7c08d388d911e1228a90fc438cd43fe2 Mon Sep 17 00:00:00 2001 From: Josiah Baldwin Date: Wed, 5 Feb 2025 12:35:23 -0800 Subject: [PATCH 4/4] Updated changelog --- CHANGELOG.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 69ab04a..9e08c55 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,11 @@ Changelog ========= +Version 1.1.1 +============= +Bugs: + * Fixed bug when running device_info when user has access to multiple meshes + Version 1.1.0 ============= Features: