feat: FB_GRAFANA_PUBLIC_URL + FB_SESSION_COOKIE_SECURE in Settings
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from app.config import get_settings
|
||||
|
||||
|
||||
@@ -35,3 +37,43 @@ def test_grafana_url_default(monkeypatch):
|
||||
assert get_settings().grafana_url == "http://localhost:3000"
|
||||
finally:
|
||||
get_settings.cache_clear()
|
||||
|
||||
|
||||
def test_grafana_public_url_default(monkeypatch):
|
||||
monkeypatch.delenv("FB_GRAFANA_PUBLIC_URL", raising=False)
|
||||
get_settings.cache_clear()
|
||||
try:
|
||||
assert get_settings().grafana_public_url == ""
|
||||
finally:
|
||||
get_settings.cache_clear()
|
||||
|
||||
|
||||
def test_grafana_public_url_from_env(monkeypatch):
|
||||
monkeypatch.setenv("FB_GRAFANA_PUBLIC_URL", "https://fb.example.de/grafana/")
|
||||
get_settings.cache_clear()
|
||||
try:
|
||||
assert get_settings().grafana_public_url == "https://fb.example.de/grafana/"
|
||||
finally:
|
||||
get_settings.cache_clear()
|
||||
|
||||
|
||||
def test_session_cookie_secure_default_false(monkeypatch):
|
||||
monkeypatch.delenv("FB_SESSION_COOKIE_SECURE", raising=False)
|
||||
get_settings.cache_clear()
|
||||
try:
|
||||
assert get_settings().session_cookie_secure is False
|
||||
finally:
|
||||
get_settings.cache_clear()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("val,expected", [
|
||||
("true", True), ("True", True), ("1", True), ("yes", True), ("on", True),
|
||||
("false", False), ("0", False), ("", False), ("nope", False),
|
||||
])
|
||||
def test_session_cookie_secure_parsing(monkeypatch, val, expected):
|
||||
monkeypatch.setenv("FB_SESSION_COOKIE_SECURE", val)
|
||||
get_settings.cache_clear()
|
||||
try:
|
||||
assert get_settings().session_cookie_secure is expected
|
||||
finally:
|
||||
get_settings.cache_clear()
|
||||
|
||||
Reference in New Issue
Block a user