summaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/meshbay-node/tests/golden/cli.json863
-rw-r--r--packages/meshbay-node/tests/test_cli_golden.py138
2 files changed, 1001 insertions, 0 deletions
diff --git a/packages/meshbay-node/tests/golden/cli.json b/packages/meshbay-node/tests/golden/cli.json
new file mode 100644
index 0000000..5ddd7fd
--- /dev/null
+++ b/packages/meshbay-node/tests/golden/cli.json
@@ -0,0 +1,863 @@
+{
+ "--help": {
+ "api": [],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "usage: meshbay-node [-h] [--hub-url HUB_URL] [--username USERNAME] [--dir DIR] [--yes]\n [--config CONFIG] [--group GROUP] [--link] [--writable] [--no-writable]\n [--removable] [--no-removable] [--name NAME]\n [--log-level {DEBUG,INFO,WARNING,ERROR}]\n [{init,reset,status,gek-init,gek,operator,member,group,root,file,video,chat,denylist,stun,transfers,reload,restart-daemon,autostart,service,calibrate-argon2}]\n [subcommand] [target] [value]\n\nMeshBay Node daemon\n\npositional arguments:\n {init,reset,status,gek-init,gek,operator,member,group,root,file,video,chat,denylist,stun,transfers,reload,restart-daemon,autostart,service,calibrate-argon2}\n init: provision config + keystore | reset: erase all node state | status:\n node state and keys | operator pair: pair a browser with this node |\n member list|invite|cancel|revoke|unpin | group list|add|remove | root\n list|add|remove|set|eject|plug | gek init|rotate | file list|rm | video\n rematch: re-resolve TMDB matches for a group's videos | chat\n status|rotate|encrypt-history|prune | denylist show|clear | stun\n list|add|remove|reset | transfers show|set|max-size|per-member: live\n transfer slots, the node-wide caps, the largest single upload, and how\n many one member may run at once in a group | reload: re-read node.toml\n (hot; systemd or the loopback API) | restart-daemon: restart the node\n (systemd unit, the Windows autostart launcher, or the service task,\n whichever applies) | autostart install|remove|start|stop|status (Windows:\n run meshbay-node at each sign-in, no admin) | service\n install|remove|start|stop|status (Windows: run at boot, before sign-in,\n needs admin once to install) | calibrate-argon2: benchmark\n subcommand 'pair' for operator; list|invite|revoke|unpin for member; list|add|remove\n for group; list|add|remove|set|eject|plug for root; init|rotate for gek;\n list|rm for file; rematch for video; show|clear for denylist;\n list|add|remove|reset for stun; show|set|max-size|per-member for\n transfers; install|remove|start|stop|status for autostart and for service\n target username for member invite|revoke|unpin (an e-mail address with --link, a\n link id for member cancel); group name for group add; file id for file rm;\n identifier for denylist clear; download cap for transfers set; size in GB\n for transfers max-size\n value the second value where a verb takes two: the upload cap for transfers set\n\noptions:\n -h, --help show this help message and exit\n --hub-url HUB_URL hub URL, for init (e.g. https://meshbay.org)\n --username USERNAME hub username, for init\n --dir DIR shared directory, for group add\n --yes skip the confirmation for destructive commands\n --config CONFIG Config file path\n --group GROUP group id (optional if only one is configured)\n --link member invite: an invitation link for this e-mail address, for someone who\n may have no account yet\n --writable root accepts member uploads (root add/set)\n --no-writable root is read-only (root add/set, group add)\n --removable mark root as removable (root set/add)\n --no-removable mark root as not removable (root set)\n --name NAME root name (root add; defaults to directory basename)\n --log-level {DEBUG,INFO,WARNING,ERROR}\n",
+ "systemctl": []
+ },
+ "autostart no-such-sub": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "autostart is Windows-only — elsewhere use 'systemctl --user enable --now meshbay-node'.\n",
+ "systemctl": []
+ },
+ "autostart status": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "autostart is Windows-only — elsewhere use 'systemctl --user enable --now meshbay-node'.\n",
+ "systemctl": []
+ },
+ "chat encrypt-history": {
+ "api": [],
+ "asked": [
+ "re-encrypt now? [y/N] "
+ ],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "This rewrites the only copy of this group's older messages.\nA backup of chat.db is taken first, beside it.\ncancelled\n",
+ "systemctl": []
+ },
+ "chat encrypt-history --yes": {
+ "api": [
+ [
+ "POST",
+ "/api/groups/gggggggggggggggggggggggggggggggg/chat/encrypt-history",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "re-encrypted 0 message(s) under epoch 1\nbackup <tmp>/chat.db.bak\n",
+ "systemctl": []
+ },
+ "chat no-such-sub": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node chat status|rotate|encrypt-history|prune [--group G]\n",
+ "systemctl": []
+ },
+ "chat prune": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node chat prune <days> [--group G]\n",
+ "systemctl": []
+ },
+ "chat prune 30": {
+ "api": [
+ [
+ "POST",
+ "/api/groups/gggggggggggggggggggggggggggggggg/chat/prune?max_age_days=30",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "removed 0 message(s) older than 30 day(s)\n",
+ "systemctl": []
+ },
+ "chat rotate": {
+ "api": [
+ [
+ "POST",
+ "/api/groups/gggggggggggggggggggggggggggggggg/chat/epoch",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "chat epoch 1 opened\nEveryone still in the group keeps reading the history; whoever left\ncannot read what is written from now on.\n",
+ "systemctl": []
+ },
+ "chat status": {
+ "api": [
+ [
+ "GET",
+ "/api/groups/gggggggggggggggggggggggggggggggg/chat",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "encryption always on (MNP 3.4)\nepoch 1\nmessages 0 encrypted, 0 in the clear\n",
+ "systemctl": []
+ },
+ "denylist clear": {
+ "api": [],
+ "asked": [
+ "clear now? [y/N] "
+ ],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "Clearing the denylist re-admits EVERY entry.\nA revocation the hub sent will not come back on its own.\ncancelled\n",
+ "systemctl": []
+ },
+ "denylist clear --yes": {
+ "api": [
+ [
+ "POST",
+ "/api/denylist/clear?subject=",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "removed 0 entr(y/ies) (all)\n",
+ "systemctl": []
+ },
+ "denylist no-such-sub": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node denylist show|clear [identifier] [--yes]\n",
+ "systemctl": []
+ },
+ "denylist show": {
+ "api": [
+ [
+ "GET",
+ "/api/denylist",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "denylist empty — nothing is being refused\n",
+ "systemctl": []
+ },
+ "file list": {
+ "api": [
+ [
+ "GET",
+ "/api/groups/gggggggggggggggggggggggggggggggg/files",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "no files indexed\n",
+ "systemctl": []
+ },
+ "file no-such-sub": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node file list|rm <id> [--group NAME] [--yes]\n",
+ "systemctl": []
+ },
+ "file rm abc": {
+ "api": [
+ [
+ "GET",
+ "/api/groups/gggggggggggggggggggggggggggggggg/files",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "no file whose id starts with 'abc'\n",
+ "systemctl": []
+ },
+ "file rm abc --yes": {
+ "api": [
+ [
+ "GET",
+ "/api/groups/gggggggggggggggggggggggggggggggg/files",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "no file whose id starts with 'abc'\n",
+ "systemctl": []
+ },
+ "gek init": {
+ "api": [
+ [
+ "POST",
+ "/api/groups/gggggggggggggggggggggggggggggggg/gek",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "GEK ready for gggggggggggggggggggggggggggggggg\n 0 authorized member(s) — each receives the key on connect\n",
+ "systemctl": []
+ },
+ "gek no-such-sub": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node gek init|rotate [--group NAME]\n",
+ "systemctl": []
+ },
+ "gek rotate": {
+ "api": [],
+ "asked": [
+ "rotate now? [y/N] "
+ ],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "Rotating replaces this group's key.\n · every member re-receives it automatically on their next connect\n · anyone revoked keeps the OLD key and loses access to new content\n · content already downloaded stays readable to whoever has it\ncancelled\n",
+ "systemctl": []
+ },
+ "gek rotate --yes": {
+ "api": [
+ [
+ "POST",
+ "/api/groups/gggggggggggggggggggggggggggggggg/gek?rotate=true",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "GEK ready for gggggggggggggggggggggggggggggggg\n 0 authorized member(s) — each receives the key on connect\n",
+ "systemctl": []
+ },
+ "gek-init": {
+ "api": [
+ [
+ "POST",
+ "/api/groups/gggggggggggggggggggggggggggggggg/gek",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "GEK ready for gggggggggggggggggggggggggggggggg\n 0 authorized member(s) — each receives the key on connect\n",
+ "systemctl": []
+ },
+ "group add": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node group add <name> --dir <path> [--no-writable]\n\nThe group must already exist on the hub and be yours. This\nonly tells the node to host it, and picks its first\ndirectory, which accepts uploads unless --no-writable.\nAdd more with: meshbay-node root add <path> [--writable]\n",
+ "systemctl": []
+ },
+ "group add g --dir /tmp/media --no-writable": {
+ "api": [
+ [
+ "POST",
+ "/api/groups/attach",
+ {
+ "name": "g",
+ "shared_dir": "/tmp/media",
+ "writable": false
+ }
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "g (g) added to <tmp>/node.toml\n shared_dir <tmp> (read-only)\n\nTell the daemon to re-read its config, then give the group a key:\n meshbay-node reload\n meshbay-node gek init --group g\n\nThe key is this group's own — members of your other groups cannot\nread it, and joining one says nothing about the other.\n",
+ "systemctl": []
+ },
+ "group list": {
+ "api": [
+ [
+ "GET",
+ "/api/groups",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "no groups hosted — add one with: meshbay-node group add <name> --dir <path>\n",
+ "systemctl": []
+ },
+ "group no-such-sub": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node group list|add|remove <name>\n",
+ "systemctl": []
+ },
+ "member cancel abababababababababababababababab": {
+ "api": [
+ [
+ "DELETE",
+ "/api/groups/gggggggggggggggggggggggggggggggg/invite-links/abababababababababababababababab",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "invitation link abababab cancelled\n",
+ "systemctl": []
+ },
+ "member invite bob": {
+ "api": [
+ [
+ "POST",
+ "/api/groups/gggggggggggggggggggggggggggggggg/invites?username=bob",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "INVITATION CODE TEST-CODE\nvalid until \n\nSend it to bob however you normally talk. It works\nonce, for that account only, and never passes through the hub.\nThey enter it the first time they open the group — you do not\nneed to be online then.\n\nalso written to <tmp>/home/.local/share/meshbay/invite-code\n",
+ "systemctl": []
+ },
+ "member invite bob@example.test --link": {
+ "api": [
+ [
+ "POST",
+ "/api/groups/gggggggggggggggggggggggggggggggg/invite-links?email=bob%40example.test",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "INVITATION LINK https://example.invalid/#/invite?v=1\nvalid until \ncancel with meshbay-node member cancel abababababababababababababababab\n\nSend it to bob@example.test yourself. It works once, and only for an\naccount registered with that address: they open it, create their\naccount or sign in, and land in the group without typing a code.\n",
+ "systemctl": []
+ },
+ "member list": {
+ "api": [
+ [
+ "GET",
+ "/api/roster",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "no members admitted yet\ninvite someone: meshbay-node member invite <username>\n",
+ "systemctl": []
+ },
+ "member no-such-sub": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node member no-such-sub <username>\n",
+ "systemctl": []
+ },
+ "member revoke bob": {
+ "api": [
+ [
+ "GET",
+ "/api/resolve?username=bob",
+ null
+ ],
+ [
+ "POST",
+ "/api/members/u/revoke?group_id=gggggggggggggggggggggggggggggggg",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "bob revoked from gggggggg\n",
+ "systemctl": []
+ },
+ "member unpin bob": {
+ "api": [
+ [
+ "GET",
+ "/api/resolve?username=bob",
+ null
+ ],
+ [
+ "POST",
+ "/api/members/u/unpin",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "bob unpinned — they can pair again with a new key\nissue a code: meshbay-node member invite bob\n",
+ "systemctl": []
+ },
+ "member upload": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "`member upload` is gone. Uploads are decided per directory now:\n\n meshbay-node root list # which are read-write\n meshbay-node root set <name> --writable # accept uploads there\n meshbay-node root set <name> --no-writable # stop them\n\nA group whose directories are all read-only accepts no uploads at all,\nwhich is what turning the old switch off meant.\n",
+ "systemctl": []
+ },
+ "no-such-verb": {
+ "api": [],
+ "asked": [],
+ "exit": 2,
+ "stderr": "usage: meshbay-node [-h] [--hub-url HUB_URL] [--username USERNAME] [--dir DIR] [--yes]\n [--config CONFIG] [--group GROUP] [--link] [--writable] [--no-writable]\n [--removable] [--no-removable] [--name NAME]\n [--log-level {DEBUG,INFO,WARNING,ERROR}]\n [{init,reset,status,gek-init,gek,operator,member,group,root,file,video,chat,denylist,stun,transfers,reload,restart-daemon,autostart,service,calibrate-argon2}]\n [subcommand] [target] [value]\nmeshbay-node: error: argument command: invalid choice: 'no-such-verb' (choose from 'init', 'reset', 'status', 'gek-init', 'gek', 'operator', 'member', 'group', 'root', 'file', 'video', 'chat', 'denylist', 'stun', 'transfers', 'reload', 'restart-daemon', 'autostart', 'service', 'calibrate-argon2')\n",
+ "stdout": "",
+ "systemctl": []
+ },
+ "operator no-such-sub": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node operator pair\n",
+ "systemctl": []
+ },
+ "operator pair": {
+ "api": [
+ [
+ "POST",
+ "/api/operator/pair",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "PAIRING CODE TEST-CODE\nvalid until \n\nSign in to the web app as this node's operator, open one of your\ngroups, go to the Members tab and enter the code there.\nIt works once, for that account only, and authorizes invites and\nfile deletion from that browser.\n\nalso written to <tmp>/home/.local/share/meshbay/pair-code\n",
+ "systemctl": []
+ },
+ "reload": {
+ "api": [],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "sent reload to meshbay-node\nwatch the result: journalctl --user -u meshbay-node -f\n",
+ "systemctl": [
+ [
+ "systemctl",
+ "--user",
+ "daemon-reload"
+ ],
+ [
+ "systemctl",
+ "--user",
+ "reload",
+ "meshbay-node"
+ ]
+ ]
+ },
+ "restart-daemon": {
+ "api": [],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "meshbay-node restarted via systemd\ncheck status: systemctl --user status meshbay-node\nwatch logs: journalctl --user -u meshbay-node -f\n",
+ "systemctl": [
+ [
+ "systemctl",
+ "--user",
+ "daemon-reload"
+ ],
+ [
+ "systemctl",
+ "--user",
+ "restart",
+ "meshbay-node"
+ ]
+ ]
+ },
+ "root add": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node root add <path> [--name NAME] [--writable] [--removable] [--group NAME]\n",
+ "systemctl": []
+ },
+ "root add /tmp/media --writable --removable": {
+ "api": [
+ [
+ "POST",
+ "/api/groups/gggggggggggggggggggggggggggggggg/roots",
+ {
+ "name": "media",
+ "path": "/tmp/media",
+ "removable": true,
+ "writable": true
+ }
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "added root media → /tmp/media (rw, removable)\nreload the daemon to start indexing:\n meshbay-node reload\n",
+ "systemctl": []
+ },
+ "root eject media": {
+ "api": [
+ [
+ "PUT",
+ "/api/groups/gggggggggggggggggggggggggggggggg/roots/media/eject",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "ejected root media — files are hidden until plugged back\n",
+ "systemctl": []
+ },
+ "root list": {
+ "api": [
+ [
+ "GET",
+ "/api/groups",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "group gggggggg not hosted on this node\n",
+ "systemctl": []
+ },
+ "root no-such-sub": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node root list|add|remove|set|eject|plug [name] [--group NAME]\n",
+ "systemctl": []
+ },
+ "root plug media": {
+ "api": [
+ [
+ "PUT",
+ "/api/groups/gggggggggggggggggggggggggggggggg/roots/media/plug",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "plugged root media — files are visible again\n",
+ "systemctl": []
+ },
+ "root remove media": {
+ "api": [],
+ "asked": [
+ "remove? [y/N] "
+ ],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "Remove root 'media' from group gggggggg?\nFiles on disk are untouched; only the node config changes.\ncancelled\n",
+ "systemctl": []
+ },
+ "root remove media --yes": {
+ "api": [
+ [
+ "DELETE",
+ "/api/groups/gggggggggggggggggggggggggggggggg/roots/media",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "removed root media\nreload the daemon to apply:\n meshbay-node reload\n",
+ "systemctl": []
+ },
+ "root set media": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "nothing to change — pass --writable/--no-writable or --removable/--no-removable\n",
+ "systemctl": []
+ },
+ "root set media --no-writable": {
+ "api": [
+ [
+ "PATCH",
+ "/api/groups/gggggggggggggggggggggggggggggggg/roots/media",
+ {
+ "writable": false
+ }
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "updated root media: writable=False\n",
+ "systemctl": []
+ },
+ "service no-such-sub": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "service mode is Windows-only — elsewhere use 'systemctl --user enable --now meshbay-node'.\n",
+ "systemctl": []
+ },
+ "service status": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "service mode is Windows-only — elsewhere use 'systemctl --user enable --now meshbay-node'.\n",
+ "systemctl": []
+ },
+ "status": {
+ "api": [],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "hub https://example.invalid (user —)\nnode key <no keystore — run: meshbay-node init>\ndaemon not running\nconfig <tmp>/node.toml\ngroups none configured — create a group on the hub, then add\n a [[groups]] entry with its id and a directory\noperator NONE PAIRED — file deletion and member invites are\n refused. Run: meshbay-node operator pair\n",
+ "systemctl": []
+ },
+ "stun list": {
+ "api": [
+ [
+ "GET",
+ "/api/node-settings",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "stun servers (none configured)\n",
+ "systemctl": []
+ },
+ "stun no-such-sub": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node stun list|add|remove|reset [url]\n",
+ "systemctl": []
+ },
+ "transfers": {
+ "api": [
+ [
+ "GET",
+ "/api/transfers",
+ null
+ ],
+ [
+ "GET",
+ "/api/node-settings",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "\n largest single upload: 8 GB per file (meshbay-node transfers max-size <GB>)\n\n nothing transferring\n",
+ "systemctl": []
+ },
+ "transfers max-size": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node transfers max-size <GB>\n",
+ "systemctl": []
+ },
+ "transfers max-size 0": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "error: a ceiling of zero is not 'unlimited'; it would refuse every upload. Make the root read-only instead.\n",
+ "systemctl": []
+ },
+ "transfers max-size 0.5": {
+ "api": [
+ [
+ "PUT",
+ "/api/node-settings",
+ {
+ "max_upload_gb": 0.5
+ }
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "largest single upload: 0.5 GB per file (applied now, and kept in node.toml)\n",
+ "systemctl": []
+ },
+ "transfers max-size 8": {
+ "api": [
+ [
+ "PUT",
+ "/api/node-settings",
+ {
+ "max_upload_gb": 8.0
+ }
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "largest single upload: 8 GB per file (applied now, and kept in node.toml)\n",
+ "systemctl": []
+ },
+ "transfers max-size huge": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "error: the size must be a number of GB (e.g. 8, or 0.5)\n",
+ "systemctl": []
+ },
+ "transfers no-such-sub": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node transfers show|set <downloads> <uploads>|max-size <GB>|per-member <downloads> <uploads> [--group NAME]\n",
+ "systemctl": []
+ },
+ "transfers per-member 0 2": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "error: a cap below 1 is not 'unlimited'; it would stop every transfer for that member. Revoke them instead.\n",
+ "systemctl": []
+ },
+ "transfers per-member 4": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node transfers per-member <downloads> <uploads> [--group NAME]\n",
+ "systemctl": []
+ },
+ "transfers per-member 4 2": {
+ "api": [
+ [
+ "PUT",
+ "/api/groups/gggggggggggggggggggggggggggggggg/transfer-limits",
+ {
+ "downloads": 4,
+ "uploads": 2
+ }
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "each member of this group may now run None download(s) and None upload(s) at once\n",
+ "systemctl": []
+ },
+ "transfers set 0 2": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "error: a cap below 1 is not 'unlimited'; it would stop every transfer. Revoke the member instead.\n",
+ "systemctl": []
+ },
+ "transfers set 4": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node transfers set <downloads> <uploads>\n",
+ "systemctl": []
+ },
+ "transfers set 4 2": {
+ "api": [
+ [
+ "PUT",
+ "/api/node-settings",
+ {
+ "max_concurrent_downloads": 4,
+ "max_concurrent_uploads": 2
+ }
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "downloads: 4, uploads: 2 (applied now, and kept in node.toml)\n",
+ "systemctl": []
+ },
+ "transfers show": {
+ "api": [
+ [
+ "GET",
+ "/api/transfers",
+ null
+ ],
+ [
+ "GET",
+ "/api/node-settings",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "\n largest single upload: 8 GB per file (meshbay-node transfers max-size <GB>)\n\n nothing transferring\n",
+ "systemctl": []
+ },
+ "video no-such-sub": {
+ "api": [],
+ "asked": [],
+ "exit": 1,
+ "stderr": "",
+ "stdout": "usage: meshbay-node video rematch [--group NAME] [--yes]\n",
+ "systemctl": []
+ },
+ "video rematch": {
+ "api": [],
+ "asked": [
+ "proceed? [y/N] "
+ ],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "Re-resolve every automatic TMDB match for this group's videos?\nManual 'Fix match' corrections are kept. Re-resolution is lazy —\neach poster re-queries TMDB the next time it is opened.\ncancelled\n",
+ "systemctl": []
+ },
+ "video rematch --yes": {
+ "api": [
+ [
+ "POST",
+ "/api/groups/gggggggggggggggggggggggggggggggg/video/rematch",
+ null
+ ]
+ ],
+ "asked": [],
+ "exit": 0,
+ "stderr": "",
+ "stdout": "cleared 0 automatic match(es) across 0 video file(s)\n",
+ "systemctl": []
+ }
+}
diff --git a/packages/meshbay-node/tests/test_cli_golden.py b/packages/meshbay-node/tests/test_cli_golden.py
new file mode 100644
index 0000000..ddaa82f
--- /dev/null
+++ b/packages/meshbay-node/tests/test_cli_golden.py
@@ -0,0 +1,138 @@
+"""
+What `meshbay-node` prints and asks for, verb by verb, recorded once and held.
+
+A characterisation test, like test_dispatch_golden.py: it states no rule of its
+own, it pins the CLI as it is, so that `main()` can be taken apart underneath
+it. Every verb test_cli_dispatch.py walks, the ones that ask for confirmation
+without --yes, each verb with a subcommand it does not have, `--help` and a
+verb that does not exist, is run with the daemon stubbed out, and what is
+recorded is the exit code, stdout, stderr, each loopback call with its body,
+each question asked and each `systemctl` run. The help text is in there whole:
+the user guide quotes it.
+
+The recording is `golden/cli.json`. When a change to this behaviour is
+intended, regenerate it with MESHBAY_GOLDEN_WRITE=1 and read the diff.
+"""
+
+import builtins
+import getpass
+import json
+import os
+import subprocess
+import sys
+from pathlib import Path
+
+import pytest
+from meshbay_node import config as config_mod
+from meshbay_node import daemon as daemon_mod
+from test_cli_dispatch import VERBS
+
+GOLDEN = Path(__file__).parent / "golden" / "cli.json"
+# The verbs that ask first, asked and answered "no": test_cli_dispatch.py
+# passes --yes to all of them.
+UNCONFIRMED = [
+ ["root", "remove", "media"],
+ ["gek", "rotate"],
+ ["file", "rm", "abc"],
+ ["video", "rematch"],
+ ["chat", "encrypt-history"],
+ ["denylist", "clear"],
+]
+# Each verb's last resort, its own usage line.
+UNKNOWN_SUB = [[verb, "no-such-sub"] for verb in (
+ "gek", "operator", "member", "group", "root", "file", "video", "chat",
+ "denylist", "stun", "transfers", "autostart", "service")]
+CASES = [["--help"], ["no-such-verb"], *VERBS, *UNCONFIRMED, *UNKNOWN_SUB]
+
+
+def _run(argv: list[str], tmp_path: Path, capsys) -> dict:
+ api: list = []
+ asked: list = []
+ systemctl: list = []
+
+ def fake_api(cfg, path, method="GET", timeout=30, body=None):
+ api.append([method, path, body])
+ return {
+ "groups": [], "files": [], "identities": [], "members": [],
+ "invites": [], "users": [], "jtis": [], "count": 0, "removed": 0,
+ "subject": "all", "code": "TEST-CODE", "expires_at": "",
+ "link": "https://example.invalid/#/invite?v=1", "invite_id": "ab" * 16,
+ "user_id": "u", "authorized_members": 0, "errors": [],
+ "name": "g", "group_id": "g", "shared_dir": str(tmp_path),
+ "config": str(tmp_path / "node.toml"),
+ "enabled": False, "epoch": 1, "converted": 0,
+ "backup": str(tmp_path / "chat.db.bak"),
+ "encrypted": False, "plaintext_messages": 0,
+ "encrypted_messages": 0, "max_age_days": 30,
+ }
+
+ def fake_input(prompt=""):
+ asked.append(prompt)
+ return "n"
+
+ def fake_run(args, **kw):
+ systemctl.append(args)
+ return subprocess.CompletedProcess(args, 0, stdout="", stderr="")
+
+ conf = tmp_path / "node.toml"
+ conf.write_text('[hub]\nurl = "https://example.invalid"\n')
+ code = 0
+ with pytest.MonkeyPatch.context() as mp:
+ mp.setattr(daemon_mod, "_daemon_api", fake_api)
+ mp.setattr(daemon_mod, "_resolve_group", lambda cfg, g: "g" * 32)
+ mp.setattr(daemon_mod, "DEFAULT_CONFIG_PATH", conf)
+ # The data directory and the keystore's default path come from these;
+ # left real, `status` would record the developer's own node.
+ mp.setenv("HOME", str(tmp_path / "home"))
+ mp.setattr(config_mod, "DEFAULT_CONFIG_PATH", conf)
+ mp.setattr(builtins, "input", fake_input)
+ mp.setattr(getpass, "getpass", lambda *a, **kw: "test-password")
+ mp.setattr(subprocess, "run", fake_run)
+ # argparse wraps the help to the terminal's width.
+ mp.setenv("COLUMNS", "100")
+ mp.setattr(sys, "argv", ["meshbay-node", *argv])
+ try:
+ daemon_mod.main()
+ except SystemExit as e:
+ code = e.code
+ out = capsys.readouterr()
+
+ def mask(text: str) -> str:
+ return text.replace(str(tmp_path), "<tmp>")
+
+ return json.loads(mask(json.dumps({
+ "exit": code, "stdout": out.out, "stderr": out.err,
+ "api": api, "asked": asked, "systemctl": systemctl})))
+
+
+def _record(tmp_path: Path, capsys) -> dict:
+ return {" ".join(argv): _run(argv, tmp_path, capsys) for argv in CASES}
+
+
+def test_every_verb_prints_as_recorded(tmp_path, capsys):
+ if os.environ.get("MESHBAY_GOLDEN_WRITE") == "1":
+ GOLDEN.write_text(json.dumps(_record(tmp_path, capsys), indent=1,
+ sort_keys=True, ensure_ascii=False) + "\n",
+ encoding="utf-8")
+ golden = json.loads(GOLDEN.read_text(encoding="utf-8"))
+ now = _record(tmp_path, capsys)
+
+ assert sorted(now) == sorted(golden), (
+ "the set of verbs changed; regenerate on purpose if it should")
+ differ = [k for k in golden if now[k] != golden[k]]
+ detail = "\n".join(
+ f" {k}\n" + "\n".join(f" {f}: was {golden[k][f]!r}\n {f}: now {now[k][f]!r}"
+ for f in golden[k] if golden[k][f] != now[k][f])
+ for k in differ[:5])
+ assert not differ, f"{len(differ)} verb(s) behave differently:\n{detail}"
+
+
+def test_the_recording_exercises_the_cli():
+ """A recording of nothing would hold nothing."""
+ golden = json.loads(GOLDEN.read_text(encoding="utf-8"))
+ assert "usage: meshbay-node" in golden["--help"]["stdout"]
+ assert golden["no-such-verb"]["exit"] == 2
+ assert sum(1 for c in golden.values() if c["api"]) > 30, "the daemon was never asked"
+ assert sum(1 for c in golden.values() if c["exit"] not in (0, None)) > 5, (
+ "no usage line was ever reached")
+ assert any(c["asked"] for c in golden.values()), "no confirmation was ever asked"