15 KiB
15 KiB
ActivityPub tests for ForgeFlux/ftest
TODO
- Write code to upload to ftest server
- Package Docker container
- Upload to Docker Hub
Environment Variables
Please see .env_sample
NAME | Purpose | Example |
---|---|---|
FTEST_AUTH |
Authorization token for uploading test results to ftest server | a random-generated string that will be provided by ftest server |
FTEST_HOST |
The URL of the ftest's instance to which tests results should be uploaded | http://localhost:5000 , if an ftest implementation is running on localhost at port 5000 |
FTEST_TARGET_HOST |
The URL of the implementation's instance against which tests will be run | http://localhost:3000 , if Forgejo or any other ActivityPub implementation is running on localhost at port 3000 |
FTEST_USER |
address of the actor against which ActivityPub tests will be run | john@localhost:3000 . User john should exist on the instance |
Usage
cp .env_sample .env # edit and populate .env with the right values
source .env
python run.py
Docker
cp .env_sample .env # edit and populate .env with the right values
source .env
docker run \
-e FTEST_AUTH=$FTEST_AUTH \
-e FTEST_TARGET_HOST=$FTEST_TARGET_HOST \
-e FTEST_USER=$FTEST_USER forgeflux/webfinger-test
Demo
Successful run:
Please open to see logs
19:29 (venv) atm@lab activitypub ±|master ✗|→ make docker.run
docker run \
--network=ftest \
-e FTEST_AUTH=aACGJUaWKbUAynhz54762jYC0lcTtIei \
-e FTEST_HOST=http://localhost:9000 \
-e FTEST_TARGET_HOST=http://forgejo:7000 \
-e FTEST_USER=alice@forgejo:7000 forgeflux/ap-test
2023-10-01 13:59:50,866 - ap - INFO - Environment: FTEST_AUTH: aACGJUaWKbUAynhz54762jYC0lcTtIei
2023-10-01 13:59:50,866 - ap - INFO - Environment: FTEST_HOST: http://localhost:9000
2023-10-01 13:59:50,866 - ap - INFO - Environment: FTEST_USER: alice@forgejo:7000
2023-10-01 13:59:50,866 - ap - INFO - Environment: FTEST_TARGET_HOST: http://forgejo:7000
Feature: ActivityPub Object # features/object.feature:8
ActivityPub Object as defined in https://www.w3.org/TR/activitypub/#obj-id
Scenario: # features/object.feature:11
Given A Fediverse server # features/steps/obejct.py:12
2023-10-01 13:59:50,869 - ap - INFO - Query webfinger: http://forgejo:7000/.well-known/webfinger?resource=acct:alice@forgejo:7000
2023-10-01 13:59:50,872 - ap - DEBUG - webfinger response:
STATUS: 200
HEADERS:
{'Access-Control-Allow-Origin': '*', 'Cache-Control': 'max-age=0, private, must-revalidate, no-transform', 'Content-Type': 'application/json;charset=utf-8', 'Set-Cookie': 'i_like_gitea=6b18e16aba159c57; Path=/; HttpOnly; SameSite=Lax, _csrf=jvm3uaKAgUmAJqMuqqBeqdARdxY6MTY5NjE2ODc5MDg3MTIxNzc2Nw; Path=/; Max-Age=86400; HttpOnly; SameSite=Lax', 'X-Frame-Options': 'SAMEORIGIN', 'Date': 'Sun, 01 Oct 2023 13:59:50 GMT', 'Content-Length': '507'}
RESPONSE PAYLOAD:
{'subject': 'acct:alice@forgejo:7000', 'aliases': ['http://forgejo:7000/alice', 'http://forgejo:7000/api/v1/activitypub/user-id/3', 'mailto:alice@example.org'], 'links': [{'rel': 'http://webfinger.net/rel/profile-page', 'type': 'text/html', 'href': 'http://forgejo:7000/alice'}, {'rel': 'http://webfinger.net/rel/avatar', 'href': 'https://secure.gravatar.com/avatar/fbf7c6aec1d4280b7c2704c1c0478bd6?d=identicon'}, {'rel': 'self', 'type': 'application/activity+json', 'href': 'http://forgejo:7000/api/v1/activitypub/user-id/3'}]}
2023-10-01 13:59:50,872 - ap - INFO - [SUCCESS] webfinger query response is HTTP 200
2023-10-01 13:59:50,872 - ap - INFO - Actor URL http://forgejo:7000/api/v1/activitypub/user-id/3
When Receiving or querying an object # features/steps/obejct.py:28
2023-10-01 13:59:50,872 - ap - INFO - Getting object: http://forgejo:7000/api/v1/activitypub/user-id/3
2023-10-01 13:59:50,874 - ap - DEBUG - AP server response:
STATUS: 200
HEADERS:
{'Cache-Control': 'max-age=0, private, must-revalidate, no-transform', 'Content-Type': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Date': 'Sun, 01 Oct 2023 13:59:50 GMT', 'Content-Length': '1103'}
RESPONSE PAYLOAD:
{'@context': ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'], 'id': 'http://forgejo:7000/api/v1/activitypub/user-id/3', 'type': 'Person', 'icon': {'type': 'Image', 'mediaType': 'image/png', 'url': 'https://secure.gravatar.com/avatar/fbf7c6aec1d4280b7c2704c1c0478bd6?d=identicon'}, 'url': 'http://forgejo:7000/alice', 'inbox': 'http://forgejo:7000/api/v1/activitypub/user-id/3/inbox', 'outbox': 'http://forgejo:7000/api/v1/activitypub/user-id/3/outbox', 'preferredUsername': 'alice', 'publicKey': {'id': 'http://forgejo:7000/api/v1/activitypub/user-id/3#main-key', 'owner': 'http://forgejo:7000/api/v1/activitypub/user-id/3', 'publicKeyPem': '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArMXwd2H5QH1NQJ8FOhaO\nAn9xfchx6wcifO6yBkzt8YCemDXqc9VKpq6Uyz5tQT5S5r7MKF56Htibc1Fx2K6A\n7ra9S+PguY/V6ibWuv1i8J/78wcE1bpVxedl59NH8qbPD+025+7Wfsc2TYNJJsKI\n0AOoeZjc9ug2JGZ5WFk0aNSgZuYwMMb+wiyM+tGM5f2nGm2vhaNy9cxZLuwJW2sn\nC7tdvk5dnWShMzbuhmYoKAsJDlM7C+NNShi7WAX21cx92JULxT8mXYJmGa2Z1TQl\nhX4PSIwSkWOrDO8Y2D+LCkmFep8iZezPdDQAnioQanGY5jX7Y2rMfH7/xwm6RinZ\njQIDAQAB\n-----END PUBLIC KEY-----\n'}}
Then the response must contain an 'id' and a 'type' parameter # features/steps/obejct.py:35
And The 'id' must resolve to the same object # features/steps/obejct.py:42
2023-10-01 13:59:50,874 - ap - INFO - Getting object: http://forgejo:7000/api/v1/activitypub/user-id/3
2023-10-01 13:59:50,876 - ap - DEBUG - AP server response:
STATUS: 200
HEADERS:
{'Cache-Control': 'max-age=0, private, must-revalidate, no-transform', 'Content-Type': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Date': 'Sun, 01 Oct 2023 13:59:50 GMT', 'Content-Length': '1103'}
RESPONSE PAYLOAD:
{'@context': ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'], 'id': 'http://forgejo:7000/api/v1/activitypub/user-id/3', 'type': 'Person', 'icon': {'type': 'Image', 'mediaType': 'image/png', 'url': 'https://secure.gravatar.com/avatar/fbf7c6aec1d4280b7c2704c1c0478bd6?d=identicon'}, 'url': 'http://forgejo:7000/alice', 'inbox': 'http://forgejo:7000/api/v1/activitypub/user-id/3/inbox', 'outbox': 'http://forgejo:7000/api/v1/activitypub/user-id/3/outbox', 'preferredUsername': 'alice', 'publicKey': {'id': 'http://forgejo:7000/api/v1/activitypub/user-id/3#main-key', 'owner': 'http://forgejo:7000/api/v1/activitypub/user-id/3', 'publicKeyPem': '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArMXwd2H5QH1NQJ8FOhaO\nAn9xfchx6wcifO6yBkzt8YCemDXqc9VKpq6Uyz5tQT5S5r7MKF56Htibc1Fx2K6A\n7ra9S+PguY/V6ibWuv1i8J/78wcE1bpVxedl59NH8qbPD+025+7Wfsc2TYNJJsKI\n0AOoeZjc9ug2JGZ5WFk0aNSgZuYwMMb+wiyM+tGM5f2nGm2vhaNy9cxZLuwJW2sn\nC7tdvk5dnWShMzbuhmYoKAsJDlM7C+NNShi7WAX21cx92JULxT8mXYJmGa2Z1TQl\nhX4PSIwSkWOrDO8Y2D+LCkmFep8iZezPdDQAnioQanGY5jX7Y2rMfH7/xwm6RinZ\njQIDAQAB\n-----END PUBLIC KEY-----\n'}}
And context must be ActivityPub # features/steps/obejct.py:48
1 feature passed, 0 failed, 0 skipped
1 scenario passed, 0 failed, 0 skipped
5 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m0.007s
Failed run:
Please open to see logs
19:48 (venv) atm@lab activitypub ±|master ✗|→ behave
2023-10-01 19:49:39,187 - ap - INFO - Environment: FTEST_AUTH: foobar
2023-10-01 19:49:39,187 - ap - INFO - Environment: FTEST_HOST: http://localhost:9000
2023-10-01 19:49:39,187 - ap - INFO - Environment: FTEST_USER: realaravinth@batsense.net
2023-10-01 19:49:39,187 - ap - INFO - Environment: FTEST_TARGET_HOST: https://gts.batsense.net
Feature: ActivityPub Object # features/object.feature:8
ActivityPub Object as defined in https://www.w3.org/TR/activitypub/#obj-id
Scenario: # features/object.feature:11
Given A Fediverse server # features/steps/object.py:12
2023-10-01 19:49:39,190 - ap - INFO - Query webfinger: https://gts.batsense.net/.well-known/webfinger?resource=acct:realaravinth@batsense.net
2023-10-01 19:49:39,265 - ap - DEBUG - webfinger response:
STATUS: 200
HEADERS:
{'Server': 'nginx/1.18.0', 'Date': 'Sun, 01 Oct 2023 14:19:39 GMT', 'Content-Type': 'application/jrd+json', 'Content-Length': '197', 'Connection': 'keep-alive', 'Cache-Control': 'public, max-age=120', 'Content-Encoding': 'gzip', 'Content-Security-Policy': "default-src 'self'; object-src 'none'; img-src 'self' blob:; media-src 'self'", 'Permissions-Policy': 'browsing-topics=(), interest-cohort=()', 'Vary': 'Accept-Encoding', 'X-Ratelimit-Limit': '300', 'X-Ratelimit-Remaining': '289', 'X-Ratelimit-Reset': '1696170087', 'X-Request-Id': 'd3psqtwa04001t6ca510'}
RESPONSE PAYLOAD:
{'subject': 'acct:realaravinth@batsense.net', 'aliases': ['https://gts.batsense.net/users/realaravinth', 'https://gts.batsense.net/@realaravinth'], 'links': [{'rel': 'http://webfinger.net/rel/profile-page', 'type': 'text/html', 'href': 'https://gts.batsense.net/@realaravinth'}, {'rel': 'self', 'type': 'application/activity+json', 'href': 'https://gts.batsense.net/users/realaravinth'}]}
2023-10-01 19:49:39,266 - ap - INFO - [SUCCESS] webfinger query response is HTTP 200
Given A Fediverse server # features/steps/object.py:12 0.077s
When Receiving or querying an object # features/steps/object.py:27
2023-10-01 19:49:39,267 - ap - INFO - Getting object: https://gts.batsense.net/users/realaravinth
2023-10-01 19:49:39,505 - ap - DEBUG - AP server response:
STATUS: 401
HEADERS:
{'Server': 'nginx/1.18.0', 'Date': 'Sun, 01 Oct 2023 14:19:39 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '104', 'Connection': 'keep-alive', 'Cache-Control': 'no-store', 'Content-Encoding': 'gzip', 'Content-Security-Policy': "default-src 'self'; object-src 'none'; img-src 'self' blob:; media-src 'self'", 'Permissions-Policy': 'browsing-topics=()', 'Vary': 'Accept-Encoding', 'X-Ratelimit-Limit': '300', 'X-Ratelimit-Remaining': '288', 'X-Ratelimit-Reset': '1696170087', 'X-Request-Id': 'bbq9qtwa040015ce6dk0'}
RESPONSE PAYLOAD:
{"error":"Unauthorized: http request wasn't signed or http signature was invalid: (verifier)"}
2023-10-01 19:49:39,505 - ap - ERROR - Request FAILURE. AP server response:
STATUS: 401
HEADERS:
{'Server': 'nginx/1.18.0', 'Date': 'Sun, 01 Oct 2023 14:19:39 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '104', 'Connection': 'keep-alive', 'Cache-Control': 'no-store', 'Content-Encoding': 'gzip', 'Content-Security-Policy': "default-src 'self'; object-src 'none'; img-src 'self' blob:; media-src 'self'", 'Permissions-Policy': 'browsing-topics=()', 'Vary': 'Accept-Encoding', 'X-Ratelimit-Limit': '300', 'X-Ratelimit-Remaining': '288', 'X-Ratelimit-Reset': '1696170087', 'X-Request-Id': 'bbq9qtwa040015ce6dk0'}
RESPONSE PAYLOAD:
When Receiving or querying an object # features/steps/object.py:27 0.238s
Assertion Failed: Request FAILURE. AP server response:
STATUS: 401
HEADERS:
{'Server': 'nginx/1.18.0', 'Date': 'Sun, 01 Oct 2023 14:19:39 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '104', 'Connection': 'keep-alive', 'Cache-Control': 'no-store', 'Content-Encoding': 'gzip', 'Content-Security-Policy': "default-src 'self'; object-src 'none'; img-src 'self' blob:; media-src 'self'", 'Permissions-Policy': 'browsing-topics=()', 'Vary': 'Accept-Encoding', 'X-Ratelimit-Limit': '300', 'X-Ratelimit-Remaining': '288', 'X-Ratelimit-Reset': '1696170087', 'X-Request-Id': 'bbq9qtwa040015ce6dk0'}
RESPONSE PAYLOAD:
{"error":"Unauthorized: http request wasn't signed or http signature was invalid: (verifier)"}
Captured logging:
INFO:ap:Query webfinger: https://gts.batsense.net/.well-known/webfinger?resource=acct:realaravinth@batsense.net
INFO:ap:[SUCCESS] webfinger query response is HTTP 200
INFO:ap:Actor URL https://gts.batsense.net/users/realaravinth
INFO:ap:Getting object: https://gts.batsense.net/users/realaravinth
ERROR:ap:Request FAILURE. AP server response:
STATUS: 401
HEADERS:
{'Server': 'nginx/1.18.0', 'Date': 'Sun, 01 Oct 2023 14:19:39 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '104', 'Connection': 'keep-alive', 'Cache-Control': 'no-store', 'Content-Encoding': 'gzip', 'Content-Security-Policy': "default-src 'self'; object-src 'none'; img-src 'self' blob:; media-src 'self'", 'Permissions-Policy': 'browsing-topics=()', 'Vary': 'Accept-Encoding', 'X-Ratelimit-Limit': '300', 'X-Ratelimit-Remaining': '288', 'X-Ratelimit-Reset': '1696170087', 'X-Request-Id': 'bbq9qtwa040015ce6dk0'}
RESPONSE PAYLOAD:
{"error":"Unauthorized: http request wasn't signed or http signature was invalid: (verifier)"}
Then the response must contain an 'id' and a 'type' parameter # None
And The 'id' must resolve to the same object # None
And context must be ActivityPub # None
===============
Summary:
Failed tests:
[FAIL] check_actor_exists failed with error:
Request FAILURE. AP server response:
STATUS: 401
HEADERS:
{'Server': 'nginx/1.18.0', 'Date': 'Sun, 01 Oct 2023 14:19:39 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '104', 'Connection': 'keep-alive', 'Cache-Control': 'no-store', 'Content-Encoding': 'gzip', 'Content-Security-Policy': "default-src 'self'; object-src 'none'; img-src 'self' blob:; media-src 'self'", 'Permissions-Policy': 'browsing-topics=()', 'Vary': 'Accept-Encoding', 'X-Ratelimit-Limit': '300', 'X-Ratelimit-Remaining': '288', 'X-Ratelimit-Reset': '1696170087', 'X-Request-Id': 'bbq9qtwa040015ce6dk0'}
RESPONSE PAYLOAD:
{"error":"Unauthorized: http request wasn't signed or http signature was invalid: (verifier)"}
-----
Failing scenarios:
features/object.feature:11
0 features passed, 1 failed, 0 skipped
0 scenarios passed, 1 failed, 0 skipped
1 step passed, 1 failed, 3 skipped, 0 undefined
Took 0m0.315s