aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/tests/test_availability_between_members.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/tests/test_availability_between_members.py')
-rw-r--r--packages/meshbay-hub/tests/test_availability_between_members.py139
1 files changed, 0 insertions, 139 deletions
diff --git a/packages/meshbay-hub/tests/test_availability_between_members.py b/packages/meshbay-hub/tests/test_availability_between_members.py
index 24d85a0..e66be31 100644
--- a/packages/meshbay-hub/tests/test_availability_between_members.py
+++ b/packages/meshbay-hub/tests/test_availability_between_members.py
@@ -202,56 +202,6 @@ async def test_the_notify_budget_is_not_refilled_by_reconnecting(client):
rev._notify_window.pop(node_id, None)
-# ── A member must not aim other people's traffic ─────────────────────────────
-
-@pytest.mark.asyncio
-async def test_a_swarm_source_cannot_name_someone_elses_address(client):
- """
- `endpoint` was free text documented as "ip:port", so an account could
- publish a third party's address as a source for any content. Nothing dials
- a swarm source today, which is the only reason this was not already the
- reflection primitive that `notify_incoming` was fixed for (H6). A port is
- all a reader needs: where the node is comes from the node record, which is
- stamped with the address its announce arrived from.
- """
- user = await _make_user(client, "av_swarm1")
- headers = {"Authorization": f"Bearer {user['token']}"}
-
- for bad in ("192.0.2.7:4433", "evil.example:53", "webrtc:0", "webrtc:70000",
- "webrtc:4433 ", "http://example.test"):
- r = await client.post("/v1/swarm/register", headers=headers,
- json={"content_hash": "ab" * 32, "endpoint": bad})
- assert r.status_code == 422, f"{bad!r} was accepted: {r.text}"
-
- r = await client.post("/v1/swarm/register", headers=headers,
- json={"content_hash": "ab" * 32, "endpoint": "webrtc:19010"})
- assert r.status_code == 201, r.text
-
-
-@pytest.mark.asyncio
-async def test_one_account_cannot_fill_the_swarm_table(client, monkeypatch):
- """Rows are keyed (hash, account) with no cap — an invented hash each time."""
- import meshbay_hub.api.groups as groups_api
- monkeypatch.setattr(groups_api, "MAX_SWARM_HASHES_PER_ACCOUNT", 3)
-
- user = await _make_user(client, "av_swarm2")
- headers = {"Authorization": f"Bearer {user['token']}"}
- for i in range(3):
- r = await client.post("/v1/swarm/register", headers=headers,
- json={"content_hash": f"{i:064x}",
- "endpoint": "webrtc:19010"})
- assert r.status_code == 201, r.text
-
- r = await client.post("/v1/swarm/register", headers=headers,
- json={"content_hash": f"{99:064x}", "endpoint": "webrtc:19010"})
- assert r.status_code == 429, r.text
-
- # Refreshing one already held is not a new claim and must still work.
- r = await client.post("/v1/swarm/register", headers=headers,
- json={"content_hash": f"{0:064x}", "endpoint": "webrtc:19011"})
- assert r.status_code == 201, r.text
-
-
# ── A member's node must not answer for another's ────────────────────────────
def test_a_node_cannot_answer_an_offer_it_was_never_sent():
@@ -321,75 +271,6 @@ async def test_an_invite_email_says_what_the_hub_knows_not_what_it_is_told(
"the sender chose the subject line of a message the hub signs")
-# ── A relay is not authenticated by the key it publishes ─────────────────────
-
-@pytest.mark.asyncio
-async def test_a_relay_must_prove_it_holds_the_approved_key(client, monkeypatch):
- """
- `relay_register` had no `Depends` and verified nothing: it compared
- `pk_relay` against the approved value, which is a **public** key. Anyone
- who could read it could rewrite where the hub tells nodes to send relayed
- traffic — an unauthenticated write to state other people's machines act
- on. The module docstring said the relay "signs keepalive JWTs"; `jwt` was
- imported and never used.
- """
- from meshbay_hub.api import relay as relay_mod
-
- # The registry ships closed (`relay.RELAYS_ENABLED`); the proof it demands
- # is still what will be wanted the day it opens.
- monkeypatch.setattr(relay_mod, "RELAYS_ENABLED", True)
- sk = Ed25519PrivateKey.generate()
- pk = pk_to_b64(sk.public_key())
- relay_mod._relays["r1"] = {"pk": pk, "active": False}
- try:
- # The public key alone, which used to be enough.
- r = await client.post("/v1/relays/register", json={
- "relay_id": "r1", "endpoint": "198.51.100.9:9999",
- "pk_relay": pk, "capacity": 100})
- assert r.status_code == 400, r.text
- assert relay_mod._relays["r1"].get("endpoint") is None
-
- # A signature over someone else's endpoint does not carry either: the
- # endpoint is inside the signed message.
- ts = int(time.time())
- sig = sk.sign(f"meshbay:relay_register:r1:10.0.0.1:4433:{ts}".encode())
- r = await client.post("/v1/relays/register", json={
- "relay_id": "r1", "endpoint": "198.51.100.9:9999", "pk_relay": pk,
- "timestamp": ts, "signature": base64.b64encode(sig).decode()})
- assert r.status_code == 401, r.text
-
- endpoint = "203.0.113.4:4433"
- sig = sk.sign(f"meshbay:relay_register:r1:{endpoint}:{ts}".encode())
- r = await client.post("/v1/relays/register", json={
- "relay_id": "r1", "endpoint": endpoint, "pk_relay": pk,
- "timestamp": ts, "signature": base64.b64encode(sig).decode()})
- assert r.status_code == 201, r.text
- assert relay_mod._relays["r1"]["endpoint"] == endpoint
- finally:
- relay_mod._relays.pop("r1", None)
-
-
-@pytest.mark.asyncio
-async def test_every_relay_route_is_closed_as_the_hub_ships(client):
- """Nothing in the tree uses the registry, and two of its routes take no account.
-
- A dependency on the router, so a route added later is closed too. The flag
- is read as shipped, not set here — a test that closes the gate itself
- would keep passing the day somebody opens it.
- """
- admin = await _make_user(client, "relayadmin")
- from meshbay_hub.api.deps import set_admin_usernames
- set_admin_usernames(["relayadmin"])
- auth = {"Authorization": f"Bearer {admin['token']}"}
-
- for method, path in (("get", "/v1/relays"),
- ("post", "/v1/relays/register"),
- ("post", "/v1/relays/approve")):
- kwargs = {"headers": auth} if method == "get" else {"json": {}, "headers": auth}
- r = await getattr(client, method)(path, **kwargs)
- assert r.status_code == 503, (path, r.status_code, r.text)
-
-
@pytest.mark.asyncio
async def test_a_stranger_who_locks_your_name_does_not_sign_you_out(client, db_session):
"""AV26. The sign-in lockout is keyed by username, and usernames are public.
@@ -442,26 +323,6 @@ async def test_a_stranger_who_locks_your_name_does_not_sign_you_out(client, db_s
assert r.status_code == 200, r.text
-@pytest.mark.asyncio
-async def test_a_captured_relay_registration_is_not_replayable(client, monkeypatch):
- """Same reason /v1/nodes/announce bounds its timestamp."""
- from meshbay_hub.api import relay as relay_mod
-
- monkeypatch.setattr(relay_mod, "RELAYS_ENABLED", True)
- sk = Ed25519PrivateKey.generate()
- pk = pk_to_b64(sk.public_key())
- relay_mod._relays["r2"] = {"pk": pk, "active": False}
- try:
- ts = int(time.time()) - 3600
- sig = sk.sign(f"meshbay:relay_register:r2:203.0.113.5:4433:{ts}".encode())
- r = await client.post("/v1/relays/register", json={
- "relay_id": "r2", "endpoint": "203.0.113.5:4433", "pk_relay": pk,
- "timestamp": ts, "signature": base64.b64encode(sig).decode()})
- assert r.status_code == 401, r.text
- finally:
- relay_mod._relays.pop("r2", None)
-
-
# ── Mail: three paths out of the hub, one of them unmetered ──────────────────
@pytest.mark.asyncio