Archived
Simplify setup flow and public API docs
This commit is contained in:
1 parent
2e401124e8
commit
97a76aa91e
12 files changed
+119
-140
No files matched your search
+14
-8
@@ -35,8 +35,9 @@ def test_custom_api_docs_include_only_current_api_surfaces(tmp_path: Path) -> No
|
||||
assert "GET /api/v1/hostnames/<secret>" in docs.text
|
||||
assert "POST /api/v1/hostnames/<secret>/rotate-update-url" in docs.text
|
||||
assert "Rotate update URL" in docs.text
|
||||
assert "GET /api/v1/admin/dashboard" in docs.text
|
||||
assert "GET /api/v1/admin/events" in docs.text
|
||||
assert "Operator API" not in docs.text
|
||||
assert "/api/v1/admin" not in docs.text
|
||||
assert "admin:<admin-password>" not in docs.text
|
||||
assert "https://karldns.de/api/v1/hostnames" in docs.text
|
||||
assert "http://localhost:8080/api/v1/hostnames" not in docs.text
|
||||
assert "registration_url" in docs.text
|
||||
@@ -52,10 +53,6 @@ def test_custom_api_docs_include_only_current_api_surfaces(tmp_path: Path) -> No
|
||||
assert "fonts.googleapis.com" not in docs.headers["content-security-policy"]
|
||||
|
||||
expected_paths = {
|
||||
"/api/v1/admin/dashboard",
|
||||
"/api/v1/admin/events",
|
||||
"/api/v1/admin/hostnames",
|
||||
"/api/v1/admin/records",
|
||||
"/api/v1/hostnames",
|
||||
"/api/v1/hostnames/{dashboard_secret}",
|
||||
"/api/v1/hostnames/{dashboard_secret}/rotate-update-url",
|
||||
@@ -70,7 +67,12 @@ def test_custom_api_docs_include_only_current_api_surfaces(tmp_path: Path) -> No
|
||||
assert "/events" not in schema["paths"]
|
||||
assert any(tag["name"] == "hostnames" for tag in schema["tags"])
|
||||
assert any(tag["name"] == "router" for tag in schema["tags"])
|
||||
assert any(tag["name"] == "admin" for tag in schema["tags"])
|
||||
assert all(tag["name"] != "admin" for tag in schema["tags"])
|
||||
schema_names = set(schema["components"]["schemas"])
|
||||
assert "AdminDashboardResponse" not in schema_names
|
||||
assert "AdminHostnamesResponse" not in schema_names
|
||||
assert "AdminEventsResponse" not in schema_names
|
||||
assert "AdminRecordsResponse" not in schema_names
|
||||
|
||||
|
||||
def test_custom_api_docs_use_visitor_public_ip(tmp_path: Path) -> None:
|
||||
@@ -110,10 +112,14 @@ def test_openapi_hides_custom_operator_routes(tmp_path: Path) -> None:
|
||||
"/ops/records",
|
||||
"/records",
|
||||
"/events",
|
||||
"/api/v1/admin/dashboard",
|
||||
"/api/v1/admin/events",
|
||||
"/api/v1/admin/hostnames",
|
||||
"/api/v1/admin/records",
|
||||
}
|
||||
assert client.get("/redoc").status_code == 404
|
||||
assert forbidden_paths.isdisjoint(schema["paths"])
|
||||
assert "/api/v1/admin/dashboard" in schema["paths"]
|
||||
assert not any(path.startswith("/api/v1/admin") for path in schema["paths"])
|
||||
|
||||
|
||||
def test_openapi_marks_generated_links_as_secret(tmp_path: Path) -> None:
|
||||
|
||||
+11
-6
@@ -26,11 +26,12 @@ def test_self_service_managed_hostname_generates_random_account(tmp_path: Path)
|
||||
response = client.post("/")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "/m/" in str(response.url)
|
||||
assert "Update-URL:" in response.text
|
||||
assert "CNAME target:" in response.text
|
||||
assert "Register URL:" in response.text
|
||||
assert "Router fields" in response.text
|
||||
assert "CNAME" in response.text
|
||||
assert "Router setup." in response.text
|
||||
assert "Use your own DNS name." in response.text
|
||||
assert "Manual updates" in response.text
|
||||
assert "curl -sS" in response.text
|
||||
assert "203.0.113.10" in response.text
|
||||
@@ -41,6 +42,8 @@ def test_self_service_managed_hostname_generates_random_account(tmp_path: Path)
|
||||
assert "/api/v1/router/update/" in response.text
|
||||
assert "/api/v1/router/register/" in response.text
|
||||
assert "/m/" in response.text
|
||||
assert 'type="password"' not in response.text
|
||||
assert "Copy setup values" not in response.text
|
||||
|
||||
|
||||
def test_legacy_custom_account_form_is_rejected(tmp_path: Path) -> None:
|
||||
@@ -74,20 +77,22 @@ def test_hostname_without_login_generates_update_and_dashboard_links(tmp_path: P
|
||||
response = client.post("/")
|
||||
|
||||
assert response.status_code == 200
|
||||
assert "/m/" in str(response.url)
|
||||
assert "Update-URL:" in response.text
|
||||
assert "CNAME target:" in response.text
|
||||
assert "Register URL:" in response.text
|
||||
assert "Private dashboard:" in response.text
|
||||
assert "Pending setup" in response.text
|
||||
assert "Register hostname" in response.text
|
||||
assert "Unregistered setups are removed after 24 hours." in response.text
|
||||
assert "Router fields" in response.text
|
||||
assert "CNAME" in response.text
|
||||
assert "FRITZ!Box fills in" in response.text
|
||||
assert "Pending setups are cleaned up after 24 hours." in response.text
|
||||
assert "Router fields" not in response.text
|
||||
assert "Copy setup values" not in response.text
|
||||
assert "Paste this exact URL into the FRITZ!Box" in response.text
|
||||
assert "Copy manual update commands" in response.text
|
||||
assert response.text.count("Secret") >= 3
|
||||
assert response.text.count("Public") >= 3
|
||||
assert ".ddns.example.net" in response.text
|
||||
assert 'type="password"' not in response.text
|
||||
|
||||
|
||||
def test_public_examples_use_visitor_public_ip(tmp_path: Path) -> None:
|
||||
|
||||
Reference in new issue
Block a user