diff options
Diffstat (limited to 'packages/meshbay-hub/tests/test_node_ws_auth.py')
| -rw-r--r-- | packages/meshbay-hub/tests/test_node_ws_auth.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/packages/meshbay-hub/tests/test_node_ws_auth.py b/packages/meshbay-hub/tests/test_node_ws_auth.py index 7d96851..ca2cb25 100644 --- a/packages/meshbay-hub/tests/test_node_ws_auth.py +++ b/packages/meshbay-hub/tests/test_node_ws_auth.py @@ -44,6 +44,11 @@ async def _make_user(client, username: str) -> dict: async def _announce_node(client, user: dict) -> str: + # A node only ever reaches the socket with its key linked to the account: + # `/v1/nodes/auth` issues no token otherwise. + r = await client.put("/v1/users/me/node_key", json={"pk_node_ed25519": user["pk_ed"]}, + headers={"Authorization": f"Bearer {user['token']}"}) + assert r.status_code == 200, r.text # Announce now requires proof of possession of the node key (M8). import time as _t ts = int(_t.time()) @@ -62,8 +67,9 @@ async def _announce_node(client, user: dict) -> str: def _node_token(user: dict) -> str: + """What `/v1/nodes/auth` issues: a node token naming the key that signed in.""" from meshbay_hub.auth import issue_access_token - return issue_access_token(user["user_id"], scope="node") + return issue_access_token(user["user_id"], scope="node", node_key=user["pk_ed"]) @pytest.mark.asyncio |