Files
bambuddy/backend/tests/unit/test_oidc_env_provider.py
T
Marian e3cada51ac feat(oidc): add is_env_managed column to oidc_providers
Marks the single provider that BAMBUDDY_OIDC_* environment variables define,
so a later change can upsert it on startup and refuse UI/API writes to it. The
row is never delete-recreated: user_oidc_links.provider_id is FK ON DELETE
CASCADE, so dropping the provider would take every account link with it.

The migration carries its own test rather than relying on the model test. A
table created from metadata already has the column, so that path never
exercises the ALTER; an installed instance gets it only through
run_migrations, and that is the path an upgrade actually takes. Covered:
the column appears on a pre-existing table, rows created before the upgrade
read as not env-managed, and re-running is a no-op because every boot replays
the whole migration set.

Refs #2593
2026-07-28 21:05:29 +00:00

13 lines
364 B
Python

import pytest
from backend.app.models.oidc_provider import OIDCProvider
@pytest.mark.asyncio
async def test_is_env_managed_defaults_false(db_session):
p = OIDCProvider(name="x", issuer_url="https://i", client_id="c", client_secret="s")
db_session.add(p)
await db_session.commit()
await db_session.refresh(p)
assert p.is_env_managed is False