Skip to content

Commit

Permalink
🎨 webserver's trash flag (#6850)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov authored Nov 27, 2024
1 parent 83a08e7 commit 4160ba3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -314,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",
)
Expand Down Expand Up @@ -376,6 +386,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(_)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 4160ba3

Please sign in to comment.