activitypub-testing can run tests for Fediverse Enhancement Proposals. Let's use FEP-9091 as an example:
FEP-9091: Export Actor Service Endpoint is a FEP Specification.
There is a FEP Test Implementation FEP-9091 in JavaScript and published activitypub-testing-fep-9091. The repo also makes the test's JavaScript file available over HTTP.
activitypub-testing run test --url <fep-url> performs Test Runs for the FEP-9091 Test Implementation.
To run a custom test module, use activitypub-testing run test with the --url flag set to the URL of the module.
activitypub-testing will fetch the URL, load the test, and then apply the test to the input built from the other CLI flags.
activitypub-testing run test \
--url=https://codeberg.org/socialweb.coop/activitypub-testing-fep-9091/raw/branch/main/fep-9091-actor-must-have-valid-export-service-endpoint.js \
--input.actor="$(cat <<EOF
{
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://www.w3.org/ns/did/v1"
],
"id": "https://alice-personal-site.example/actor",
"type": "Person",
"name": "Alice",
"service": [{
"id": "https://alice-personal-site.example/actor#export",
"type": "https://w3id.org/fep/9091#Export",
"serviceEndpoint": "https://alice-personal-site.example/actor/accountExport"
}]
}
EOF
)"
{
"type": [
"Assertion"
],
"result": {
"outcome": "passed"
},
"test": {
"slug": "fep-9091-actor-must-have-valid-export-service-endpoint",
"name": "Actor must have a valid export service endpoint",
"id": "urn:uuid:94113b63-3de7-4924-8fcb-90b61133d3aa",
"requirementReference": []
},
"input": {
"actor": "{\n \"@context\": [\n \"https://www.w3.org/ns/activitystreams\",\n \"https://www.w3.org/ns/did/v1\"\n ],\n \"id\": \"https://alice-personal-site.example/actor\",\n \"type\": \"Person\",\n \"name\": \"Alice\",\n \"service\": [{\n \"id\": \"https://alice-personal-site.example/actor#export\",\n \"type\": \"https://w3id.org/fep/9091#Export\",\n \"serviceEndpoint\": \"https://alice-personal-site.example/actor/accountExport\"\n }]\n}"
},
"@context": [
"https://socialweb.coop/ns/testing/context.json",
"https://www.w3.org/ns/activitystreams"
]
}
Use activitypub-testing run test with the --url flag set to the URL to the custom test module. activitypub-testing will fetch the URL, load the test, and then apply the test to the input built from the other CLI flags. The test accepts an --input.module argument that expects an ECMAScript Module. We can use curl in a shell command substitution to get the URL as JavaScript and substitute that value as --input.module.
fetchAsObject() {
curl --silent -H 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"' "$1"
}
testFep9091ActorUrl() {
activitypub-testing run test \
--url=https://codeberg.org/socialweb.coop/activitypub-testing-fep-9091/raw/branch/main/fep-9091-actor-must-have-valid-export-service-endpoint.js \
--input.actor="$(fetchAsObject "$1")"
}
testFep9091ActorUrl https://socialweb.coop