aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/tests/test_group_leave_and_quota.py
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-30 11:49:56 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-30 11:49:56 +0200
commitd3ad243c4ae3a273f623bd5fc631e3266aa4d0e4 (patch)
tree95ff1252c80a71e93c5098822d31b835572d8b52 /packages/meshbay-hub/tests/test_group_leave_and_quota.py
parent69554fac7eba6eef7eb8a1c0111c5b92e7f21256 (diff)
downloadmeshbay-d3ad243c4ae3a273f623bd5fc631e3266aa4d0e4.tar.gz
fix: only the owner decides who hosts a group, and nobody is made a member unasked
- hub: a node may host a group only if its account owns it or the owner approved that node (new `group_hosts`). Membership was the ceiling, and every member holds the group key, so any member's node could register as a host and be the one clients kept. A node claiming a group it may not host is recorded as a request; the owner is notified once and approves or refuses it (GET/POST/DELETE /v1/groups/{id}/hosts[/{node_id}]), which takes effect on a connected node at once. - hub: an owner adding a username creates an invitation (new `group_invitations`), accepted or declined by the invitee (/v1/groups/invitations, /{id}/invitation/accept|decline). Until then the group is not listed, not dialled, not searched and not in any token. Invitation links, open joins and group creation still make members directly: they are the account's own act. - hub: the MNP token names only the group it is minted for (group_id is now required), so a node operator no longer learns a member's other groups. - SPA: invitations on the home page; invited people and host requests in the group's settings; the transport sends group_id. Ten catalogues. - Browser probes for both screens, run in Chrome and Firefox. - Design §5.2, §7.2, §7.3, AV32, AV33; protocol §6.3; user guide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub/tests/test_group_leave_and_quota.py')
-rw-r--r--packages/meshbay-hub/tests/test_group_leave_and_quota.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/packages/meshbay-hub/tests/test_group_leave_and_quota.py b/packages/meshbay-hub/tests/test_group_leave_and_quota.py
index 8af830d..e4efc09 100644
--- a/packages/meshbay-hub/tests/test_group_leave_and_quota.py
+++ b/packages/meshbay-hub/tests/test_group_leave_and_quota.py
@@ -17,6 +17,7 @@ import hashlib
from datetime import UTC, datetime
import pytest
+from membership import add_member
from meshbay_hub.api.groups import MAX_PUBLIC_GROUPS
from meshbay_hub.db.models import Group, GroupMember, User
from sqlalchemy import select
@@ -55,7 +56,7 @@ async def test_a_member_can_leave(client, db_session):
owner = await _user(client, "owner1_test")
member = await _user(client, "member1_test")
gid = await _group(client, owner, "readers")
- await client.post(f"/v1/groups/{gid}/members/member1_test", json={}, headers=owner)
+ await add_member(client, gid, 'member1_test', owner)
# Marked hosted, or the member would not see the group in the first place
# and the assertion below would hold whether or not leaving worked.
@@ -80,7 +81,7 @@ async def test_leaving_removes_only_that_membership_row(client, db_session):
owner = await _user(client, "owner2_test")
member = await _user(client, "member2_test")
gid = await _group(client, owner, "still-here")
- await client.post(f"/v1/groups/{gid}/members/member2_test", json={}, headers=owner)
+ await add_member(client, gid, 'member2_test', owner)
await client.post(f"/v1/groups/{gid}/leave", headers=member)
@@ -100,8 +101,8 @@ async def test_leaving_does_not_touch_the_account_or_its_other_groups(client, db
elsewhere = await _user(client, "owner3b_test")
gid = await _group(client, owner, "leaving")
other = await _group(client, elsewhere, "staying")
- await client.post(f"/v1/groups/{gid}/members/member3_test", json={}, headers=owner)
- await client.post(f"/v1/groups/{other}/members/member3_test", json={}, headers=elsewhere)
+ await add_member(client, gid, 'member3_test', owner)
+ await add_member(client, other, 'member3_test', elsewhere)
await client.post(f"/v1/groups/{gid}/leave", headers=member)
@@ -130,7 +131,7 @@ async def test_leaving_twice_is_refused(client):
owner = await _user(client, "owner5_test")
member = await _user(client, "member5_test")
gid = await _group(client, owner, "once")
- await client.post(f"/v1/groups/{gid}/members/member5_test", json={}, headers=owner)
+ await add_member(client, gid, 'member5_test', owner)
assert (await client.post(f"/v1/groups/{gid}/leave",
headers=member)).status_code == 200
@@ -203,7 +204,7 @@ async def test_the_cap_is_per_owner(client):
b = await _user(client, "ownerb2_test")
for i in range(MAX_PUBLIC_GROUPS):
gid = await _group(client, a, f"a-pub-{i}", visibility="public")
- await client.post(f"/v1/groups/{gid}/members/ownerb2_test", json={}, headers=a)
+ await add_member(client, gid, 'ownerb2_test', a)
r = await client.post("/v1/groups",
json={"name": "b-first", "visibility": "public",