@socialweb.coop/activitypub-testing
v0.7.0
Published
tools for testing implementations of [ActivityPub][ActivityPub], a decentralized social networking protocol.
Downloads
19
Readme
@socialweb.coop/activitypub-testing
tools for testing implementations of [ActivityPub][ActivityPub], a decentralized social networking protocol.
How to use the activitypub-testing
CLI
If you have npm
installed, You may be able to use the activitypub-testing cli without downloading this source code.
ad-hoc usage using npx
For ad-hoc usage, try:
⚡ npx @socialweb.coop/activitypub-testing help
activitypub-testing
What?
activitypub-testing is a cli for testing implementations of ActivityPub[0]
Usage:
# browse all the tests
activitypub-testing get tests [--output=<mediaType>]
# inspect a single test
activitypub-testing get test --uuid=<uuid> [--output=<mediaType>]
# run a test
activitypub-testing run test (--uuid=<uuid> | --slug=<slug>) --inputs.anyInputName=<inputs.anyInputName>
activitypub-testing [--help] [-h] [help]
Options:
-h --help Show this help text.
-o --output Choose output media type (default `text`, also allows `json`, `yaml`)
Examples:
# runs test inbox-must-be-an-orderedcollection[1] against a valid actor fetched via https
activitypub-testing \
test \
--uuid '5e94d155-ed4a-4d71-b797-d7c387736ecf' \
--inputs.object="$(curl -s 'https://socialweb.coop/activitypub/actors/with-empty-inbox.json')"
[0]: https://en.wikipedia.org/wiki/ActivityPub
[1]: https://socialweb.coop/activitypub/test-cases/inbox-must-be-an-orderedcollection/
run test
by slug
⚡ npx @socialweb.coop/activitypub-testing run test --slug actor-must-serve-as2-object-to-get --inputs.time="T1M" --inputs.id="https://bengo.is/actor.json"
{
"type": "Assertion",
"test": {
"id": "urn:uuid:e7ee491d-88d7-4e67-80c8-f74781bb247c",
"uuid": "e7ee491d-88d7-4e67-80c8-f74781bb247c",
"url": "https://socialweb.coop/activitypub/test-cases/actor-must-serve-as2-object-to-get/",
"slug": "actor-must-serve-as2-object-to-get"
},
"result": {
"outcome": "passed"
},
"@context": [
"https://socialweb.coop/ns/testing/context.json"
]
}
or
run test
by uuid
⚡ npx @socialweb.coop/activitypub-testing run test --uuid 'e7ee491d-88d7-4e67-80c8-f74781bb247c' --inputs.time="T1M" --inputs.id="https://bengo.is/404"
{
"type": "Assertion",
"test": {
"id": "urn:uuid:e7ee491d-88d7-4e67-80c8-f74781bb247c",
"uuid": "e7ee491d-88d7-4e67-80c8-f74781bb247c",
"url": "https://socialweb.coop/activitypub/test-cases/actor-must-serve-as2-object-to-get/",
"slug": "actor-must-serve-as2-object-to-get"
},
"result": {
"outcome": "failed",
"info": "unable to parse response body as JSON",
"pointer": {
"response": {
"body": "<html>\r\n<head><title>404 Not Found</title></head>\r\n<body>\r\n<center><h1>404 Not Found</h1></center>\r\n<hr><center>nginx/1.25.2</center>\r\n</body>\r\n</html>\r\n",
"statusCodeValue": "404",
"headers": []
}
}
},
"@context": [
"https://socialweb.coop/ns/testing/context.json"
]
}
install globally using npm
Or to install an activitypub-testing
command globally for repeat usage, run:
npm install -g @socialweb.coop/activitypub-testing
npm install -g
should have installed activitypub-testing
to your shell PATH
.
The following should work in your command prompt
activitypub-testing --help
Developing this Repository
Developing tests
See ./src/tests/ for the source code.
Each ActivityPub test case should be in a folder in that directory named after the test slug, e.g. ./tests/actor-must-serve-as2-object-to-get
Developing the activitypub-testing
CLI
See ./src/cli.js for the source code.
You should be able to run the cli.js
script like
⚡ ./src/cli.js --uuid=test-uuid
no test found with uuid of test-uuid
npm scripts
These are in ./package.json and each has a name. Run like pnpm run <name>
build
- build the source code into./dist
lint
- check source code against lint rulesactivitypub-testing
- run theactivitypub-testing
CLI