mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-12 20:15:10 +00:00
/api/health needs X-Secret-Key but stays outside the rate limit. Only the admin key gets load_errors from /api/services, default error details no longer name the exception class, and a prepare signal replaces aiohttp's Server banner on every response while the CDM routes keep their own.
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""E2E: basic reachability against a running `unshackle serve`."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
pytestmark = [pytest.mark.live]
|
|
|
|
|
|
def test_health_endpoint(http_session, server_url: str) -> None:
|
|
r = http_session.get(f"{server_url}/api/health", timeout=10)
|
|
assert r.status_code == 200, r.text
|
|
body = r.json()
|
|
assert body["status"] == "ok"
|
|
assert "version" in body
|
|
assert "update_check" in body
|
|
|
|
|
|
def test_services_endpoint(http_session, server_url: str) -> None:
|
|
r = http_session.get(f"{server_url}/api/services", timeout=10)
|
|
assert r.status_code == 200, r.text
|
|
body = r.json()
|
|
assert "services" in body
|
|
assert isinstance(body["services"], list)
|
|
|
|
|
|
def test_health_requires_secret_key(server_url: str, secret_key: str) -> None:
|
|
"""Health needs the API key like every other route."""
|
|
import requests
|
|
|
|
r = requests.get(f"{server_url}/api/health", timeout=10)
|
|
assert r.status_code == (401 if secret_key else 200)
|
|
|
|
|
|
def test_unknown_route_returns_404(http_session, server_url: str) -> None:
|
|
r = http_session.get(f"{server_url}/api/this-does-not-exist", timeout=10)
|
|
assert r.status_code in (404, 405)
|