Refactor backend services and jail configuration
- Refactor action_config_service, filter_config_service, jail_config_service, and jail_service - Add jail_socket utility module for socket communication - Update test_jail_service with new test cases - Update architecture and task documentation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -15,6 +15,7 @@ from app.models.geo import GeoDetail, GeoInfo
|
||||
from app.models.jail import JailDetailResponse, JailListResponse
|
||||
from app.services import ban_service, jail_service
|
||||
from app.services.jail_service import JailNotFoundError, JailOperationError
|
||||
from app.utils import jail_socket
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Helpers
|
||||
@@ -75,6 +76,7 @@ def _patch_client(responses: dict[str, Any]) -> Any:
|
||||
stack = contextlib.ExitStack()
|
||||
stack.enter_context(patch("app.services.jail_service.Fail2BanClient", _FakeClient))
|
||||
stack.enter_context(patch("app.services.ban_service.Fail2BanClient", _FakeClient))
|
||||
stack.enter_context(patch("app.utils.jail_socket.Fail2BanClient", _FakeClient))
|
||||
return stack
|
||||
|
||||
|
||||
@@ -281,12 +283,12 @@ class TestLockInitialization:
|
||||
|
||||
async def test_reload_all_lock_is_lazy_initialised(self) -> None:
|
||||
"""The reload-all lock should be created lazily on first use."""
|
||||
jail_service._reload_all_lock = None
|
||||
jail_socket._reload_all_lock = None
|
||||
|
||||
lock = _ = jail_service._get_reload_all_lock()
|
||||
lock = _ = jail_socket._get_reload_all_lock()
|
||||
|
||||
assert isinstance(lock, asyncio.Lock)
|
||||
assert jail_service._reload_all_lock is lock
|
||||
assert jail_socket._reload_all_lock is lock
|
||||
|
||||
async def test_backend_cmd_lock_is_lazy_initialised(self) -> None:
|
||||
"""The backend capability probe lock should be created lazily on first use."""
|
||||
|
||||
Reference in New Issue
Block a user