From be00606d8ccc1854f6c21f663e8ba34dd839473d Mon Sep 17 00:00:00 2001 From: Tobias Messner Date: Mon, 9 Dec 2024 14:40:38 +0100 Subject: [PATCH] chore: Refactor configuration paths - Move the web-based configuration code outside the settings folder - Change the configuration API paths from /settings/configuration to /configuration - Move the server-side config code inside the new top-level configuration folder into a new folder called app --- backend/capellacollab/__main__.py | 2 +- backend/capellacollab/alembic/env.py | 2 +- .../{settings => }/configuration/__init__.py | 0 .../{config => configuration/app}/__init__.py | 0 .../app}/exceptions.py | 0 .../{config => configuration/app}/generate.py | 4 +++- .../{config => configuration/app}/loader.py | 2 +- .../{config => configuration/app}/models.py | 0 .../{settings => }/configuration/core.py | 0 .../{settings => }/configuration/crud.py | 0 .../{settings => }/configuration/models.py | 0 .../{settings => }/configuration/routes.py | 8 ++++--- .../{settings => }/configuration/util.py | 5 ++-- .../core/authentication/api_key_cookie.py | 2 +- .../capellacollab/core/authentication/oidc.py | 2 +- .../capellacollab/core/database/__init__.py | 2 +- .../capellacollab/core/database/migration.py | 2 +- backend/capellacollab/core/database/models.py | 2 +- backend/capellacollab/core/email/send.py | 2 +- .../capellacollab/core/logging/__init__.py | 4 ++-- backend/capellacollab/core/logging/loki.py | 4 ++-- backend/capellacollab/core/responses.py | 2 +- backend/capellacollab/feedback/util.py | 8 +++---- .../projects/toolmodels/backups/routes.py | 2 +- .../toolmodels/backups/runs/interface.py | 2 +- .../modelsources/git/github/handler.py | 2 +- .../modelsources/git/gitlab/handler.py | 2 +- backend/capellacollab/routes.py | 11 +++++++++ .../capellacollab/sessions/hooks/guacamole.py | 2 +- .../sessions/hooks/log_collector.py | 2 +- backend/capellacollab/sessions/idletimeout.py | 2 +- backend/capellacollab/sessions/injection.py | 2 +- backend/capellacollab/sessions/models.py | 2 +- .../capellacollab/sessions/operators/k8s.py | 4 ++-- backend/capellacollab/sessions/util.py | 4 +--- .../t4c/instance/repositories/interface.py | 2 +- .../t4c/license_server/interface.py | 6 ++--- backend/capellacollab/settings/routes.py | 5 ---- backend/capellacollab/tools/models.py | 2 +- backend/capellacollab/tools/routes.py | 2 +- backend/capellacollab/users/routes.py | 2 +- .../tests/config/test_app_configuration.py | 4 ++-- backend/tests/core/test_auth_routes.py | 2 +- .../pipeline-runs/test_pipeline_runs.py | 2 +- .../sessions/test_session_environment.py | 6 ++--- .../sessions/test_session_idletimeout.py | 2 +- .../tests/sessions/test_session_injection.py | 2 +- .../settings/test_global_configuration.py | 24 +++++++++---------- backend/tests/test_beta.py | 4 ++-- backend/tests/test_event_creation.py | 4 ++-- backend/tests/test_feedback.py | 16 ++++++------- .../app/openapi/api/configuration.service.ts | 15 ++++-------- 52 files changed, 95 insertions(+), 95 deletions(-) rename backend/capellacollab/{settings => }/configuration/__init__.py (100%) rename backend/capellacollab/{config => configuration/app}/__init__.py (100%) rename backend/capellacollab/{config => configuration/app}/exceptions.py (100%) rename backend/capellacollab/{config => configuration/app}/generate.py (88%) rename backend/capellacollab/{config => configuration/app}/loader.py (96%) rename backend/capellacollab/{config => configuration/app}/models.py (100%) rename backend/capellacollab/{settings => }/configuration/core.py (100%) rename backend/capellacollab/{settings => }/configuration/crud.py (100%) rename backend/capellacollab/{settings => }/configuration/models.py (100%) rename backend/capellacollab/{settings => }/configuration/routes.py (93%) rename backend/capellacollab/{settings => }/configuration/util.py (90%) diff --git a/backend/capellacollab/__main__.py b/backend/capellacollab/__main__.py index 6566fbe2d0..4f0bc904e2 100644 --- a/backend/capellacollab/__main__.py +++ b/backend/capellacollab/__main__.py @@ -16,7 +16,7 @@ import capellacollab.projects.toolmodels.backups.runs.interface as pipeline_runs_interface # This import statement is required and should not be removed! (Alembic will not work otherwise) -from capellacollab.config import config +from capellacollab.configuration.app import config from capellacollab.core import logging as core_logging from capellacollab.core.database import engine, migration from capellacollab.routes import router diff --git a/backend/capellacollab/alembic/env.py b/backend/capellacollab/alembic/env.py index 4852e1352e..14aa99f202 100644 --- a/backend/capellacollab/alembic/env.py +++ b/backend/capellacollab/alembic/env.py @@ -10,7 +10,7 @@ from alembic import context from sqlalchemy import engine_from_config, pool -from capellacollab.config import config as cfg +from capellacollab.configuration.app import config as cfg # this is the Alembic Config object, which provides # access to the values within the .ini file in use. diff --git a/backend/capellacollab/settings/configuration/__init__.py b/backend/capellacollab/configuration/__init__.py similarity index 100% rename from backend/capellacollab/settings/configuration/__init__.py rename to backend/capellacollab/configuration/__init__.py diff --git a/backend/capellacollab/config/__init__.py b/backend/capellacollab/configuration/app/__init__.py similarity index 100% rename from backend/capellacollab/config/__init__.py rename to backend/capellacollab/configuration/app/__init__.py diff --git a/backend/capellacollab/config/exceptions.py b/backend/capellacollab/configuration/app/exceptions.py similarity index 100% rename from backend/capellacollab/config/exceptions.py rename to backend/capellacollab/configuration/app/exceptions.py diff --git a/backend/capellacollab/config/generate.py b/backend/capellacollab/configuration/app/generate.py similarity index 88% rename from backend/capellacollab/config/generate.py rename to backend/capellacollab/configuration/app/generate.py index be3f4e6fce..f2faf7257e 100644 --- a/backend/capellacollab/config/generate.py +++ b/backend/capellacollab/configuration/app/generate.py @@ -15,7 +15,9 @@ def write_config() -> None: """Write the default configuration to a config file.""" config_path = ( - pathlib.Path(__file__).parent.parent.parent / "config" / "config.yaml" + pathlib.Path(__file__).parent.parent.parent.parent + / "config" + / "config.yaml" ) config_path.parent.mkdir(parents=True, exist_ok=True) diff --git a/backend/capellacollab/config/loader.py b/backend/capellacollab/configuration/app/loader.py similarity index 96% rename from backend/capellacollab/config/loader.py rename to backend/capellacollab/configuration/app/loader.py index 712a8a5e14..d1f944db99 100644 --- a/backend/capellacollab/config/loader.py +++ b/backend/capellacollab/configuration/app/loader.py @@ -15,7 +15,7 @@ config_locations: list[pathlib.Path] = [ pathlib.Path(__file__).parents[0] / CONFIG_FILE_NAME, - pathlib.Path(__file__).parents[2] / "config" / CONFIG_FILE_NAME, + pathlib.Path(__file__).parents[3] / "config" / CONFIG_FILE_NAME, pathlib.Path(appdirs.user_config_dir("capellacollab", "db")) / CONFIG_FILE_NAME, pathlib.Path("/etc/capellacollab") / CONFIG_FILE_NAME, diff --git a/backend/capellacollab/config/models.py b/backend/capellacollab/configuration/app/models.py similarity index 100% rename from backend/capellacollab/config/models.py rename to backend/capellacollab/configuration/app/models.py diff --git a/backend/capellacollab/settings/configuration/core.py b/backend/capellacollab/configuration/core.py similarity index 100% rename from backend/capellacollab/settings/configuration/core.py rename to backend/capellacollab/configuration/core.py diff --git a/backend/capellacollab/settings/configuration/crud.py b/backend/capellacollab/configuration/crud.py similarity index 100% rename from backend/capellacollab/settings/configuration/crud.py rename to backend/capellacollab/configuration/crud.py diff --git a/backend/capellacollab/settings/configuration/models.py b/backend/capellacollab/configuration/models.py similarity index 100% rename from backend/capellacollab/settings/configuration/models.py rename to backend/capellacollab/configuration/models.py diff --git a/backend/capellacollab/settings/configuration/routes.py b/backend/capellacollab/configuration/routes.py similarity index 93% rename from backend/capellacollab/settings/configuration/routes.py rename to backend/capellacollab/configuration/routes.py index c64b4f8317..bcda9ab5ba 100644 --- a/backend/capellacollab/settings/configuration/routes.py +++ b/backend/capellacollab/configuration/routes.py @@ -18,10 +18,12 @@ tags=["Configuration"], ) -schema_router = fastapi.APIRouter(dependencies=[], tags=["Configuration"]) +router_without_authentication = fastapi.APIRouter( + dependencies=[], tags=["Configuration"] +) -@router.get( +@router_without_authentication.get( "/unified", ) def get_unified_config( @@ -92,7 +94,7 @@ async def update_configuration( ).configuration -@schema_router.get( +@router_without_authentication.get( f"/{models.GlobalConfiguration._name}/schema", response_model=t.Any ) async def get_json_schema(): diff --git a/backend/capellacollab/settings/configuration/util.py b/backend/capellacollab/configuration/util.py similarity index 90% rename from backend/capellacollab/settings/configuration/util.py rename to backend/capellacollab/configuration/util.py index b9ddfe87ca..13051e68b9 100644 --- a/backend/capellacollab/settings/configuration/util.py +++ b/backend/capellacollab/configuration/util.py @@ -2,8 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 import capellacollab -from capellacollab.config import config -from capellacollab.settings.configuration import models +from capellacollab.configuration.app import config + +from . import models def get_metadata( diff --git a/backend/capellacollab/core/authentication/api_key_cookie.py b/backend/capellacollab/core/authentication/api_key_cookie.py index 9a6c34c3fb..d2ddf47191 100644 --- a/backend/capellacollab/core/authentication/api_key_cookie.py +++ b/backend/capellacollab/core/authentication/api_key_cookie.py @@ -9,7 +9,7 @@ from fastapi import security from jwt import exceptions as jwt_exceptions -from capellacollab.config import config +from capellacollab.configuration.app import config from . import exceptions, oidc diff --git a/backend/capellacollab/core/authentication/oidc.py b/backend/capellacollab/core/authentication/oidc.py index f2ed30c8b3..52118bfbee 100644 --- a/backend/capellacollab/core/authentication/oidc.py +++ b/backend/capellacollab/core/authentication/oidc.py @@ -8,7 +8,7 @@ import requests from oauthlib import common, oauth2 -from capellacollab.config import config +from capellacollab.configuration.app import config from . import exceptions, models diff --git a/backend/capellacollab/core/database/__init__.py b/backend/capellacollab/core/database/__init__.py index 652e0becdf..b1c9863df1 100644 --- a/backend/capellacollab/core/database/__init__.py +++ b/backend/capellacollab/core/database/__init__.py @@ -10,7 +10,7 @@ from sqlalchemy import orm from sqlalchemy.dialects import postgresql -from capellacollab.config import config +from capellacollab.configuration.app import config engine = sa.create_engine( config.database.url, diff --git a/backend/capellacollab/core/database/migration.py b/backend/capellacollab/core/database/migration.py index 99022aac1c..42ccd4feb9 100644 --- a/backend/capellacollab/core/database/migration.py +++ b/backend/capellacollab/core/database/migration.py @@ -12,7 +12,7 @@ from sqlalchemy import orm from capellacollab import core -from capellacollab.config import config +from capellacollab.configuration.app import config from capellacollab.core import database from capellacollab.events import crud as events_crud from capellacollab.projects import crud as projects_crud diff --git a/backend/capellacollab/core/database/models.py b/backend/capellacollab/core/database/models.py index 8f2ac6e160..0a25eb9adf 100644 --- a/backend/capellacollab/core/database/models.py +++ b/backend/capellacollab/core/database/models.py @@ -4,6 +4,7 @@ # pylint: disable=unused-import # These import statements of the models are required and should not be removed! (SQLAlchemy will not load the models otherwise) +import capellacollab.configuration.models import capellacollab.events.models import capellacollab.feedback.models import capellacollab.notices.models @@ -18,7 +19,6 @@ import capellacollab.projects.tools.models import capellacollab.projects.users.models import capellacollab.sessions.models -import capellacollab.settings.configuration.models import capellacollab.settings.integrations.purevariants.models import capellacollab.settings.modelsources.git.models import capellacollab.settings.modelsources.t4c.instance.models diff --git a/backend/capellacollab/core/email/send.py b/backend/capellacollab/core/email/send.py index 304839fc87..c3f8621465 100644 --- a/backend/capellacollab/core/email/send.py +++ b/backend/capellacollab/core/email/send.py @@ -7,7 +7,7 @@ import pydantic -from capellacollab.config import config +from capellacollab.configuration.app import config from . import exceptions, models diff --git a/backend/capellacollab/core/logging/__init__.py b/backend/capellacollab/core/logging/__init__.py index 605bf3b2ac..79db6ddc40 100644 --- a/backend/capellacollab/core/logging/__init__.py +++ b/backend/capellacollab/core/logging/__init__.py @@ -13,10 +13,10 @@ import fastapi from starlette.middleware import base -from capellacollab import config +from capellacollab.configuration.app import config from capellacollab.core.authentication import injectables as auth_injectables -LOGGING_LEVEL = config.config.logging.level +LOGGING_LEVEL = config.logging.level class CustomFormatter(logging.Formatter): diff --git a/backend/capellacollab/core/logging/loki.py b/backend/capellacollab/core/logging/loki.py index 3546cd80ec..089a6e8816 100644 --- a/backend/capellacollab/core/logging/loki.py +++ b/backend/capellacollab/core/logging/loki.py @@ -11,8 +11,8 @@ import requests from requests import auth -from capellacollab.config import config -from capellacollab.config import models as config_models +from capellacollab.configuration.app import config +from capellacollab.configuration.app import models as config_models from . import exceptions diff --git a/backend/capellacollab/core/responses.py b/backend/capellacollab/core/responses.py index 5caed9b193..46c45e7727 100644 --- a/backend/capellacollab/core/responses.py +++ b/backend/capellacollab/core/responses.py @@ -8,7 +8,7 @@ import fastapi import pydantic -from capellacollab.config import config +from capellacollab.configuration.app import config from capellacollab.core import pydantic as core_pydantic from capellacollab.projects.users import models as projects_users_models from capellacollab.users import models as users_models diff --git a/backend/capellacollab/feedback/util.py b/backend/capellacollab/feedback/util.py index e0d5e84ee6..e48f3b3f71 100644 --- a/backend/capellacollab/feedback/util.py +++ b/backend/capellacollab/feedback/util.py @@ -5,14 +5,12 @@ from sqlalchemy import orm -from capellacollab.config import config +from capellacollab.configuration import core as config_core +from capellacollab.configuration import models as settings_config_models +from capellacollab.configuration.app import config from capellacollab.core.email import exceptions as email_exceptions from capellacollab.core.email import models as email_models from capellacollab.core.email import send as email_send -from capellacollab.settings.configuration import core as config_core -from capellacollab.settings.configuration import ( - models as settings_config_models, -) from capellacollab.users import models as users_models from . import exceptions, models diff --git a/backend/capellacollab/projects/toolmodels/backups/routes.py b/backend/capellacollab/projects/toolmodels/backups/routes.py index 8e6927bace..ef52128383 100644 --- a/backend/capellacollab/projects/toolmodels/backups/routes.py +++ b/backend/capellacollab/projects/toolmodels/backups/routes.py @@ -9,6 +9,7 @@ import requests from sqlalchemy import orm +from capellacollab.configuration import core as configuration_core from capellacollab.core import credentials, database from capellacollab.core.authentication import injectables as auth_injectables from capellacollab.projects.toolmodels import ( @@ -23,7 +24,6 @@ ) from capellacollab.projects.users import models as projects_users_models from capellacollab.sessions import operators -from capellacollab.settings.configuration import core as configuration_core from capellacollab.settings.modelsources.t4c.instance.repositories import ( interface as t4c_repository_interface, ) diff --git a/backend/capellacollab/projects/toolmodels/backups/runs/interface.py b/backend/capellacollab/projects/toolmodels/backups/runs/interface.py index 8fcb674bc8..c1ba6f303e 100644 --- a/backend/capellacollab/projects/toolmodels/backups/runs/interface.py +++ b/backend/capellacollab/projects/toolmodels/backups/runs/interface.py @@ -9,7 +9,7 @@ from kubernetes.client import exceptions as k8s_exceptions from starlette import concurrency as starlette_concurrency -from capellacollab.config import config +from capellacollab.configuration.app import config from capellacollab.core import database from capellacollab.core.logging import loki from capellacollab.projects.toolmodels import ( diff --git a/backend/capellacollab/projects/toolmodels/modelsources/git/github/handler.py b/backend/capellacollab/projects/toolmodels/modelsources/git/github/handler.py index c9e68fd878..f339276f1e 100644 --- a/backend/capellacollab/projects/toolmodels/modelsources/git/github/handler.py +++ b/backend/capellacollab/projects/toolmodels/modelsources/git/github/handler.py @@ -10,7 +10,7 @@ import requests -from capellacollab.config import config +from capellacollab.configuration.app import config from .. import exceptions as git_exceptions from ..handler import handler diff --git a/backend/capellacollab/projects/toolmodels/modelsources/git/gitlab/handler.py b/backend/capellacollab/projects/toolmodels/modelsources/git/gitlab/handler.py index 709aab069a..cb9a581621 100644 --- a/backend/capellacollab/projects/toolmodels/modelsources/git/gitlab/handler.py +++ b/backend/capellacollab/projects/toolmodels/modelsources/git/gitlab/handler.py @@ -8,7 +8,7 @@ import aiohttp import requests -from capellacollab.config import config +from capellacollab.configuration.app import config from .. import exceptions as git_exceptions from ..handler import handler diff --git a/backend/capellacollab/routes.py b/backend/capellacollab/routes.py index 3a30672f9f..9f606f9158 100644 --- a/backend/capellacollab/routes.py +++ b/backend/capellacollab/routes.py @@ -6,6 +6,7 @@ import fastapi +from capellacollab.configuration import routes as configuration_routes from capellacollab.core import responses as auth_responses from capellacollab.core.authentication import routes as authentication_routes from capellacollab.events import routes as events_router @@ -77,5 +78,15 @@ settings_routes.router_without_authentication, prefix="/settings", ) +router.include_router( + configuration_routes.router, + prefix="/configurations", + responses=auth_responses.api_exceptions(include_authentication=True), +) +router.include_router( + configuration_routes.router_without_authentication, + prefix="/configurations", +) + router.include_router(authentication_routes.router, prefix="/authentication") diff --git a/backend/capellacollab/sessions/hooks/guacamole.py b/backend/capellacollab/sessions/hooks/guacamole.py index 4ea12c157c..05635c41a0 100644 --- a/backend/capellacollab/sessions/hooks/guacamole.py +++ b/backend/capellacollab/sessions/hooks/guacamole.py @@ -10,7 +10,7 @@ from requests import auth as requests_auth from requests import exceptions as requests_exceptions -from capellacollab.config import config +from capellacollab.configuration.app import config from capellacollab.core import credentials from . import interface diff --git a/backend/capellacollab/sessions/hooks/log_collector.py b/backend/capellacollab/sessions/hooks/log_collector.py index 2e0c3e02a3..7b4ecd54c3 100644 --- a/backend/capellacollab/sessions/hooks/log_collector.py +++ b/backend/capellacollab/sessions/hooks/log_collector.py @@ -6,7 +6,7 @@ import yaml -from capellacollab.config import config +from capellacollab.configuration.app import config from capellacollab.sessions import models as sessions_models from capellacollab.sessions.operators import models as operators_models from capellacollab.tools import models as tools_models diff --git a/backend/capellacollab/sessions/idletimeout.py b/backend/capellacollab/sessions/idletimeout.py index d3fd0f6a1c..9f3121d069 100644 --- a/backend/capellacollab/sessions/idletimeout.py +++ b/backend/capellacollab/sessions/idletimeout.py @@ -9,7 +9,7 @@ import requests from starlette import concurrency -from capellacollab.config import config +from capellacollab.configuration.app import config from capellacollab.core import database from . import crud, operators, util diff --git a/backend/capellacollab/sessions/injection.py b/backend/capellacollab/sessions/injection.py index 9a375bf0f1..7887ac5dc9 100644 --- a/backend/capellacollab/sessions/injection.py +++ b/backend/capellacollab/sessions/injection.py @@ -6,7 +6,7 @@ import requests from capellacollab import core -from capellacollab.config import config +from capellacollab.configuration.app import config from capellacollab.sessions import models2 as sessions_models2 log = logging.getLogger(__name__) diff --git a/backend/capellacollab/sessions/models.py b/backend/capellacollab/sessions/models.py index a468298d33..3dedb1a62e 100644 --- a/backend/capellacollab/sessions/models.py +++ b/backend/capellacollab/sessions/models.py @@ -12,7 +12,7 @@ import sqlalchemy as sa from sqlalchemy import orm -from capellacollab.config import config +from capellacollab.configuration.app import config from capellacollab.core import database from capellacollab.core import models as core_models from capellacollab.core import pydantic as core_pydantic diff --git a/backend/capellacollab/sessions/operators/k8s.py b/backend/capellacollab/sessions/operators/k8s.py index a6527d0d70..e116428751 100644 --- a/backend/capellacollab/sessions/operators/k8s.py +++ b/backend/capellacollab/sessions/operators/k8s.py @@ -23,8 +23,8 @@ from kubernetes import client from kubernetes.client import exceptions -from capellacollab.config import config -from capellacollab.config import models as config_models +from capellacollab.configuration.app import config +from capellacollab.configuration.app import models as config_models from capellacollab.sessions import models as sessions_models from capellacollab.tools import models as tools_models diff --git a/backend/capellacollab/sessions/util.py b/backend/capellacollab/sessions/util.py index 692ebfedd3..cecc61e5e6 100644 --- a/backend/capellacollab/sessions/util.py +++ b/backend/capellacollab/sessions/util.py @@ -10,12 +10,10 @@ from sqlalchemy import orm -from capellacollab.config import config +from capellacollab.configuration.app import config from capellacollab.core import credentials from capellacollab.core import models as core_models -from capellacollab.sessions import hooks from capellacollab.sessions.hooks import interface as hooks_interface -from capellacollab.sessions.operators import k8s from capellacollab.tools import models as tools_models from capellacollab.users import models as users_models diff --git a/backend/capellacollab/settings/modelsources/t4c/instance/repositories/interface.py b/backend/capellacollab/settings/modelsources/t4c/instance/repositories/interface.py index 05a3d372b1..8d41f2765e 100644 --- a/backend/capellacollab/settings/modelsources/t4c/instance/repositories/interface.py +++ b/backend/capellacollab/settings/modelsources/t4c/instance/repositories/interface.py @@ -6,7 +6,7 @@ import requests from requests import auth -from capellacollab.config import config +from capellacollab.configuration.app import config from capellacollab.core import credentials from capellacollab.settings.modelsources.t4c.instance import ( models as t4c_models, diff --git a/backend/capellacollab/settings/modelsources/t4c/license_server/interface.py b/backend/capellacollab/settings/modelsources/t4c/license_server/interface.py index 9aa6e23863..5aec567b30 100644 --- a/backend/capellacollab/settings/modelsources/t4c/license_server/interface.py +++ b/backend/capellacollab/settings/modelsources/t4c/license_server/interface.py @@ -3,7 +3,7 @@ import requests -from capellacollab import config +from capellacollab.configuration.app import config from capellacollab.core import pydantic as core_pydantic from . import exceptions @@ -18,7 +18,7 @@ def get_t4c_license_server_version(usage_api: str) -> str | None: try: r = requests.get( f"{usage_api}/status/json", - timeout=config.config.requests.timeout, + timeout=config.requests.timeout, ) except requests.Timeout: return None @@ -36,7 +36,7 @@ def get_t4c_license_server_usage(usage_api: str) -> T4CLicenseServerUsage: try: r = requests.get( f"{usage_api}/status/json", - timeout=config.config.requests.timeout, + timeout=config.requests.timeout, ) except requests.Timeout: raise exceptions.T4CLicenseServerTimeoutError() diff --git a/backend/capellacollab/settings/routes.py b/backend/capellacollab/settings/routes.py index 8a8ebfdc01..e2137d8a7a 100644 --- a/backend/capellacollab/settings/routes.py +++ b/backend/capellacollab/settings/routes.py @@ -4,7 +4,6 @@ import fastapi from capellacollab.core.authentication import injectables as auth_injectables -from capellacollab.settings.configuration import routes as configuration_routes from capellacollab.settings.integrations.purevariants import ( routes as purevariants_routes, ) @@ -29,7 +28,3 @@ router.include_router( purevariants_routes.router, prefix="/integrations/pure-variants" ) -router.include_router(configuration_routes.router, prefix="/configurations") -router_without_authentication.include_router( - configuration_routes.schema_router, prefix="/configurations" -) diff --git a/backend/capellacollab/tools/models.py b/backend/capellacollab/tools/models.py index a9dc9fb73b..c045e21326 100644 --- a/backend/capellacollab/tools/models.py +++ b/backend/capellacollab/tools/models.py @@ -15,7 +15,7 @@ from sqlalchemy import orm from capellacollab import core -from capellacollab.config import config +from capellacollab.configuration.app import config from capellacollab.core import database from capellacollab.core import pydantic as core_pydantic from capellacollab.core.database import decorator diff --git a/backend/capellacollab/tools/routes.py b/backend/capellacollab/tools/routes.py index 8bfc81bac3..4d1eb70886 100644 --- a/backend/capellacollab/tools/routes.py +++ b/backend/capellacollab/tools/routes.py @@ -8,7 +8,7 @@ import capellacollab.projects.toolmodels.crud as projects_models_crud import capellacollab.settings.modelsources.t4c.instance.crud as settings_t4c_crud -from capellacollab.config import config +from capellacollab.configuration.app import config from capellacollab.core import database from capellacollab.core import exceptions as core_exceptions from capellacollab.core.authentication import injectables as auth_injectables diff --git a/backend/capellacollab/users/routes.py b/backend/capellacollab/users/routes.py index 6684372a0c..2d72687027 100644 --- a/backend/capellacollab/users/routes.py +++ b/backend/capellacollab/users/routes.py @@ -6,6 +6,7 @@ import fastapi from sqlalchemy import orm +from capellacollab.configuration import core as config_core from capellacollab.core import database from capellacollab.core.authentication import injectables as auth_injectables from capellacollab.events import crud as events_crud @@ -15,7 +16,6 @@ from capellacollab.projects import models as projects_models from capellacollab.projects.users import crud as projects_users_crud from capellacollab.sessions import routes as session_routes -from capellacollab.settings.configuration import core as config_core from capellacollab.users import injectables as users_injectables from capellacollab.users import models as users_models from capellacollab.users.tokens import routes as tokens_routes diff --git a/backend/tests/config/test_app_configuration.py b/backend/tests/config/test_app_configuration.py index 7137de9f29..2785f9a468 100644 --- a/backend/tests/config/test_app_configuration.py +++ b/backend/tests/config/test_app_configuration.py @@ -7,8 +7,8 @@ import pytest import yaml -from capellacollab.config import exceptions as config_exceptions -from capellacollab.config import loader +from capellacollab.configuration.app import exceptions as config_exceptions +from capellacollab.configuration.app import loader def test_loader_unique_key_loader_succeeds(): diff --git a/backend/tests/core/test_auth_routes.py b/backend/tests/core/test_auth_routes.py index dfb01d7af3..de4ed486b6 100644 --- a/backend/tests/core/test_auth_routes.py +++ b/backend/tests/core/test_auth_routes.py @@ -9,7 +9,7 @@ from fastapi import status, testclient from sqlalchemy import orm -from capellacollab.config import config +from capellacollab.configuration.app import config from capellacollab.core.authentication import api_key_cookie, exceptions, oidc from capellacollab.core.authentication import routes as auth_routes from capellacollab.users import crud as users_crud diff --git a/backend/tests/projects/toolmodels/pipelines/pipeline-runs/test_pipeline_runs.py b/backend/tests/projects/toolmodels/pipelines/pipeline-runs/test_pipeline_runs.py index 073f0a5c71..6c308a40ba 100644 --- a/backend/tests/projects/toolmodels/pipelines/pipeline-runs/test_pipeline_runs.py +++ b/backend/tests/projects/toolmodels/pipelines/pipeline-runs/test_pipeline_runs.py @@ -15,7 +15,7 @@ import capellacollab.projects.toolmodels.backups.runs.models as pipeline_runs_models import capellacollab.projects.toolmodels.models as toolmodels_models from capellacollab.__main__ import app -from capellacollab.config import config +from capellacollab.configuration.app import config from capellacollab.core.logging import loki from capellacollab.projects.toolmodels.backups.runs import ( injectables as runs_injectables, diff --git a/backend/tests/sessions/test_session_environment.py b/backend/tests/sessions/test_session_environment.py index 763ccb4c99..30a07e53bb 100644 --- a/backend/tests/sessions/test_session_environment.py +++ b/backend/tests/sessions/test_session_environment.py @@ -6,8 +6,8 @@ import pytest from sqlalchemy import orm -from capellacollab import config -from capellacollab.config import models as config_models +from capellacollab.configuration.app import config +from capellacollab.configuration.app import models as config_models from capellacollab.core import models as core_models from capellacollab.sessions import crud as sessions_crud from capellacollab.sessions import hooks as sessions_hooks @@ -97,7 +97,7 @@ def fixture_patch_irrelevant_request_session_calls( ) monkeypatch.setattr( - config.config, + config, "general", config_models.GeneralConfig( host="localhost", port=8080, scheme="http" diff --git a/backend/tests/sessions/test_session_idletimeout.py b/backend/tests/sessions/test_session_idletimeout.py index bc5c55420d..9cc62b46dd 100644 --- a/backend/tests/sessions/test_session_idletimeout.py +++ b/backend/tests/sessions/test_session_idletimeout.py @@ -5,7 +5,7 @@ import requests import capellacollab.sessions.idletimeout -from capellacollab.config import models as config_models +from capellacollab.configuration.app import models as config_models from capellacollab.sessions.idletimeout import terminate_idle_session diff --git a/backend/tests/sessions/test_session_injection.py b/backend/tests/sessions/test_session_injection.py index 387579f67c..08fa48e7d8 100644 --- a/backend/tests/sessions/test_session_injection.py +++ b/backend/tests/sessions/test_session_injection.py @@ -6,7 +6,7 @@ from fastapi import status from capellacollab import core -from capellacollab.config import config +from capellacollab.configuration.app import config from capellacollab.sessions import injection from capellacollab.sessions import models2 as models2_sessions diff --git a/backend/tests/settings/test_global_configuration.py b/backend/tests/settings/test_global_configuration.py index 3b3377256d..bb7610e9ea 100644 --- a/backend/tests/settings/test_global_configuration.py +++ b/backend/tests/settings/test_global_configuration.py @@ -6,7 +6,7 @@ from fastapi import testclient from sqlalchemy import orm -from capellacollab.settings.configuration import crud as configuration_crud +from capellacollab.configuration import crud as configuration_crud @pytest.mark.usefixtures("admin") @@ -15,7 +15,7 @@ def test_get_default_configuration( ): """Test that the default configuration is returned if no configuration is set.""" - response = client.get("/api/v1/settings/configurations/global") + response = client.get("/api/v1/configurations/global") assert response.status_code == 200 assert response.json()["metadata"]["environment"] == "-" @@ -34,7 +34,7 @@ def test_get_general_configuration( db, "global", {"metadata": {"environment": "test"}} ) - response = client.get("/api/v1/settings/configurations/global") + response = client.get("/api/v1/configurations/global") assert response.status_code == 200 assert response.json()["metadata"]["environment"] == "test" @@ -47,7 +47,7 @@ def test_get_general_configuration( @pytest.mark.usefixtures("executor_name") def test_get_configuration_schema(client: testclient.TestClient): - response = client.get("/api/v1/settings/configurations/global/schema") + response = client.get("/api/v1/configurations/global/schema") assert response.status_code == 200 assert "$defs" in response.json() @@ -65,7 +65,7 @@ def test_update_general_configuration( } response = client.put( - "/api/v1/settings/configurations/global", + "/api/v1/configurations/global", json={ "metadata": { "provider": "The best team in the world!", @@ -81,7 +81,7 @@ def test_update_general_configuration( ) response = client.put( - "/api/v1/settings/configurations/global", + "/api/v1/configurations/global", json={ "metadata": { "provider": "Still the best team in the world!", @@ -102,7 +102,7 @@ def test_update_general_configuration_additional_properties_fails( client: testclient.TestClient, ): response = client.put( - "/api/v1/settings/configurations/global", json={"test": "test"} + "/api/v1/configurations/global", json={"test": "test"} ) assert response.status_code == 422 @@ -114,7 +114,7 @@ def test_metadata_is_updated( client: testclient.TestClient, ): response = client.put( - "/api/v1/settings/configurations/global", + "/api/v1/configurations/global", json={ "metadata": { "privacy_policy_url": "https://example.com/privacy-policy", @@ -128,7 +128,7 @@ def test_metadata_is_updated( assert response.status_code == 200 - response = client.get("/api/v1/settings/configurations/unified") + response = client.get("/api/v1/configurations/unified") assert response.status_code == 200 assert response.json()["metadata"]["environment"] == "test" @@ -138,7 +138,7 @@ def test_navbar_is_updated( client: testclient.TestClient, ): response = client.put( - "/api/v1/settings/configurations/global", + "/api/v1/configurations/global", json={ "navbar": { "external_links": [ @@ -154,7 +154,7 @@ def test_navbar_is_updated( assert response.status_code == 200 - response = client.get("/api/v1/settings/configurations/unified") + response = client.get("/api/v1/configurations/unified") assert response.status_code == 200 assert response.json()["navbar"]["external_links"][0] == { "name": "Example", @@ -168,7 +168,7 @@ def test_global_configuration_invalid_pipelines( client: testclient.TestClient, ): response = client.put( - "/api/v1/settings/configurations/global", + "/api/v1/configurations/global", json={"pipelines": {"cron": "invalid", "timezone": "Berlin"}}, ) diff --git a/backend/tests/test_beta.py b/backend/tests/test_beta.py index 029ae5fb94..972aed8996 100644 --- a/backend/tests/test_beta.py +++ b/backend/tests/test_beta.py @@ -5,7 +5,7 @@ from fastapi import testclient from sqlalchemy import orm -from capellacollab.settings.configuration import crud as configuration_crud +from capellacollab.configuration import crud as configuration_crud from capellacollab.users import crud as users_crud from capellacollab.users import models as users_models @@ -137,7 +137,7 @@ def test_disable_beta_un_enroll( assert response.status_code == 200 client.put( - "/api/v1/settings/configurations/global", + "/api/v1/configurations/global", json={"beta": {"enabled": False}}, ) diff --git a/backend/tests/test_event_creation.py b/backend/tests/test_event_creation.py index cf2fc54174..8fd3b5e3d3 100644 --- a/backend/tests/test_event_creation.py +++ b/backend/tests/test_event_creation.py @@ -8,7 +8,7 @@ from fastapi import testclient from sqlalchemy import orm -from capellacollab import config +from capellacollab.configuration.app import config from capellacollab.events import models as events_models from capellacollab.projects import models as projects_models from capellacollab.projects.users import crud as projects_users_crud @@ -25,7 +25,7 @@ def fixture_unique_username() -> str: def test_create_admin_user_by_system(db: orm.Session): - user = users_crud.get_user_by_name(db, config.config.initial.admin) + user = users_crud.get_user_by_name(db, config.initial.admin) assert user is not None events: list[events_models.DatabaseUserHistoryEvent] = ( diff --git a/backend/tests/test_feedback.py b/backend/tests/test_feedback.py index 60d6a211ed..92c72211d6 100644 --- a/backend/tests/test_feedback.py +++ b/backend/tests/test_feedback.py @@ -8,12 +8,12 @@ from fastapi import testclient from sqlalchemy import orm -from capellacollab.config import config -from capellacollab.config import models as config_models +from capellacollab.configuration import crud as configuration_crud +from capellacollab.configuration.app import config +from capellacollab.configuration.app import models as config_models from capellacollab.feedback import crud as feedback_crud from capellacollab.feedback import metrics as feedback_metrics from capellacollab.feedback import models as feedback_models -from capellacollab.settings.configuration import crud as configuration_crud from capellacollab.users import models as users_models from capellacollab.users import routes as users_routes @@ -194,7 +194,7 @@ def test_feedback_is_updated( client: testclient.TestClient, ): response = client.put( - "/api/v1/settings/configurations/global", + "/api/v1/configurations/global", json={ "feedback": { "enabled": True, @@ -210,7 +210,7 @@ def test_feedback_is_updated( assert response.status_code == 200 - response = client.get("/api/v1/settings/configurations/unified") + response = client.get("/api/v1/configurations/unified") assert response.status_code == 200 assert response.json()["feedback"] == { "enabled": True, @@ -228,7 +228,7 @@ def test_activate_feedback_without_smtp( client: testclient.TestClient, ): response = client.put( - "/api/v1/settings/configurations/global", + "/api/v1/configurations/global", json={ "feedback": { "enabled": True, @@ -245,7 +245,7 @@ def test_activate_feedback_without_recipients( client: testclient.TestClient, ): response = client.put( - "/api/v1/settings/configurations/global", + "/api/v1/configurations/global", json={ "feedback": { "enabled": True, @@ -262,7 +262,7 @@ def test_activate_feedback_without_recipients( @pytest.mark.usefixtures("user", "smtp_config_not_set", "feedback_enabled") def test_feedback_is_disabled_without_smtp(client: testclient.TestClient): - response = client.get("/api/v1/settings/configurations/unified") + response = client.get("/api/v1/configurations/unified") assert response.status_code == 200 assert response.json()["feedback"]["enabled"] is False diff --git a/frontend/src/app/openapi/api/configuration.service.ts b/frontend/src/app/openapi/api/configuration.service.ts index 5d01ac8243..0d108462c4 100644 --- a/frontend/src/app/openapi/api/configuration.service.ts +++ b/frontend/src/app/openapi/api/configuration.service.ts @@ -151,7 +151,7 @@ export class ConfigurationService { } } - let localVarPath = `/api/v1/settings/configurations/global`; + let localVarPath = `/api/v1/configurations/global`; return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, @@ -211,7 +211,7 @@ export class ConfigurationService { } } - let localVarPath = `/api/v1/settings/configurations/global/schema`; + let localVarPath = `/api/v1/configurations/global/schema`; return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, @@ -237,13 +237,6 @@ export class ConfigurationService { let localVarHeaders = this.defaultHeaders; - let localVarCredential: string | undefined; - // authentication (PersonalAccessToken) required - localVarCredential = this.configuration.lookupCredential('PersonalAccessToken'); - if (localVarCredential) { - localVarHeaders = localVarHeaders.set('Authorization', 'Basic ' + localVarCredential); - } - let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; if (localVarHttpHeaderAcceptSelected === undefined) { // to determine the Accept header @@ -278,7 +271,7 @@ export class ConfigurationService { } } - let localVarPath = `/api/v1/settings/configurations/unified`; + let localVarPath = `/api/v1/configurations/unified`; return this.httpClient.request('get', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext, @@ -358,7 +351,7 @@ export class ConfigurationService { } } - let localVarPath = `/api/v1/settings/configurations/global`; + let localVarPath = `/api/v1/configurations/global`; return this.httpClient.request('put', `${this.configuration.basePath}${localVarPath}`, { context: localVarHttpContext,