diff options
author | Maxim Devaev <[email protected]> | 2023-01-22 18:11:26 +0200 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2023-01-22 19:35:45 +0200 |
commit | 828778f10afb5d9e3824c72ba559e448e158b4ce (patch) | |
tree | 27e5aaa0f26b9486a5aee475aef5ca78bcc8256b | |
parent | 2cbdd9984a51854930885967b8eddb78b58783b6 (diff) |
refactoring
-rw-r--r-- | kvmd/apps/kvmd/__init__.py | 6 | ||||
-rw-r--r-- | kvmd/apps/kvmd/auth.py | 5 | ||||
-rw-r--r-- | testenv/tests/apps/kvmd/test_auth.py | 12 |
3 files changed, 14 insertions, 9 deletions
diff --git a/kvmd/apps/kvmd/__init__.py b/kvmd/apps/kvmd/__init__.py index dcc9efea..4d891f40 100644 --- a/kvmd/apps/kvmd/__init__.py +++ b/kvmd/apps/kvmd/__init__.py @@ -74,12 +74,14 @@ def main(argv: (list[str] | None)=None) -> None: KvmdServer( auth_manager=AuthManager( + enabled=config.auth.enabled, + internal_type=config.auth.internal.type, internal_kwargs=config.auth.internal._unpack(ignore=["type", "force_users"]), + force_internal_users=config.auth.internal.force_users, + external_type=config.auth.external.type, external_kwargs=(config.auth.external._unpack(ignore=["type"]) if config.auth.external.type else {}), - force_internal_users=config.auth.internal.force_users, - enabled=config.auth.enabled, ), info_manager=InfoManager(global_config), log_reader=(LogReader() if config.log_reader.enabled else None), diff --git a/kvmd/apps/kvmd/auth.py b/kvmd/apps/kvmd/auth.py index cfc2fb6a..6ae696ad 100644 --- a/kvmd/apps/kvmd/auth.py +++ b/kvmd/apps/kvmd/auth.py @@ -34,15 +34,14 @@ from ...plugins.auth import get_auth_service_class class AuthManager: def __init__( self, + enabled: bool, internal_type: str, internal_kwargs: dict, + force_internal_users: list[str], external_type: str, external_kwargs: dict, - - force_internal_users: list[str], - enabled: bool, ) -> None: self.__enabled = enabled diff --git a/testenv/tests/apps/kvmd/test_auth.py b/testenv/tests/apps/kvmd/test_auth.py index 4a9b8766..8b8577bd 100644 --- a/testenv/tests/apps/kvmd/test_auth.py +++ b/testenv/tests/apps/kvmd/test_auth.py @@ -51,12 +51,14 @@ async def _get_configured_manager( ) -> AsyncGenerator[AuthManager, None]: manager = AuthManager( + enabled=True, + internal_type="htpasswd", internal_kwargs=_make_service_kwargs(internal_path), + force_internal_users=(force_internal_users or []), + external_type=("htpasswd" if external_path else ""), external_kwargs=(_make_service_kwargs(external_path) if external_path else {}), - force_internal_users=(force_internal_users or []), - enabled=True, ) try: @@ -139,12 +141,14 @@ async def test_ok__external(tmpdir) -> None: # type: ignore async def test_ok__disabled() -> None: try: manager = AuthManager( + enabled=False, + internal_type="foobar", internal_kwargs={}, + force_internal_users=[], + external_type="", external_kwargs={}, - force_internal_users=[], - enabled=False, ) assert not manager.is_auth_enabled() |