Archived
Refactor UI assets and harden quality checks
This commit is contained in:
1 parent
23ab466c52
commit
4ecc8eb874
62 files changed
+3314
-3206
No files matched your search
+25
-2
@@ -395,6 +395,15 @@ def test_invalid_dns_provider_is_rejected() -> None:
|
||||
validate_dns_provider_settings(settings)
|
||||
|
||||
|
||||
def test_dns_backend_enabled_recognizes_explicit_or_legacy_rfc2136() -> None:
|
||||
from karldns.dns.base import _dns_backend_enabled
|
||||
|
||||
assert _dns_backend_enabled("cloudflare", DdnsSettings()) is True
|
||||
assert _dns_backend_enabled("rfc2136", DdnsSettings()) is True
|
||||
assert _dns_backend_enabled("", DdnsSettings(rfc2136_server="192.0.2.53")) is True
|
||||
assert _dns_backend_enabled("", DdnsSettings()) is False
|
||||
|
||||
|
||||
def test_required_cloudflare_provider_requires_token_and_zone(tmp_path: Path) -> None:
|
||||
with pytest.raises(RuntimeError, match="DDNS_CLOUDFLARE_API_TOKEN"):
|
||||
make_app(
|
||||
@@ -470,7 +479,7 @@ def test_cloudflare_publish_reconciles_provider_state(monkeypatch) -> None:
|
||||
return {"id": "record-id", "content": "203.0.113.99"}
|
||||
|
||||
monkeypatch.setattr(cloudflare, "_cloudflare_find_record", fake_find)
|
||||
monkeypatch.setattr(cloudflare, "_cloudflare_request", lambda *args, **kwargs: {"success": True, "result": []})
|
||||
monkeypatch.setattr(cloudflare, "_cloudflare_request", lambda *args, **_kwargs: {"success": True, "result": []})
|
||||
|
||||
with pytest.raises(DnsReconciliationError, match="did not match"):
|
||||
cloudflare.publish_cloudflare(
|
||||
@@ -496,7 +505,7 @@ def test_rfc2136_delete_checks_response_code(monkeypatch) -> None:
|
||||
def rcode(self) -> int:
|
||||
return dns.rcode.REFUSED
|
||||
|
||||
monkeypatch.setattr(dns.query, "tcp", lambda *args, **kwargs: RefusedResponse())
|
||||
monkeypatch.setattr(dns.query, "tcp", lambda *args, **_kwargs: RefusedResponse())
|
||||
|
||||
with pytest.raises(DnsProviderError, match="RFC2136 delete failed"):
|
||||
delete_rfc2136_records(
|
||||
@@ -505,6 +514,20 @@ def test_rfc2136_delete_checks_response_code(monkeypatch) -> None:
|
||||
)
|
||||
|
||||
|
||||
def test_rfc2136_zone_uses_explicit_setting_or_hostname_parent() -> None:
|
||||
from karldns.dns.rfc2136 import _rfc2136_zone
|
||||
|
||||
assert _rfc2136_zone("home.example.net", DdnsSettings(rfc2136_zone="example.net")) == "example.net"
|
||||
assert _rfc2136_zone("home.example.net", DdnsSettings()) == "example.net"
|
||||
|
||||
|
||||
def test_rfc2136_relative_name_uses_at_for_zone_apex() -> None:
|
||||
from karldns.dns.rfc2136 import _rfc2136_relative_name
|
||||
|
||||
assert _rfc2136_relative_name("home.example.net", "example.net") == "home"
|
||||
assert _rfc2136_relative_name("example.net", "example.net") == "@"
|
||||
|
||||
|
||||
def test_invalid_integer_env_value_fails_startup(monkeypatch) -> None:
|
||||
monkeypatch.setenv("DDNS_RATE_LIMIT_PER_MINUTE", "not-an-int")
|
||||
|
||||
|
||||
Reference in new issue
Block a user