Files
Warp/server/test/complement/README.md
T
tajniak81andClaude Opus 5.5 a94794b866
CI / Test (ubuntu-latest) (push) Canceled after 0s
CI / Test (windows-latest) (push) Canceled after 0s
CI / Storage tests on PostgreSQL (push) Canceled after 0s
CI / Complement (federation off) (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
CI / Smoke test the binary (push) Canceled after 0s
Phase 9: application services and admin completion
Implements PLAN.md Phase 9. internal/appservice reads registration files
(appservice.config_files), matches namespaces the way Synapse does
(anchored at the start), and delivers events to each service as
transactions read from the roomserver's event stream at a cursor kept in
appservice_state. A transaction in flight is recorded, so after a restart
it is resent under the same ID; failures back off from 2s to 5m, and a
successful ping cuts the backoff short.

In the Client-Server API an as_token acts as the service's sender or, with
?user_id=, as any existing user in its namespace. Services register and
log in their users with m.login.application_service; exclusive user and
alias namespaces are refused to everybody else with M_EXCLUSIVE. Unknown
aliases and users in a namespace are asked of the service first. The
ping endpoint reports M_URL_NOT_SET, M_BAD_STATUS, M_CONNECTION_FAILED
and M_CONNECTION_TIMEOUT. Services' own requests, and their users' when
rate_limited is false, skip the rate limiter.

Users can change their password (POST /account/password) and deactivate
their account (POST /account/deactivate), both behind the password.
Deactivation revokes tokens, deletes devices, optionally erases the
profile and leaves every room through a new userapi.AccountObserver.

The admin API is complete: user detail, the admin flag, deactivation and
reactivation, password resets, devices, media quotas
(media.max_user_storage_bytes plus per-user overrides), registration
tokens with use limits and expiry (registration.require_token), server
notices (internal/servernotices, server_notices.*), an editor for the
federation allow/deny lists persisted in server_settings, a delivery view
of the application services, and an audit log of every change.

Migration 0011 adds the registration token, server notice room, media
quota, audit log and appservice cursor tables. Policy lists are now
returned sorted. The Complement entrypoint loads the registrations
Complement mounts in /complement/appservice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 12:58:28 +02:00

89 lines
3.7 KiB
Markdown

# Complement
[Complement](https://github.com/matrix-org/complement) is the official
Matrix integration suite and this project's primary progress metric
(PLAN.md section 9). It runs one container per homeserver per test and
drives it over the real HTTP API.
```sh
make complement # the C-S set, federation off
make complement-federation # the federation set
bash run.sh TestLogin # one test
COMPLEMENT_DEBUG=1 make complement # with the container logs
```
Needs Docker. [run.sh](run.sh) builds the image, clones Complement into
`.complement/` at the repository root (git-ignored) and runs the subset for
the phases that are done.
## Files
| | |
|---|---|
| [Dockerfile](Dockerfile) | the homeserver image, built from the repository root |
| [entrypoint.sh](entrypoint.sh) | the deployment, entirely `WARP_*` environment variables |
| [run.sh](run.sh) | build, clone, run |
## Profiles
`COMPLEMENT_PROFILE` picks one; each has its own test set in `run.sh`.
**`csapi`** (the default, `make complement`) — the Client-Server tests in
`tests/csapi`, with `WARP_FEDERATION_ENABLED=false`. Port 8448 is still
served over TLS, because the CA is mounted either way, but the gate answers
every federation request with `M_UNRECOGNIZED`.
**`federation`** (`make complement-federation`) — the federation tests in
`tests/` and the multi-server tests in `tests/csapi`, with federation on.
The entrypoint has Complement's CA at `/complement/ca` sign a certificate
for the server's name, serves the API on 8448 with it, and points
`federation.tls_ca_file` at the same CA, so that Warp trusts the other
homeservers of the run and the servers Complement itself pretends to be.
The switch reaches the container through `COMPLEMENT_SHARE_ENV_PREFIX`:
`run.sh` sets `PASS_WARP_FEDERATION_ENABLED`, which Complement passes on
as `WARP_FEDERATION_ENABLED`.
The federation set leaves out partial-state joins (MSC3706,
`TestPartialStateJoin*`), which Warp does not implement.
Application services arrived in Phase 9. Complement writes the
registration file of each service a blueprint asks for into
`/complement/appservice`, and `entrypoint.sh` hands every file there to
`WARP_APPSERVICE_CONFIG_FILES`. The tests that use them, and the Phase 9
account tests (password change, deactivation), are not in either set yet.
They join once a run has shown which pass.
## The test set
`COMPLEMENT_TESTS` in `run.sh` lists what is expected to pass. Phase 1:
- `TestRegistration`
- `TestLogin`
- `TestDeviceManagement`
Extend it as each phase lands rather than switching to the whole suite: a
pass count that drops because a later phase is missing is noise, not
information.
Two notes on the environment, both in `entrypoint.sh`:
- **Rate limiting is off.** The whole suite comes from the one address the
test runner has, so the limiter would spend the run returning
`M_LIMIT_EXCEEDED` and tell us nothing about the server. Synapse's own
Complement image does the same.
- **Registration is on**, because the tests create their own users.
## Tests that need later phases
Some subtests of the three above reach for endpoints that are not Phase 1
work. `TestDeviceManagement` calls `/sync` after creating a session, and
`TestLogout` checks that a revoked token cannot sync. Phase 1 answers
`/sync` with an empty but well-formed response for exactly that reason —
there are no rooms yet, so an empty sync is the complete truth, and it makes
token revocation observable. Phase 4 replaces it with the real syncapi.
The shared-secret registration subtests of `TestRegistration` probe
`/_synapse/admin/v1/register` and skip themselves when it 404s, which it
does here: that endpoint is Synapse's, and `warp create-account` covers the
same need.