# Testing Checklist **Status**: Active **Last Updated**: 2026-11-03 (v2.10.1) What to test, how to run the tests, and what CI does with them. Setup and the environment variables the tests need are in [development-setup.md](development-setup.md#running-the-tests). ## How tests run **Locally** ```bash SESSION_SECRET=test uv run pytest # everything SESSION_SECRET=test uv run pytest --ignore=tests/test_migration_race_condition.py # fast loop ``` `tests/test_migration_race_condition.py` takes about 5 minutes; skip it while iterating, never before a release. **In CI** (`.gitea/workflows/build-container.yml`), on every pushed `vX.Y.Z` tag (or a manual run): 1. `docker buildx build --target test -f Containerfile .` builds the Containerfile's `test` stage: the runtime dependencies plus pytest and pytest-mock, with `SESSION_SECRET=ci-test-secret`, `SITE_URL=http://localhost:5000` and `ADMIN_ME=https://test.example.com`, then `python -m pytest -q -p no:cacheprovider tests`. 2. Only if that succeeds is the runtime image built and pushed as `:vX.Y.Z` and `:latest`. So a failing test blocks the release image; it does not block the merge or the tag. Run the full suite before merging (see [git-branching-strategy.md](git-branching-strategy.md#release-process)). To reproduce CI locally: `docker build --target test -f Containerfile .` (pytest-cov is not installed in that stage, so don't depend on it in tests). ## Every change - [ ] Full suite passes locally - [ ] New behaviour has tests; a bug fix has a test that failed before the fix - [ ] Tests use the `app` / `client` fixtures from `tests/conftest.py` (temporary data directory, `TESTING=True`); nothing touches `./data` - [ ] No test makes real network requests (see below) - [ ] Schema changes: a numbered migration in `migrations/`, plus a test that it applies to an existing database (`tests/test_migrations.py`) ## Conventions - **Where**: one file per module or feature (`tests/test_websub.py`). Work driven by a spec review or an incident gets its own file named for the release, with a docstring saying what it covers, e.g. `test_micropub_v290.py`, `test_microformats_v280.py`, `test_websub_hardening.py` ("one test per finding of the v2.10.0 review"). - **Outbound HTTP**: everything StarPunk fetches from or sends to other servers goes through `starpunk/webmention_ssrf.py`. Tests replace its transport and DNS instead of mocking callers: ```python monkeypatch.setattr("starpunk.webmention_ssrf.socket.getaddrinfo", lambda *a, **k: PUBLIC) monkeypatch.setattr("starpunk.webmention_ssrf.TRANSPORT", httpx.MockTransport(handler)) ``` (see the `web` fixture in `tests/test_websub.py`). Test the private address rejection by making `getaddrinfo` return e.g. `10.0.0.2`. - **Background workers** don't run under `TESTING=True`. Drive them directly, e.g. `WebSubWorker(app)` inside `app.app_context()` (`run_worker` in `tests/test_websub.py`). - **Crossposting** targets are configured per test with app config overrides and mocked HTTP; never with real credentials. - **Concurrency** fixes need a test that reproduces the race with real processes or threads (`tests/test_migration_concurrency.py`). ## New or changed protocol work StarPunk implements Micropub, IndieAuth, Webmention, WebSub and microformats2. For changes to any of them: - [ ] Read the W3C Recommendation (or the living spec) and cite section numbers in the ADR and in test names or docstrings - [ ] Test each MUST that the change touches, including the error responses (status codes, `error` values, headers) and not only the happy path - [ ] Test discovery: `Link` headers and `` elements still advertise the endpoint on every page and feed that should have them - [ ] Test what a strict client sends: form-encoded and JSON (Micropub), case and percent-encoding variants (WebSub topics), relative URLs (Webmention sources) - [ ] Test that requests to user-supplied URLs are refused for private addresses and time out - [ ] Rendered markup: parse the page with `mf2py` and assert on the parsed properties (`tests/test_microformats*.py`), not on raw HTML strings - [ ] Manual check against the live site after deploy with the external validators below ## Validation tools (manual, after deploy) | Protocol | Tool | |---|---| | Micropub | [micropub.rocks](https://micropub.rocks/), a real client (Quill, Indigenous) | | IndieAuth | Sign in to a Micropub client; [indieauth.rocks](https://indieauth.rocks/) | | Webmention | [webmention.rocks](https://webmention.rocks/) | | WebSub | [websub.rocks](https://websub.rocks/) (publisher and hub tests) | | Microformats2 | [pin13.net/mf2](https://pin13.net/mf2/), [IndieWebify.me](https://indiewebify.me/) | | Feeds | [W3C Feed Validator](https://validator.w3.org/feed/) (RSS, Atom), [JSON Feed validator](https://validator.jsonfeed.org/) | | HTML | [W3C HTML validator](https://validator.w3.org/) | ## Specifications - Micropub: https://www.w3.org/TR/micropub/ - IndieAuth: https://indieauth.spec.indieweb.org/ - Webmention: https://www.w3.org/TR/webmention/ - WebSub: https://www.w3.org/TR/websub/ - Microformats2 h-entry: https://microformats.org/wiki/h-entry - RSS 2.0: https://www.rssboard.org/rss-specification, Atom: RFC 4287, JSON Feed 1.1: https://www.jsonfeed.org/version/1.1/