mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-07 23:01:06 +02:00
chore(config): register BAMBUDDY_OIDC_* in the typo-guard
Unknown BAMBUDDY_* vars log "possible typo" on every boot, so a correct OIDC config would have told its operator it was wrong, once per restart. The test asserts against the reader's own variable list rather than a copied one, so a thirteenth variable added later fails here instead of surfacing in somebody's logs. Refs #2593
This commit is contained in:
@@ -135,6 +135,20 @@ _INTENTIONAL_UNSETTINGS = {
|
||||
"LOG_DIR", # config.py (above)
|
||||
"LOG_LEVEL", # main.py logging setup
|
||||
"BUG_REPORT_RELAY_URL", # config.py (above)
|
||||
# #2593 — core/oidc_env.py reads these directly; they are not Settings
|
||||
# fields because they map to an OIDCProvider row, not to app config.
|
||||
"BAMBUDDY_OIDC_NAME",
|
||||
"BAMBUDDY_OIDC_ISSUER_URL",
|
||||
"BAMBUDDY_OIDC_CLIENT_ID",
|
||||
"BAMBUDDY_OIDC_CLIENT_SECRET",
|
||||
"BAMBUDDY_OIDC_SCOPES",
|
||||
"BAMBUDDY_OIDC_ENABLED",
|
||||
"BAMBUDDY_OIDC_AUTO_CREATE_USERS",
|
||||
"BAMBUDDY_OIDC_AUTO_LINK_EXISTING",
|
||||
"BAMBUDDY_OIDC_EMAIL_CLAIM",
|
||||
"BAMBUDDY_OIDC_REQUIRE_EMAIL_VERIFIED",
|
||||
"BAMBUDDY_OIDC_ICON_URL",
|
||||
"BAMBUDDY_OIDC_AUTOLOGIN",
|
||||
}
|
||||
|
||||
_known_settings_fields = {f.upper() for f in settings.model_fields}
|
||||
|
||||
@@ -116,3 +116,14 @@ def test_optional_strings_override_their_defaults(monkeypatch):
|
||||
assert cfg["scopes"] == "openid profile groups"
|
||||
assert cfg["email_claim"] == "mail"
|
||||
assert cfg["icon_url"] == "https://sso.example.com/logo.png"
|
||||
|
||||
|
||||
def test_every_var_the_reader_knows_is_registered_in_the_typo_guard():
|
||||
"""An unregistered BAMBUDDY_* var logs "possible typo" at every boot, which
|
||||
would tell operators their correct config is wrong. Asserted against the
|
||||
reader's own vars rather than a copied list, so a var added later is caught
|
||||
here instead of in someone's logs."""
|
||||
from backend.app.core.config import _INTENTIONAL_UNSETTINGS
|
||||
|
||||
unregistered = {v for v in (*REQUIRED, *OPTIONAL) if v not in _INTENTIONAL_UNSETTINGS}
|
||||
assert not unregistered
|
||||
|
||||
Reference in New Issue
Block a user