40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
# retoor <retoor@molodetz.nl>
|
|||
|
|
|
||
|
|
import requests
|
||
|
|
|
||
|
|
from devplacepy.services.nodes.spec import SPEC
|
||
|
|
from tests.conftest import BASE_URL
|
||
|
|
|
||
|
|
|
||
|
|
def test_spec_json_is_public_and_matches_the_spec(app_server):
|
||
|
|
response = requests.get(f"{BASE_URL}/nodes/spec.json")
|
||
|
|
assert response.status_code == 200
|
||
|
|
assert response.headers["content-type"].startswith("application/json")
|
||
|
|
assert response.json() == SPEC.describe()
|
||
|
|
|
||
|
|
|
||
|
|
def test_spec_json_never_describes_an_open_proxy(app_server):
|
||
|
|
body = requests.get(f"{BASE_URL}/nodes/spec.json").json()
|
||
|
|
assert body["open_proxy"] is False
|
||
|
|
assert body["allowed_ports"] == [80, 443]
|
||
|
|
|
||
|
|
|
||
|
|
def test_protocol_docs_page_renders_every_spec_value(app_server):
|
||
|
|
response = requests.get(f"{BASE_URL}/docs/nodes-protocol.html")
|
||
|
|
assert response.status_code == 200
|
||
|
|
page = response.text
|
||
|
|
for frame in SPEC.frames:
|
||
|
|
assert f"<code>{frame.type}</code>" in page
|
||
|
|
for destination in SPEC.destinations:
|
||
|
|
assert destination.suffix in page
|
||
|
|
for refusal in SPEC.refusals:
|
||
|
|
assert refusal.code in page
|
||
|
|
for name in SPEC.limits.describe():
|
||
|
|
assert name in page
|
||
|
|
|
||
|
|
|
||
|
|
def test_nodes_api_docs_group_lists_the_spec_endpoint(app_server):
|
||
|
|
response = requests.get(f"{BASE_URL}/docs/nodes.html")
|
||
|
|
assert response.status_code == 200
|
||
|
|
assert "/nodes/spec.json" in response.text
|