12 KiB
ActivityPub Testing - Complete Guide
This is the complete guide for testing ActivityPub federation in Solar Network.
📁 File Overview
| File | Purpose | When to Use |
|---|---|---|
setup-activitypub-test.sh |
One-command setup of test environment | First time setup |
test-activitypub.sh |
Quick validation of basic functionality | After setup, before detailed tests |
ACTIVITYPUB_TESTING_QUICKSTART.md |
Quick start reference | Getting started quickly |
ACTIVITYPUB_TESTING_GUIDE.md |
Comprehensive testing scenarios | Full testing workflow |
ACTIVITYPUB_TESTING_QUICKREF.md |
Command and query reference | Daily testing |
ACTIVITYPUB_TESTING_HELPER_API.md |
Helper API for testing | Programmatic testing |
ACTIVITYPUB_TEST_RESULTS_TEMPLATE.md |
Track test results | During testing |
ACTIVITYPUB_IMPLEMENTATION.md |
Implementation details | Understanding the code |
ACTIVITYPUB_SUMMARY.md |
Feature summary | Reviewing what's implemented |
🚀 Quick Start (5 Minutes)
1. Setup Test Environment
./setup-activitypub-test.sh
This will:
- ✅ Configure
/etc/hosts - ✅ Start Mastodon via Docker
- ✅ Create test Mastodon account
- ✅ Apply database migrations
2. Validate Setup
./test-activitypub.sh
This checks:
- ✅ WebFinger endpoint
- ✅ Actor profile
- ✅ Public keys
- ✅ Database tables
3. Start Solar Network
cd DysonNetwork.Sphere
dotnet run
4. Test Federation
- Open http://mastodon.local:3001
- Search for
@solaruser@solar.local - Click Follow
- Create a post in Solar Network
- Verify it appears in Mastodon
📖 Recommended Reading Order
For First-Time Testing
-
Start Here:
ACTIVITYPUB_TESTING_QUICKSTART.md- Overview of the setup
- Quick command reference
- Common commands
-
Then:
ACTIVITYPUB_TESTING_GUIDE.md- Detailed test scenarios
- Step-by-step instructions
- Troubleshooting
-
Reference:
ACTIVITYPUB_TESTING_QUICKREF.md- Command snippets
- Database queries
- Response codes
During Testing
-
Track Progress:
ACTIVITYPUB_TEST_RESULTS_TEMPLATE.md- Checklists for each test
- Results tracking
- Issue logging
-
Helper API:
ACTIVITYPUB_TESTING_HELPER_API.md- Manual testing endpoints
- Debugging tools
- Status monitoring
For Understanding
-
Implementation:
ACTIVITYPUB_IMPLEMENTATION.md- Architecture details
- Service descriptions
- Data flow diagrams
-
Features:
ACTIVITYPUB_SUMMARY.md- What's implemented
- Model relationships
- API endpoints
🔍 Test Scenarios Summary
Basic Functionality (All instances must pass)
- WebFinger discovery works
- Actor profile is valid JSON-LD
- Public key is present
- Outbox returns public posts
- Inbox accepts activities
Federation - Follow
- Remote user can follow local user
- Local user can follow remote user
- Accept activity is sent/received
- Relationship state is correct
- Unfollow works correctly
Federation - Content
- Local posts federate to remote instances
- Remote posts appear in local database
- Post content is preserved
- Timestamps are correct
- Attachments are handled
- Content warnings are respected
Federation - Interactions
- Likes federate correctly
- Likes appear in both instances
- Replies federate correctly
- Reply threading works
- Boosts/Announces work
- Undo activities work
Security
- HTTP signatures are verified
- Invalid signatures are rejected
- Keys are properly stored
- Private keys never exposed
🐛 Common Issues & Solutions
Issue: "Failed to verify signature"
Causes:
- Signature header format is wrong
- Public key doesn't match keyId
- Date header is too old (>5 minutes)
- Request body doesn't match digest
Solutions:
- Check signature format:
keyId="...",algorithm="...",headers="...",signature="..." - Verify keyId in actor profile
- Ensure Date header is recent
- Check body is exactly what was signed
Issue: "Target actor or inbox not found"
Causes:
- Actor hasn't been fetched yet
- Actor URL is incorrect
- Remote instance is inaccessible
Solutions:
- Manually fetch actor first
- Verify actor URL is correct
- Test accessibility with curl
Issue: Activities not arriving
Causes:
- Network connectivity issue
- Remote instance is down
- Activity wasn't queued properly
Solutions:
- Check network connectivity
- Verify remote instance is running
- Check fediverse_activities table for status
📊 Monitoring During Tests
Check Logs
# Solar Network ActivityPub logs
dotnet run --project DysonNetwork.Sphere 2>&1 | grep -i activitypub
# Mastodon federation logs
docker compose -f docker-compose.mastodon-test.yml logs -f web | grep -i federation
Monitor Database
# Watch activity table
watch -n 2 'psql -d dyson_network -c \
"SELECT type, status, created_at FROM fediverse_activities ORDER BY created_at DESC LIMIT 5;"'
Test Network
# Test connectivity between instances
curl -v http://mastodon.local:3001
curl -v http://solar.local:5000
# Test with traceroute (if available)
traceroute mastodon.local
traceroute solar.local
🎯 Success Criteria
Minimal Viable Federation
To consider ActivityPub implementation "working", all of these must pass:
- ✅ WebFinger returns actor links
- ✅ Actor profile has all required fields
- ✅ Follow relationships work bidirectionally
- ✅ Public posts federate to followers
- ✅ Incoming posts are stored correctly
- ✅ HTTP signatures are verified
- ✅ Basic interaction types work (Like, Reply)
Full Production Ready
For production, also need:
- ✅ Activity queue with retry logic
- ✅ Rate limiting on outgoing deliveries
- ✅ Monitoring and alerting
- ✅ Admin interface for federation management
- ✅ Content filtering and moderation
- ✅ Instance blocking capabilities
- ✅ Performance optimization for high volume
🔐 Security Checklist
During testing, verify:
- Private keys are never logged
- Private keys are never returned in API responses
- Only public keys are in actor profiles
- All incoming activities are signature-verified
- Invalid signatures are rejected with 401
- TLS is used in production
- Host header is verified against request URL
📈 Performance Metrics
Track these during testing:
| Metric | Target | Actual |
|---|---|---|
| WebFinger response time | <500ms | ___ ms |
| Actor fetch time | <1s | ___ ms |
| Signature verification time | <100ms | ___ ms |
| Activity processing time | <500ms | ___ ms |
| Outgoing delivery success rate | >95% | ___% |
| Outgoing delivery time | <5s | ___ ms |
🧪 Testing Checklist
Self-Hosted Instance Tests
Setup:
- Setup script completed
- Mast containers running
- Solar Network running
- /etc/hosts configured
- Database migrations applied
Basic Federation:
- WebFinger works
- Actor profile valid
- Public key present
- Outbox accessible
Follow Flow:
- Mastodon → Solar follow works
- Solar → Mastodon follow works
- Accept activity sent
- Relationship state correct
Content Flow:
- Solar posts appear in Mastodon
- Mastodon posts appear in Solar
- Content preserved correctly
- Timestamps correct
Interactions:
- Likes work both ways
- Replies work both ways
- Boosts work both ways
- Undo works
Security:
- HTTP signatures verified
- Invalid signatures rejected
- Keys properly managed
Real Instance Tests
Discovery:
- Domain publicly accessible
- WebFinger works from public internet
- Actor discoverable from public instances
Federation:
- Posts federate to public instances
- Follows work with public instances
- Interactions work with public instances
📝 Testing Notes
What Worked Well
What Needs Improvement
Bugs Found
| # | Description | Severity | Status |
|---|---|---|---|
| 1 | _____________________ | Low/Medium/High | ☐ Open/☐ Fixed |
| 2 | _____________________ | Low/Medium/High | ☐ Open/☐ Fixed |
| 3 | _____________________ | Low/Medium/High | ☐ Open/☐ Fixed |
🎓 Learning Resources
ActivityPub Specification
Implementation Guides
Tools
🔄 Next Steps After Testing
Phase 1: Fix Issues
- Address all bugs found during testing
- Improve error messages
- Add better logging
Phase 2: Enhance Features
- Implement activity queue
- Add retry logic
- Add rate limiting
- Implement instance blocking
Phase 3: Production Readiness
- Add monitoring and metrics
- Add admin interface
- Add content filtering
- Implement moderation tools
Phase 4: Additional Features
- Support more activity types
- Support media attachments
- Support polls
- Support custom emojis
📞 Getting Help
If you encounter issues:
- Check logs: See the logs section above
- Review troubleshooting: See
ACTIVITYPUB_TESTING_GUIDE.mdPart 5 - Check database queries: Use queries from
ACTIVITYPUB_TESTING_QUICKREF.md - Validate signatures: Use helper API in
ACTIVITYPUB_TESTING_HELPER_API.md
✨ Quick Test Commands
All-in-One Test Sequence
# 1. Setup
./setup-activitypub-test.sh
# 2. Validate
./test-activitypub.sh
# 3. Test WebFinger
curl "http://solar.local:5000/.well-known/webfinger?resource=acct:solaruser@solar.local"
# 4. Test Actor
curl -H "Accept: application/activity+json" \
http://solar.local:5000/activitypub/actors/solaruser
# 5. Test Follow (from Mastodon UI)
# Open http://mastodon.local:3001 and follow @solaruser@solar.local
# 6. Check database
psql -d dyson_network -c "SELECT * FROM fediverse_relationships;"
# 7. Test Post (create in Solar Network UI)
# Should appear in http://mastodon.local:3001
# 8. Verify content
psql -d dyson_network -c "SELECT * FROM fediverse_contents;"
# 9. Test Like (like from Mastodon UI)
# Should appear in fediverse_reactions table
# 10. Check activities
psql -d dyson_network -c "SELECT type, status FROM fediverse_activities;"
🎉 Conclusion
You now have everything needed to test ActivityPub federation for Solar Network:
- ✅ Self-hosted test environment (Mastodon)
- ✅ Setup automation (setup script)
- ✅ Quick validation (test script)
- ✅ Comprehensive testing guide
- ✅ Helper API for programmatic testing
- ✅ Quick reference for daily use
- ✅ Results template for tracking progress
Recommended workflow:
- Run
setup-activitypub-test.sh - Run
test-activitypub.shfor validation - Follow scenarios in
ACTIVITYPUB_TESTING_GUIDE.md - Use
ACTIVITYPUB_TESTING_HELPER_API.mdfor specific tests - Track results in
ACTIVITYPUB_TEST_RESULTS_TEMPLATE.md - Reference
ACTIVITYPUB_TESTING_QUICKREF.mdfor commands
Good luck with your federation testing! 🚀