Expose usedns, date_pattern, and prefregex in jail config UI
- Add use_dns and prefregex fields to JailConfig model (backend + frontend types) - Add prefregex to JailConfigUpdate; validate as regex before writing - Fetch usedns and prefregex in get_jail_config via asyncio.gather - Write usedns and prefregex in update_jail_config - ConfigPage JailAccordionPanel: editable date_pattern input, dns_mode Select dropdown (yes/warn/no/raw), and prefregex input - 8 new service unit tests + 3 new router integration tests - 628 tests pass; 85% line coverage; ruff/mypy/tsc/eslint clean
This commit is contained in:
@@ -77,6 +77,8 @@ def _make_jail_config(name: str = "sshd") -> JailConfig:
|
||||
date_pattern=None,
|
||||
log_encoding="UTF-8",
|
||||
backend="polling",
|
||||
use_dns="warn",
|
||||
prefregex="",
|
||||
actions=["iptables"],
|
||||
)
|
||||
|
||||
@@ -234,6 +236,45 @@ class TestUpdateJailConfig:
|
||||
|
||||
assert resp.status_code == 400
|
||||
|
||||
async def test_204_with_dns_mode(self, config_client: AsyncClient) -> None:
|
||||
"""PUT /api/config/jails/sshd accepts dns_mode field."""
|
||||
with patch(
|
||||
"app.routers.config.config_service.update_jail_config",
|
||||
AsyncMock(return_value=None),
|
||||
):
|
||||
resp = await config_client.put(
|
||||
"/api/config/jails/sshd",
|
||||
json={"dns_mode": "no"},
|
||||
)
|
||||
|
||||
assert resp.status_code == 204
|
||||
|
||||
async def test_204_with_prefregex(self, config_client: AsyncClient) -> None:
|
||||
"""PUT /api/config/jails/sshd accepts prefregex field."""
|
||||
with patch(
|
||||
"app.routers.config.config_service.update_jail_config",
|
||||
AsyncMock(return_value=None),
|
||||
):
|
||||
resp = await config_client.put(
|
||||
"/api/config/jails/sshd",
|
||||
json={"prefregex": r"^%(__prefix_line)s"},
|
||||
)
|
||||
|
||||
assert resp.status_code == 204
|
||||
|
||||
async def test_204_with_date_pattern(self, config_client: AsyncClient) -> None:
|
||||
"""PUT /api/config/jails/sshd accepts date_pattern field."""
|
||||
with patch(
|
||||
"app.routers.config.config_service.update_jail_config",
|
||||
AsyncMock(return_value=None),
|
||||
):
|
||||
resp = await config_client.put(
|
||||
"/api/config/jails/sshd",
|
||||
json={"date_pattern": "%Y-%m-%d %H:%M:%S"},
|
||||
)
|
||||
|
||||
assert resp.status_code == 204
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# GET /api/config/global
|
||||
|
||||
Reference in New Issue
Block a user