From b5755df6498146374d9c5203e84b9e2498f0d57d Mon Sep 17 00:00:00 2001 From: Pedro Crespo-Valero <32402063+pcrespov@users.noreply.github.com> Date: Wed, 27 Nov 2024 11:30:57 +0100 Subject: [PATCH 1/2] adds webserver trash --- .../application_settings.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/services/web/server/src/simcore_service_webserver/application_settings.py b/services/web/server/src/simcore_service_webserver/application_settings.py index 67b1b32696d..0663c9a49e3 100644 --- a/services/web/server/src/simcore_service_webserver/application_settings.py +++ b/services/web/server/src/simcore_service_webserver/application_settings.py @@ -271,18 +271,27 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings): WEBSERVER_CLUSTERS: bool = False WEBSERVER_DB_LISTENER: bool = True WEBSERVER_FOLDERS: bool = True - WEBSERVER_WORKSPACES: bool = True WEBSERVER_GROUPS: bool = True WEBSERVER_META_MODELING: bool = True WEBSERVER_NOTIFICATIONS: bool = Field(default=True) WEBSERVER_PRODUCTS: bool = True + WEBSERVER_PROFILING: bool = False WEBSERVER_PUBLICATIONS: bool = True WEBSERVER_REMOTE_DEBUG: bool = True WEBSERVER_SOCKETIO: bool = True WEBSERVER_TAGS: bool = True + WEBSERVER_TRASH: Annotated[ + bool, + Field( + description="Currently only used to enable/disable front-end", + validation_alias=AliasChoices( + "WEBSERVER_TRASH", "WEBSERVER_DEV_FEATURES_ENABLED" + ), + ), + ] = False WEBSERVER_VERSION_CONTROL: bool = True WEBSERVER_WALLETS: bool = True - WEBSERVER_PROFILING: bool = False + WEBSERVER_WORKSPACES: bool = True # WEBSERVER_SECURITY: bool = Field( @@ -376,6 +385,7 @@ def _get_disabled_public_plugins(self) -> list[str]: "WEBSERVER_META_MODELING", "WEBSERVER_PAYMENTS", "WEBSERVER_SCICRUNCH", + "WEBSERVER_TRASH", "WEBSERVER_VERSION_CONTROL", } return [_ for _ in public_plugin_candidates if not self.is_enabled(_)] From 5e1d30252e0e210cf3672ccd80c16c83738fbaaf Mon Sep 17 00:00:00 2001 From: Pedro Crespo-Valero <32402063+pcrespov@users.noreply.github.com> Date: Wed, 27 Nov 2024 12:27:28 +0100 Subject: [PATCH 2/2] adds tests --- .../application_settings.py | 1 + .../isolated/test_application_settings.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/services/web/server/src/simcore_service_webserver/application_settings.py b/services/web/server/src/simcore_service_webserver/application_settings.py index 0663c9a49e3..511554e185e 100644 --- a/services/web/server/src/simcore_service_webserver/application_settings.py +++ b/services/web/server/src/simcore_service_webserver/application_settings.py @@ -323,6 +323,7 @@ def build_vcs_release_url_if_unset(cls, values): # TODO: consider mark as dev-feature in field extras of Config attr. # Then they can be automtically advertised "WEBSERVER_META_MODELING", + "WEBSERVER_TRASH", "WEBSERVER_VERSION_CONTROL", mode="before", ) diff --git a/services/web/server/tests/unit/isolated/test_application_settings.py b/services/web/server/tests/unit/isolated/test_application_settings.py index 84c8ee46871..43f4a366197 100644 --- a/services/web/server/tests/unit/isolated/test_application_settings.py +++ b/services/web/server/tests/unit/isolated/test_application_settings.py @@ -103,6 +103,25 @@ def test_settings_to_client_statics_plugins( assert set(statics["pluginsDisabled"]) == (disable_plugins | {"WEBSERVER_CLUSTERS"}) +@pytest.mark.parametrize("is_dev_feature_enabled", [True, False]) +def test_settings_to_client_statics_for_webserver_trash( + is_dev_feature_enabled: bool, + mock_webserver_service_environment: EnvVarsDict, + monkeypatch: pytest.MonkeyPatch, +): + monkeypatch.setenv( + "WEBSERVER_DEV_FEATURES_ENABLED", f"{is_dev_feature_enabled}".lower() + ) + + settings = ApplicationSettings.create_from_envs() + statics = settings.to_client_statics() + + if is_dev_feature_enabled: + assert "WEBSERVER_TRASH" not in set(statics["pluginsDisabled"]) + else: + assert "WEBSERVER_TRASH" in set(statics["pluginsDisabled"]) + + def test_avoid_sensitive_info_in_public(app_settings: ApplicationSettings): # avoids display of sensitive info assert not any("pass" in key for key in app_settings.public_dict())