summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/tests/test_transport_contracts.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/tests/test_transport_contracts.py')
-rw-r--r--packages/meshbay-hub/tests/test_transport_contracts.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/meshbay-hub/tests/test_transport_contracts.py b/packages/meshbay-hub/tests/test_transport_contracts.py
index 98ebd66..6c178a6 100644
--- a/packages/meshbay-hub/tests/test_transport_contracts.py
+++ b/packages/meshbay-hub/tests/test_transport_contracts.py
@@ -30,6 +30,7 @@ GROUP_PAGE = STATIC / "group-page.js"
SPLIT_FILES = [APP, GROUP_PAGE, CHAT_APP, STATIC / "files-app.js",
STATIC / "video-player.js", STATIC / "video-app.js",
STATIC / "music-app.js", STATIC / "music-player.js",
+ STATIC / "photos-app.js",
STATIC / "group-settings.js"]
pytestmark = pytest.mark.skipif(
@@ -119,6 +120,31 @@ def test_the_view_only_follows_new_messages_when_already_at_the_bottom(chat):
"scrolling unconditionally fights someone reading back through history")
+def test_every_authorize_admin_op_call_is_registered_in_admin_op_types(transport):
+ """
+ Found live (docs/photos.md's photo_roots): `setPhotoRoots` called
+ `_authorizeAdminOp(msg, 'photo_roots', ...)` like every other admin op,
+ but `photo_roots` was never added to `ADMIN_OP_TYPES` — so its initial
+ request was never keyed `admin:photo_roots`, the node's `admin_challenge`
+ reply matched no pending request (_dispatch's own keyed block, which
+ `return`s unconditionally whether or not it found a match), and the
+ request sat until its 30 s timeout with no error and no admin prompt.
+ `ADMIN_OP_TYPES`'s own comment already narrates this exact bug once,
+ for `audio_root`/`apps_enabled` — this pins it so a third op cannot
+ reintroduce it silently.
+ """
+ set_body = transport[transport.index("const ADMIN_OP_TYPES = new Set(["):]
+ set_body = set_body[:set_body.index("]);")]
+ registered = set(re.findall(r"'([a-z_]+)'", set_body))
+
+ called = set(re.findall(r"_authorizeAdminOp\(\s*\w+,\s*'([a-z_]+)'", transport))
+ assert called, "the extraction pattern itself found nothing — check it against transport.js"
+ missing = called - registered
+ assert not missing, (
+ f"{sorted(missing)} call _authorizeAdminOp but are missing from ADMIN_OP_TYPES — "
+ "their admin_challenge will silently time out instead of ever reaching the user")
+
+
def test_the_bottom_is_reached_by_scrollTop_not_a_sentinel(chat):
"""scrollIntoView on a zero-height marker stops short of the true bottom.