Mittwald-/Login-API: Weiterleitungen folgen (wie requests); nicht gefolgte 3xx-Antwort ist ein Fehler statt leerer Erfolg

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
RubenRWU
2026-10-15 16:19:01 +02:00
parent c45a6a0561
commit 8000f76457
3 changed files with 22 additions and 3 deletions

View File

@@ -492,3 +492,22 @@ def test_cortecs_key_from_admin_env_counts_as_set_and_reaches_the_container(clie
assert deploy.build_env(db, t, reveal=True)["CORTECS_API_KEY"] == "ck-aus-env"
assert "ck-aus-env" not in str(deploy.build_env(db, t, reveal=False))
assert "aus Admin-Env" in deploy.build_env(db, t, reveal=False)["CORTECS_API_KEY"]
def test_http_clients_follow_redirects_and_3xx_is_never_success(monkeypatch):
import httpx
from app.services import mittwald as mwmod, onyva_login
from app.services.mittwald import DeployError, Mittwald
seen = []
class R:
status_code, content, text = 200, b"[]", "[]"
def json(self): return []
monkeypatch.setattr(httpx, "request", lambda *a, **k: (seen.append(k), R())[1])
Mittwald._real_http("GET", "https://x/v2/stacks/", {}, None)
onyva_login.OnyvaLogin._real("GET", "https://x/api/v1/apps", {}, None)
assert all(k.get("follow_redirects") is True for k in seen) and len(seen) == 2
# Eine nicht gefolgte 308-Weiterleitung (leerer Body) ist ein Fehler, kein „null“
with pytest.raises(DeployError, match="308"):
Mittwald("t", "https://api.test/v2", False, lambda m: None, lambda *a: (308, None, "")).api("GET", "/projects/p/stacks/", write=False)