Files
owncast/test/automated/activitypub
Gabe KangasandGitHub 5a4af3a294 ActivityPub background actor validation, update and cleanup process (#4765)
* feat(ap): add validation+update+cleanup AP actor job

* fix(test): use time.Time instead of sql.NullTime

* feat(test): add integration test for AP follower cleanup/validation job
2026-02-02 17:34:25 -08:00
..
2026-01-21 22:33:55 -08:00
2026-01-21 22:33:55 -08:00
2026-01-21 22:33:55 -08:00
2026-01-21 22:33:55 -08:00

ActivityPub Federation Test

This test verifies Owncast's ActivityPub federation by having snac2 users follow the Owncast instance and confirming message delivery.

One-Time Setup

1. Install mkcert

# Ubuntu/Debian
sudo apt install mkcert

# Or download directly
curl -sLO https://github.com/FiloSottile/mkcert/releases/download/v1.4.4/mkcert-v1.4.4-linux-amd64
chmod +x mkcert-v1.4.4-linux-amd64
sudo mv mkcert-v1.4.4-linux-amd64 /usr/local/bin/mkcert

2. Install the local CA

This installs a Certificate Authority into your system's trust store. All certificates generated by mkcert will be trusted.

mkcert -install

3. Generate certificates for the test domains

cd test/automated/activitypub
mkdir -p certs
mkcert -cert-file certs/cert.pem -key-file certs/key.pem owncast.local snac.local localhost 127.0.0.1

4. Add hosts entries

sudo sh -c 'echo "127.0.0.1 owncast.local snac.local" >> /etc/hosts'

5. Install snac2

# Ubuntu/Debian
sudo apt install snac2

# Or build from source
git clone https://codeberg.org/grunfink/snac2.git
cd snac2
make
sudo make install

6. Install Caddy

Caddy is used as the HTTPS reverse proxy for TLS termination. It will be installed automatically by setup.sh, or you can install it manually:

# Download binary directly
curl -sL "https://github.com/caddyserver/caddy/releases/download/v2.8.4/caddy_2.8.4_linux_amd64.tar.gz" | sudo tar -xz -C /usr/local/bin caddy

# Or see: https://caddyserver.com/docs/install

Running the Test

# Run with default 100 users
./run.sh

# Run with fewer users for quick testing
USER_COUNT=10 ./run.sh

# Keep servers running after test for debugging
KEEP_RUNNING=true ./run.sh

# Adjust follow request throttling (default 0.1s)
FOLLOW_DELAY=0.2 ./run.sh

# Run in CI mode (skip interactive prompts)
CI=true ./run.sh

Configuration Options

Variable Default Description
USER_COUNT 100 Number of test users to create
FOLLOW_DELAY 0.1 Delay in seconds between follow requests
KEEP_RUNNING false Keep servers running after test for debugging
CI false Skip interactive prompts for CI environments
PROXY_PORT 8443 HTTPS proxy port
SNAC_PORT 9080 snac2 HTTP port
OWNCAST_PORT 8080 Owncast HTTP port

What the Test Does

  1. Creates a temporary snac2 instance with test users
  2. Starts an HTTPS reverse proxy for TLS termination
  3. Starts Owncast configured for federation
  4. Has all snac2 users follow Owncast
  5. Sends a message from Owncast
  6. Verifies all followers received the message

Test Results

The test reports:

  • Followers Registered: Number of successful follow requests
  • Messages Delivered: Number of users who received the message
  • Delivery Time: Time to deliver to all followers
  • Follow Success Rate: Percentage of follow requests that succeeded
  • Delivery Rate: Percentage of registered followers who received the message

Troubleshooting

Certificate errors from snac2

Make sure you ran mkcert -install and generated the certificates. The CA must be in the system trust store for snac2 to trust the certificates.

Port already in use

Kill any leftover processes:

pkill -f "snac httpd /tmp"
pkill -f "caddy run"

Hosts file not configured

Verify the entries exist:

grep -E 'owncast.local|snac.local' /etc/hosts