Unmapped ohne Kreuzjoin, Listen-GET kurz, Rebuild im Hintergrund. Tandoor-Zugang (URL/Token) in den Einstellungen mit ausliefern. Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
from data_layer.tandoor_client import TandoorError, normalize_base_url, public_settings, token_hint
|
|
|
|
|
|
def test_normalize_https_strips_slash():
|
|
assert normalize_base_url("https://tandoor.stommer.de/") == "https://tandoor.stommer.de"
|
|
|
|
|
|
def test_normalize_rejects_empty_and_bare_host():
|
|
try:
|
|
normalize_base_url(" ")
|
|
except TandoorError as e:
|
|
assert "fehlt" in str(e)
|
|
else:
|
|
raise AssertionError("expected TandoorError")
|
|
try:
|
|
normalize_base_url("tandoor.stommer.de")
|
|
except TandoorError:
|
|
pass
|
|
else:
|
|
raise AssertionError("expected TandoorError")
|
|
|
|
|
|
def test_normalize_rejects_public_http():
|
|
try:
|
|
normalize_base_url("http://tandoor.stommer.de")
|
|
except TandoorError as e:
|
|
assert "https" in str(e)
|
|
else:
|
|
raise AssertionError("expected TandoorError")
|
|
|
|
|
|
def test_token_hint_never_full():
|
|
assert token_hint("abcdefghijklmnop") == "…mnop"
|
|
assert "abcd" not in (token_hint("secret-token-value") or "")
|
|
assert public_settings(None)["token_set"] is False
|
|
pub = public_settings({"base_url": "https://tandoor.example", "api_token": "super-secret-token"})
|
|
assert pub["token_set"] is True
|
|
assert pub["token_hint"] == "…oken"
|
|
assert "super" not in (pub["token_hint"] or "")
|
|
assert "api_token" not in pub
|