diff --git a/docker-compose.yml b/docker-compose.yml index adadcb7..a36c6b8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,7 @@ services: environment: DATABASE_URL: postgresql+psycopg://scrobbler:${POSTGRES_PASSWORD:-scrobbler}@db:5432/scrobbler SECRET_KEY: ${SECRET_KEY:-change-me} - CORS_ORIGINS: ${UI_BASE_URL:-http://localhost:8080} + CORS_ORIGINS: ${CORS_ORIGINS:-http://localhost:8080} UI_BASE_URL: ${UI_BASE_URL:-http://localhost:8080} WEB_CONCURRENCY: ${WEB_CONCURRENCY:-2} FORWARDED_ALLOW_IPS: "*" diff --git a/docs/design/activitypub-phase1.md b/docs/design/activitypub-phase1.md index 4ef2dc0..1d41deb 100644 --- a/docs/design/activitypub-phase1.md +++ b/docs/design/activitypub-phase1.md @@ -1,6 +1,6 @@ # ActivityPub phase 1: discoverable profile -**Status: done** on `feature/activitypub` (`98c6554` … `913ef67`). The one gap is the manual check with a real Mastodon account through a tunnel: it's still to do, and needs a public HTTPS address. +**Status: done** on `feature/activitypub` (`98c6554` … `913ef67`). The manual check with a real Mastodon account through a tunnel (`cloudflared`) is also done: WebFinger, the actor and the key all resolved correctly from mastodon.social and activitypub.academy. This implements phase 1 of [activitypub.md](activitypub.md). Handles and actor URLs are on the **UI's domain**, and posts are **followers only by default** (a per-user setting). diff --git a/docs/design/activitypub-phase2.md b/docs/design/activitypub-phase2.md index 6050d80..eb219e9 100644 --- a/docs/design/activitypub-phase2.md +++ b/docs/design/activitypub-phase2.md @@ -1,6 +1,6 @@ # ActivityPub phase 2: followers -**Status: done** on `feature/activitypub` (`a6d3fb6` … `fe95f59`). The GoToSocial interop test passes locally and in CI. Before merging, the plan still calls for a manual pass with a real Mastodon account through a tunnel. +**Status: done** on `feature/activitypub` (`a6d3fb6` … `fe95f59`). The GoToSocial interop test passes locally and in CI. The manual pass with a real Mastodon account through a tunnel is also done: follow, unfollow, manual approval, and block/unblock all worked correctly. Where this differed from the plan: diff --git a/docs/design/activitypub-phase3.md b/docs/design/activitypub-phase3.md index cfe57e3..3285cd1 100644 --- a/docs/design/activitypub-phase3.md +++ b/docs/design/activitypub-phase3.md @@ -1,6 +1,6 @@ # ActivityPub phase 3: posts -**Status: done** on `feature/activitypub` (`bc717c2` … `860d4d0`). The GoToSocial interop test now covers posts too: a weekly summary reaches a follower's home timeline as `private` with the expected content, and disappears from it when deleted. As with phases 1-2, a manual pass with a real Mastodon account through a tunnel is still to do before merging. +**Status: done** on `feature/activitypub` (`bc717c2` … `860d4d0`). The GoToSocial interop test now covers posts too: a weekly summary reaches a follower's home timeline as `private` with the expected content, and disappears from it when deleted. The manual pass with a real Mastodon account through a tunnel (done alongside phase 4's, see its notes) confirmed a forced weekly summary posted and deleted correctly there too. Where this differed from the plan: diff --git a/docs/design/activitypub-phase4.md b/docs/design/activitypub-phase4.md index 3dab2f3..ccef145 100644 --- a/docs/design/activitypub-phase4.md +++ b/docs/design/activitypub-phase4.md @@ -1,11 +1,15 @@ # ActivityPub phase 4: now playing -**Status: done** on `feature/activitypub` (`7d86bad` … `9883111`). The GoToSocial interop test now covers now playing too: turning it on updates the "Now playing" field GoToSocial has cached for the profile, via the periodic `Update(Person)` push - not just a fresh fetch showing the live truth, which was already covered by the actor route's own tests. As with phases 1-3, a manual pass with a real Mastodon account through a tunnel is still to do before merging. +**Status: done** on `feature/activitypub` (`7d86bad` … `9883111`, plus a `docker-compose.yml` fix from the manual pass below). The GoToSocial interop test now covers now playing too: turning it on updates the "Now playing" field GoToSocial has cached for the profile, via the periodic `Update(Person)` push - not just a fresh fetch showing the live truth, which was already covered by the actor route's own tests. + +The manual pass with a real Mastodon account through a tunnel (the last standing gap after every phase) is also done now, covering phases 1-4 together: WebFinger, actor and follow/unfollow/approve/block against mastodon.social and activitypub.academy over a `cloudflared` tunnel, a forced weekly summary posting and deleting correctly, and the now-playing profile field appearing, clearing, and respecting the 5-minute push throttle. Where this differed from the plan: - **The now-playing key had to be hashed, not raw.** `artist\x1ftrack\x1fstarted_at` was going straight into `federation_posts.key` (`VARCHAR(64)`), which real track and artist names routinely overflow. Caught by the first Postgres-backed test that used a real track name, not by anything in the plan itself. - **`now_playing_field()` needed its own privacy gate.** It read core's `now_playing` table (populated for every user regardless of federation settings) without checking `now_playing_mode` itself, so a user who'd never turned the feature on at all would still leak what they were listening to if a caller forgot to gate it externally. Found while designing the periodic push task, not by a test written against the plan - the existing tests happened to never combine "something playing" with "mode off". Fixed by moving the gate inside `now_playing_field()` itself, so there's exactly one place that can get this wrong. +- **`docker-compose.yml` hardcoded the API's `CORS_ORIGINS` to `UI_BASE_URL`.** Found during the manual pass: pointing `UI_BASE_URL` at the tunnel host (needed for federation's own identity) silently changed which browser origins the API accepted, blocking the operator's own `localhost:8080` UI from calling it at all - an `.env` `CORS_ORIGINS` setting had no effect, since the compose file never referenced it. Fixed by making `CORS_ORIGINS` its own variable, defaulting the same as before. +- **`TestConfig` wasn't isolating `UI_BASE_URL`/`CORS_ORIGINS` either.** The same local `.env` change broke six tests that assert on `http://localhost:8080` URLs, the same way an earlier session found `FEDERATION_ENABLED`/`LASTFM_API_KEY` leaking from a developer's `.env` into the test run. Pinned alongside them. This implements phase 4 of [activitypub.md](activitypub.md): **now playing**, the last of the "still open" decisions there. It builds on [phase 3](activitypub-phase3.md): publishing, delivery and the web UI for posts. diff --git a/docs/design/activitypub.md b/docs/design/activitypub.md index 9a83579..9ae59ff 100644 --- a/docs/design/activitypub.md +++ b/docs/design/activitypub.md @@ -337,7 +337,7 @@ Everything goes on the existing Prometheus and Grafana setup: - visibility addressing - **In-process federation**: two Scrobbler instances in one test process following each other. - **A real peer in CI**: a [GoToSocial](https://gotosocial.org) container, which is a single binary with SQLite. It follows a Scrobbler user and we assert that it receives the `Accept` and the posts. That's much lighter than running Mastodon in CI. -- **Manual pass before release**: +- **Manual pass before release** (done, over a `cloudflared` tunnel - see [phase 4](activitypub-phase4.md)): - follow from a real Mastodon account - check the profile, posts, profile-field updates and unfollowing - check with [verify.funfedi.dev](https://verify.funfedi.dev/) or the [ActivityPub Academy](https://activitypub.academy/) diff --git a/src/scrobbler/config.py b/src/scrobbler/config.py index 667c759..b16a5d0 100644 --- a/src/scrobbler/config.py +++ b/src/scrobbler/config.py @@ -76,7 +76,9 @@ class TestConfig(Config): "postgresql+psycopg://scrobbler:scrobbler@localhost:5432/scrobbler_test", ) START_METRICS_SERVER = False - # Tests never inherit optional features from a developer's .env or environment; - # tests that need them turn them on explicitly. + # Tests never inherit optional features or URLs from a developer's .env or + # environment; tests that need them turn them on, or override them, explicitly. LASTFM_API_KEY = "" FEDERATION_ENABLED = "0" + UI_BASE_URL = "http://localhost:8080" + CORS_ORIGINS = ["http://localhost:8080"]