Skip to content

Commit 38430bc

Browse files
committed
drops webserver_enabled and cleanup tests
1 parent af3ed7e commit 38430bc

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

services/web/server/src/simcore_service_webserver/application_settings.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -280,15 +280,6 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
280280
WEBSERVER_REMOTE_DEBUG: bool = True
281281
WEBSERVER_SOCKETIO: bool = True
282282
WEBSERVER_TAGS: bool = True
283-
WEBSERVER_TRASH: Annotated[
284-
bool,
285-
Field(
286-
description="Currently only used to enable/disable front-end",
287-
validation_alias=AliasChoices(
288-
"WEBSERVER_TRASH", "WEBSERVER_DEV_FEATURES_ENABLED"
289-
),
290-
),
291-
] = False
292283
WEBSERVER_VERSION_CONTROL: bool = True
293284
WEBSERVER_WALLETS: bool = True
294285
WEBSERVER_WORKSPACES: bool = True
@@ -302,7 +293,7 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
302293

303294
@model_validator(mode="before")
304295
@classmethod
305-
def build_vcs_release_url_if_unset(cls, values):
296+
def _build_vcs_release_url_if_unset(cls, values):
306297
release_url = values.get("SIMCORE_VCS_RELEASE_URL")
307298

308299
if release_url is None and (
@@ -323,12 +314,11 @@ def build_vcs_release_url_if_unset(cls, values):
323314
# TODO: consider mark as dev-feature in field extras of Config attr.
324315
# Then they can be automtically advertised
325316
"WEBSERVER_META_MODELING",
326-
"WEBSERVER_TRASH",
327317
"WEBSERVER_VERSION_CONTROL",
328318
mode="before",
329319
)
330320
@classmethod
331-
def enable_only_if_dev_features_allowed(cls, v, info: ValidationInfo):
321+
def _enable_only_if_dev_features_allowed(cls, v, info: ValidationInfo):
332322
"""Ensures that plugins 'under development' get programatically
333323
disabled if WEBSERVER_DEV_FEATURES_ENABLED=False
334324
"""
@@ -345,19 +335,14 @@ def enable_only_if_dev_features_allowed(cls, v, info: ValidationInfo):
345335
else False
346336
)
347337

348-
@cached_property
349-
def log_level(self) -> int:
350-
level: int = getattr(logging, self.WEBSERVER_LOGLEVEL.upper())
351-
return level
352-
353338
@field_validator("WEBSERVER_LOGLEVEL")
354339
@classmethod
355-
def valid_log_level(cls, value):
340+
def _valid_log_level(cls, value):
356341
return cls.validate_log_level(value)
357342

358343
@field_validator("SC_HEALTHCHECK_TIMEOUT", mode="before")
359344
@classmethod
360-
def get_healthcheck_timeout_in_seconds(cls, v):
345+
def _get_healthcheck_timeout_in_seconds(cls, v):
361346
# Ex. HEALTHCHECK --interval=5m --timeout=3s
362347
if isinstance(v, str):
363348
factor = 1 # defaults on s
@@ -371,6 +356,11 @@ def get_healthcheck_timeout_in_seconds(cls, v):
371356

372357
# HELPERS --------------------------------------------------------
373358

359+
@cached_property
360+
def log_level(self) -> int:
361+
level: int = getattr(logging, self.WEBSERVER_LOGLEVEL.upper())
362+
return level
363+
374364
def is_enabled(self, field_name: str) -> bool:
375365
return bool(getattr(self, field_name, None))
376366

@@ -386,7 +376,6 @@ def _get_disabled_public_plugins(self) -> list[str]:
386376
"WEBSERVER_META_MODELING",
387377
"WEBSERVER_PAYMENTS",
388378
"WEBSERVER_SCICRUNCH",
389-
"WEBSERVER_TRASH",
390379
"WEBSERVER_VERSION_CONTROL",
391380
}
392381
return [_ for _ in public_plugin_candidates if not self.is_enabled(_)]

services/web/server/tests/unit/isolated/test_application_settings.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,16 @@ def test_settings_to_client_statics_plugins(
104104

105105

106106
@pytest.mark.parametrize("is_dev_feature_enabled", [True, False])
107-
def test_settings_to_client_statics_for_webserver_trash(
107+
@pytest.mark.parametrize(
108+
"plugin_name",
109+
["WEBSERVER_META_MODELING", "WEBSERVER_VERSION_CONTROL", "WEBSERVER_CLUSTERS"]
110+
# NOTE: this is the list in _enable_only_if_dev_features_allowed
111+
)
112+
def test_disabled_plugins_settings_to_client_statics(
108113
is_dev_feature_enabled: bool,
109114
mock_webserver_service_environment: EnvVarsDict,
110115
monkeypatch: pytest.MonkeyPatch,
116+
plugin_name: str,
111117
):
112118
monkeypatch.setenv(
113119
"WEBSERVER_DEV_FEATURES_ENABLED", f"{is_dev_feature_enabled}".lower()
@@ -116,10 +122,11 @@ def test_settings_to_client_statics_for_webserver_trash(
116122
settings = ApplicationSettings.create_from_envs()
117123
statics = settings.to_client_statics()
118124

125+
# checks whether it is shown to the front-end depending on the value of WEBSERVER_DEV_FEATURES_ENABLED
119126
if is_dev_feature_enabled:
120-
assert "WEBSERVER_TRASH" not in set(statics["pluginsDisabled"])
127+
assert plugin_name not in set(statics["pluginsDisabled"])
121128
else:
122-
assert "WEBSERVER_TRASH" in set(statics["pluginsDisabled"])
129+
assert plugin_name in set(statics["pluginsDisabled"])
123130

124131

125132
def test_avoid_sensitive_info_in_public(app_settings: ApplicationSettings):

0 commit comments

Comments
 (0)