mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-12-05 09:03:39 +01:00
Mail between two nodes that had just exchanged contact addresses never arrived readable. Fixes along the whole path, each covered by a test: - Status: the web UI's own requests get the full wormhole status, so it stops treating a ready node as not ready. - Invites: the owner node named in an invite is asked first, with an onion-sized timeout; an import that could not reach it finishes in the background and replaces the keyless contact it left behind. - Aliases: no one-sided mailbox alias is made up on compose; both sides address mail by node id until an alias is agreed. - Signing: each mailbox request is signed once, keeping polls under the sign rate limit. - MLS: the welcome is sent with the mail until the peer answers, and the receiver joins as the identity whose key package the sender used, with that identity's DH key. - Sender seal: a seal addressed to the node's DM identity opens even when the browser names the node's transport identity. - Gate rooms: the chat controller restarted the live stream and the room long-poll on every status refresh, about 60 requests a second, which exhausted local ports; it now reacts only to access changes, and the stream waits a minute between tries when there is no admin session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
2.5 KiB
Python
69 lines
2.5 KiB
Python
"""The operator's own UI sees whether the private DM route is ready.
|
|
|
|
The Messages view waits for transport_tier before it polls or sends. The
|
|
status routes hid every field but a few from callers without the admin key,
|
|
so the UI (which reaches the backend through its proxy, without the key)
|
|
never saw the tier and said "connecting" forever. The proxy's operator-client
|
|
token now counts as the operator for these status views only.
|
|
"""
|
|
|
|
import asyncio
|
|
|
|
import pytest
|
|
from starlette.requests import Request
|
|
|
|
import auth
|
|
import main
|
|
|
|
ADMIN_KEY = "test-admin-key-for-status"
|
|
|
|
|
|
def _request(path: str, token: str = "") -> Request:
|
|
headers = [(auth.OPERATOR_CLIENT_HEADER.lower().encode(), token.encode())] if token else []
|
|
return Request(
|
|
{
|
|
"type": "http",
|
|
"headers": headers,
|
|
"client": ("203.0.113.9", 50000),
|
|
"method": "GET",
|
|
"path": path,
|
|
"query_string": b"",
|
|
}
|
|
)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _state(monkeypatch):
|
|
monkeypatch.setattr(auth, "_current_admin_key", lambda: ADMIN_KEY)
|
|
monkeypatch.setattr(main, "_check_scoped_auth", lambda *_a, **_k: (False, "no"))
|
|
monkeypatch.setattr(main, "_is_debug_test_request", lambda *_a, **_k: False)
|
|
monkeypatch.setattr(
|
|
main,
|
|
"get_wormhole_state",
|
|
lambda: {"configured": True, "ready": True, "running": True, "arti_ready": True, "rns_ready": False},
|
|
)
|
|
monkeypatch.setattr(main, "_current_private_lane_tier", lambda *_a, **_k: "private_strong")
|
|
|
|
|
|
@pytest.mark.parametrize("route", ["api_wormhole_status", "api_wormhole_health", "api_get_wormhole_status"])
|
|
def test_operator_ui_sees_the_transport_tier(route):
|
|
handler = getattr(main, route)
|
|
token = auth.operator_client_token(ADMIN_KEY)
|
|
result = asyncio.run(handler(_request("/api/wormhole/status", token)))
|
|
assert result["transport_tier"] == "private_strong"
|
|
|
|
|
|
@pytest.mark.parametrize("route", ["api_wormhole_status", "api_wormhole_health", "api_get_wormhole_status"])
|
|
@pytest.mark.parametrize("token", ["", "0" * 64])
|
|
def test_others_still_get_the_redacted_view(route, token):
|
|
handler = getattr(main, route)
|
|
result = asyncio.run(handler(_request("/api/wormhole/status", token)))
|
|
assert "transport_tier" not in result
|
|
|
|
|
|
def test_token_is_ignored_in_lan_mode(monkeypatch):
|
|
monkeypatch.setattr(auth, "_lan_mode_enabled", lambda: True)
|
|
token = auth.operator_client_token(ADMIN_KEY)
|
|
result = asyncio.run(main.api_wormhole_status(_request("/api/wormhole/status", token)))
|
|
assert "transport_tier" not in result
|