134 lines
7.1 KiB
Markdown
134 lines
7.1 KiB
Markdown
|
[![status-badge](https://ci.batsense.net/host-metai/badges/93/status.svg)](https://ci.batsense.net/repos/93)
|
||
|
[![status-badge](https://ci.batsense.net/host-metai/badges/90/status.svg)](https://ci.batsense.net/repos/90)
|
||
|
|
||
|
---
|
||
|
|
||
|
# [Host Meta](https://www.rfc-editor.org/rfc/rfc6415.html) 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`](./.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
|
||
|
|
||
|
```bash
|
||
|
cp .env_sample .env # edit and populate .env with the right values
|
||
|
source .env
|
||
|
python run.py
|
||
|
```
|
||
|
|
||
|
### Docker
|
||
|
|
||
|
```bash
|
||
|
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_HOST=$FTEST_HOST \
|
||
|
-e FTEST_USER=$FTEST_USER forgeflux/host-meta-test
|
||
|
```
|
||
|
|
||
|
## Demo
|
||
|
|
||
|
### Successful run:
|
||
|
|
||
|
<details>
|
||
|
|
||
|
<summary>Please open to see logs</summary>
|
||
|
|
||
|
```bash
|
||
|
17:22 (venv) atm@lab host-meta ±|master ✗|→ behave
|
||
|
2023-10-02 17:22:23,120 - ap - INFO - Environment: FTEST_AUTH: foobar
|
||
|
2023-10-02 17:22:23,120 - ap - INFO - Environment: FTEST_HOST: http://localhost:9000
|
||
|
2023-10-02 17:22:23,120 - ap - INFO - Environment: FTEST_USER: realaravinth@batsense.net
|
||
|
2023-10-02 17:22:23,120 - ap - INFO - Environment: FTEST_TARGET_HOST: https://gts.batsense.net
|
||
|
Feature: Host Meta # features/host_meta.feature:1
|
||
|
As defined in https://www.rfc-editor.org/rfc/rfc6415.html
|
||
|
Scenario: # features/host_meta.feature:4
|
||
|
Given A Fediverse server # features/steps/host_meta.py:43 0.000s
|
||
|
When Querying /.well-known/host-meta # features/steps/host_meta.py:48
|
||
|
2023-10-02 17:22:23,134 - ap - DEBUG - host-meta response:
|
||
|
|
||
|
STATUS: 404
|
||
|
|
||
|
HEADERS:
|
||
|
{'Server': 'nginx/1.18.0', 'Date': 'Mon, 02 Oct 2023 11:52:23 GMT', 'Content-Type': 'text/html', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip'}
|
||
|
|
||
|
RESPONSE PAYLOAD:
|
||
|
b'<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.18.0</center>\r\n</body>\r\n</html>\r\n'
|
||
|
2023-10-02 17:22:23,167 - ap - DEBUG - host-meta response:
|
||
|
|
||
|
STATUS: 200
|
||
|
|
||
|
HEADERS:
|
||
|
{'Server': 'nginx/1.18.0', 'Date': 'Mon, 02 Oct 2023 11:52:23 GMT', 'Content-Type': 'application/xrd+xml', 'Content-Length': '206', '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': '296', 'X-Ratelimit-Reset': '1696247748', 'X-Request-Id': 'fhtkqw4a04000cj8v2a0'}
|
||
|
|
||
|
RESPONSE PAYLOAD:
|
||
|
b'<?xml version="1.0" encoding="UTF-8"?>\n<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd When Querying /.well-known/host-meta # features/steps/host_meta.py:48 0.045s
|
||
|
Then The page must resolve at port 80 or 443 # features/steps/host_meta.py:68
|
||
|
2023-10-02 17:22:23,178 - ap - DEBUG - host-meta response:
|
||
|
|
||
|
STATUS: 404
|
||
|
|
||
|
HEADERS:
|
||
|
{'Server': 'nginx/1.18.0', 'Date': 'Mon, 02 Oct 2023 11:52:23 GMT', 'Content-Type': 'text/html', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip'}
|
||
|
|
||
|
RESPONSE PAYLOAD:
|
||
|
b'<html>\r\n<head><title>404 Not Found</title></head>\r\n<body>\r\n<center><h1>404 Not Foun Then The page must resolve at port 80 or 443 # features/steps/host_meta.py:68 0.011se}
|
||
|
And If both port 80 _and_ 443 work, then they SHOULD return same document # features/steps/host_meta.py:91 0.000s
|
||
|
And The document SHOULD be served with "application/xrd+xml" media type # features/steps/host_meta.py:99 0.000s
|
||
|
And The host-meta document root MUST be an "XRD" element # features/steps/host_meta.py:120 0.000s
|
||
|
And The document SHOULD NOT include a "Subject" element # features/steps/host_meta.py:133 0.000s
|
||
|
And The document SHOULD include "Link" element # features/steps/host_meta.py:147 0.000s
|
||
|
And The document's "Link" element should include either "template" or "href" attributes # features/steps/host_meta.py:161 0.000s
|
||
|
And The document should have at least on 'lrdd' document # features/steps/host_meta.py:187 0.000s
|
||
|
And Fediverse specific: The lrdd document must include template containing WebFinger well-known URI # features/steps/host_meta.py:214 0.000s
|
||
|
|
||
|
|
||
|
|
||
|
===============
|
||
|
Partial success. 8 out of 9 tests passed
|
||
|
Summary:
|
||
|
|
||
|
Successful tests:
|
||
|
|
||
|
[OK] Page must resolve at port 80
|
||
|
|
||
|
[OK] The document SHOULD be served with "application/xrd+xml" media type
|
||
|
|
||
|
[OK] The host-meta document root MUST be an "XRD" element
|
||
|
|
||
|
[OK] The document SHOULD NOT include a "Subject" element
|
||
|
|
||
|
[OK] The document SHOULD include "Link" element
|
||
|
|
||
|
[OK] The document's "Link" element should include either "template" or "href" attributes
|
||
|
|
||
|
[OK] The document should have at least on 'lrdd' document
|
||
|
|
||
|
[OK] Fediverse specific: The lrdd document must include template containing WebFinger well-known URI
|
||
|
|
||
|
2023-10-02 17:22:23,181 - ap - INFO - Uploading logs to ftest server http://localhost:9000/api/v1/foobar/results
|
||
|
<Response [401]>
|
||
|
1 feature passed, 0 failed, 0 skipped
|
||
|
1 scenario passed, 0 failed, 0 skipped
|
||
|
11 steps passed, 0 failed, 0 skipped, 0 undefined
|
||
|
Took 0m0.056s
|
||
|
```
|
||
|
|
||
|
</details>
|