50 lines
2.1 KiB
Python
50 lines
2.1 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from pytest import MonkeyPatch
|
||
|
|
|
||
|
|
from core.config.settings import Settings
|
||
|
|
|
||
|
|
|
||
|
|
def test_social_prefixed_supabase_env_populates_settings(
|
||
|
|
monkeypatch: MonkeyPatch,
|
||
|
|
) -> None:
|
||
|
|
monkeypatch.setenv("SOCIAL_SUPABASE__PUBLIC_SCHEME", "https")
|
||
|
|
monkeypatch.setenv("SOCIAL_SUPABASE__PUBLIC_HOST", "public.example")
|
||
|
|
monkeypatch.setenv("SOCIAL_SUPABASE__KONG_HTTP_PORT", "8443")
|
||
|
|
monkeypatch.setenv("SOCIAL_SUPABASE__ANON_KEY", "anon-key")
|
||
|
|
monkeypatch.setenv("SOCIAL_SUPABASE__SERVICE_ROLE_KEY", "service-key")
|
||
|
|
monkeypatch.setenv("SOCIAL_SUPABASE__JWT_SECRET", "jwt-secret")
|
||
|
|
monkeypatch.setenv("SOCIAL_DATABASE__HOST", "db")
|
||
|
|
monkeypatch.setenv("SOCIAL_DATABASE__PORT", "5432")
|
||
|
|
monkeypatch.setenv("SOCIAL_DATABASE__NAME", "app")
|
||
|
|
monkeypatch.setenv("SOCIAL_DATABASE__USER", "user")
|
||
|
|
monkeypatch.setenv("SOCIAL_DATABASE__PASSWORD", "pass")
|
||
|
|
|
||
|
|
settings = Settings()
|
||
|
|
|
||
|
|
assert settings.supabase.public_url == "https://public.example:8443"
|
||
|
|
assert settings.supabase.api_external_url == "https://public.example:8443"
|
||
|
|
assert settings.supabase.anon_key == "anon-key"
|
||
|
|
assert settings.supabase.service_role_key == "service-key"
|
||
|
|
assert settings.supabase.jwt_secret == "jwt-secret"
|
||
|
|
|
||
|
|
supabase_settings = settings.model_dump()["supabase"]
|
||
|
|
assert supabase_settings["public_url"] == "https://public.example:8443"
|
||
|
|
assert supabase_settings["api_external_url"] == "https://public.example:8443"
|
||
|
|
assert supabase_settings["anon_key"] == "anon-key"
|
||
|
|
assert supabase_settings["service_role_key"] == "service-key"
|
||
|
|
assert supabase_settings["jwt_secret"] == "jwt-secret"
|
||
|
|
assert settings.database_url == "postgresql+asyncpg://user:pass@db:5432/app"
|
||
|
|
|
||
|
|
|
||
|
|
def test_social_prefixed_api_external_url_is_loaded(
|
||
|
|
monkeypatch: MonkeyPatch,
|
||
|
|
) -> None:
|
||
|
|
monkeypatch.setenv("SOCIAL_SUPABASE__PUBLIC_SCHEME", "https")
|
||
|
|
monkeypatch.setenv("SOCIAL_SUPABASE__PUBLIC_HOST", "api.example")
|
||
|
|
monkeypatch.setenv("SOCIAL_SUPABASE__KONG_HTTP_PORT", "8443")
|
||
|
|
|
||
|
|
settings = Settings()
|
||
|
|
|
||
|
|
assert settings.supabase.api_external_url == "https://api.example:8443"
|