Files
cc-ci/tests/matrix-synapse/custom/test_federation_version.py
T
notplantsandClaude Fable 5.1 9a80002b37
continuous-integration/drone/push Build is failing
lint: ruff format + one auto-fix so the push self-test is green again
`scripts/lint.sh --fix` from the pinned lint devshell: 90 Python files
reformatted (ruff format, mechanical) and one C420 (dict comprehension →
dict.fromkeys) in tests/unit/test_f211_sso_skip.py. The push self-test had
been failing at the lint stage since build 1313 (2026-08-31) on exactly
these files; nothing else changed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FqkQq3CDmFWcQ7u1LzoyRz
2026-09-07 21:15:05 +00:00

46 lines
2.1 KiB
Python

"""matrix-synapse — recipe-specific functional test (Phase 2 P3, ≥2 beyond parity).
Plan §4.3 explicitly names `/_matrix/federation/v1/version` as a matrix-synapse-specific test
target ("federation endpoint reachable"). This endpoint is the canonical "is this server
discoverable on the Matrix federation" probe — every Synapse exposes it, and federating servers
hit it to learn the running implementation + version.
This test fetches `/_matrix/federation/v1/version` and asserts:
1. Status 200.
2. JSON body with the documented `server` envelope: `{ "server": { "name": ..., "version": ... } }`.
3. `server.name` is the string `"Synapse"` (the running implementation).
4. `server.version` is a non-empty string (the running synapse build).
Non-vacuous: a generic matrix-compatible server with a different implementation name (e.g.
Dendrite) would fail the `name == "Synapse"` check. A misconfigured Synapse that hasn't booted
its federation subsystem returns 502; a homeserver with federation disabled returns 403/404.
Runs in the custom tier against the shared post-install live deployment.
"""
from __future__ import annotations
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "..", "runner"))
from harness import http as harness_http # noqa: E402
def test_federation_version_endpoint(live_app):
"""GET /_matrix/federation/v1/version → 200, JSON with server.name=Synapse."""
url = f"https://{live_app}/_matrix/federation/v1/version"
status, body = harness_http.retry_http_get(url, expect_status=200, max_wait=60, interval=3)
assert status == 200, f"GET {url} HTTP {status} (expected 200)"
assert isinstance(body, dict), f"federation version returned non-dict: {type(body).__name__}"
server = body.get("server")
assert isinstance(server, dict), (
f"federation version response missing 'server' envelope: {body!r}"
)
name = server.get("name")
assert name == "Synapse", f"server.name={name!r}, expected 'Synapse'"
version = server.get("version")
assert isinstance(version, str) and len(version) > 0, (
f"server.version is not a non-empty string: {version!r}"
)