Refactor UI assets and harden quality checks

This commit is contained in:
StasonJatham committed 2026-06-17 23:18:00 +02:00
1 parent 23ab466c52
commit 4ecc8eb874
62 files changed
+3314 -3206

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
import asyncio
from starlette.responses import HTMLResponse
from karldns.routers.management_passwords import (
_dashboard_password_error,
_dashboard_password_error_response,
_DashboardPasswordErrorContext,
)
def test_dashboard_password_error_requires_minimum_length() -> None:
assert _dashboard_password_error("short", "short") == "Password must be at least 8 characters."
def test_dashboard_password_error_requires_confirmation_match() -> None:
assert _dashboard_password_error("correct horse", "different horse") == "The passwords do not match."
def test_dashboard_password_error_accepts_valid_password() -> None:
assert _dashboard_password_error("correct horse", "correct horse") is None
def test_dashboard_password_error_response_renders_new_password_errors(monkeypatch) -> None:
async def fake_render_management_page_async(_service: object, context: object) -> str:
return f"message={context.message}"
monkeypatch.setattr(
"karldns.routers.management_passwords.render_management_page_async",
fake_render_management_page_async,
)
response = asyncio.run(
_dashboard_password_error_response(
object(),
_DashboardPasswordErrorContext(
management_slug="manage-secret",
account={"hostname": "home.example.net"},
form={"dashboard_password": ["short"], "dashboard_password_confirm": ["short"]},
request_ip="198.51.100.1",
current_password_error=None,
),
)
)
assert isinstance(response, HTMLResponse)
assert response.status_code == 400
assert b"Password must be at least 8 characters." in response.body