Server: basic implementation. Not tested => no python installed; bugfix in ESP (uvicorn on port 8090)

This commit is contained in:
Thomas Karner committed 2026-09-20 23:49:40 +02:00
1 parent 3694cdf207
commit 8a51e3d95e
38 files changed
+2442 -21

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
from __future__ import annotations
from poorbird.config import Settings
def test_every_setting_reads_from_the_environment(monkeypatch):
"""Phase 1.2: no path, host or secret may be baked into code."""
monkeypatch.setenv("POORBIRD_DATABASE_URL", "postgresql+psycopg://u:p@10.0.0.5:5432/db")
monkeypatch.setenv("POORBIRD_IMAGE_ROOT", "/mnt/elsewhere/images")
monkeypatch.setenv("POORBIRD_API_PORT", "9999")
monkeypatch.setenv("POORBIRD_ENROLL_SECRET", "deadbeef")
s = Settings(_env_file=None)
assert s.database_url.endswith("@10.0.0.5:5432/db")
assert str(s.image_root).endswith("images")
assert s.api_port == 9999
assert s.enroll_secret_is_set
def test_database_url_is_tcp_not_a_unix_socket():
"""A Unix socket is the one genuinely container-hostile choice."""
s = Settings(_env_file=None)
assert "@" in s.database_url and ":" in s.database_url.rpartition("@")[2]
assert "/var/run/postgresql" not in s.database_url
def test_enroll_secret_is_not_leaked_by_repr():
s = Settings(_env_file=None, enroll_secret="hunter2")
assert "hunter2" not in repr(s)