mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-22 03:49:18 +02:00
fix(oidc): treat a blank optional env var as unset, not a refusal
BAMBUDDY_OIDC_SCOPES, _EMAIL_CLAIM and _ICON_URL fell back to their default only when the key was absent, so `BAMBUDDY_OIDC_ICON_URL=` in a compose file (as .env.example ships it, commented) reached the schema validator as an empty string and got the whole provider refused. default_group already treated blank as unset; these three now follow the same rule.
This commit is contained in:
@@ -547,6 +547,41 @@ async def test_an_empty_group_variable_counts_as_unset(db_session, monkeypatch):
|
||||
assert provider.default_group_id is None
|
||||
|
||||
|
||||
# --- blank optional strings count as unset, not a refusal ---------------------
|
||||
# `.env.example` ships `# BAMBUDDY_OIDC_ICON_URL=` commented out, so uncommenting
|
||||
# it must not take the provider down -- same rule default_group already follows.
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_blank_scopes_still_creates_the_provider(db_session, monkeypatch):
|
||||
_configure(monkeypatch, BAMBUDDY_OIDC_SCOPES="")
|
||||
await apply_env_oidc_provider(db_session)
|
||||
|
||||
provider = await _env_provider(db_session)
|
||||
assert provider is not None, "a blank optional var must not refuse the whole provider"
|
||||
assert provider.scopes == "openid email profile"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_blank_email_claim_still_creates_the_provider(db_session, monkeypatch):
|
||||
_configure(monkeypatch, BAMBUDDY_OIDC_EMAIL_CLAIM="")
|
||||
await apply_env_oidc_provider(db_session)
|
||||
|
||||
provider = await _env_provider(db_session)
|
||||
assert provider is not None, "a blank optional var must not refuse the whole provider"
|
||||
assert provider.email_claim == "email"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_blank_icon_url_still_creates_the_provider(db_session, monkeypatch):
|
||||
_configure(monkeypatch, BAMBUDDY_OIDC_ICON_URL="")
|
||||
await apply_env_oidc_provider(db_session)
|
||||
|
||||
provider = await _env_provider(db_session)
|
||||
assert provider is not None, "a blank optional var must not refuse the whole provider"
|
||||
assert provider.icon_url is None
|
||||
|
||||
|
||||
# --- account links and collision behavior ------------------------------------
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user