refactor: form-core wiring, JWT sessions, slowapi, packaging, frontend rewrite, test declutter
This commit is contained in:
parent
06ab25fb47
commit
03af41e837
74 changed files with 6089 additions and 5183 deletions
|
|
@ -3,6 +3,8 @@
|
|||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent.parent
|
||||
sys.path.insert(0, str(REPO_ROOT / "backend" / "scripts"))
|
||||
|
||||
|
|
@ -12,6 +14,7 @@ from check_prod import check
|
|||
def _good() -> dict:
|
||||
return {
|
||||
"CALLBACK_TOKEN": "t" * 40,
|
||||
"JWT_SECRET": "j" * 40,
|
||||
"LANGFLOW_API_KEY": "k" * 24,
|
||||
"LFX_API_KEY": "x" * 24,
|
||||
"LANGFLOW_SUPERUSER_PASSWORD": "p" * 20,
|
||||
|
|
@ -31,33 +34,28 @@ def test_good_env_passes_without_warnings():
|
|||
assert warnings == []
|
||||
|
||||
|
||||
def test_empty_and_short_secrets_fail():
|
||||
@pytest.mark.parametrize(
|
||||
("key", "bad_value"),
|
||||
[
|
||||
("CALLBACK_TOKEN", ""),
|
||||
("JWT_SECRET", ""),
|
||||
("CALLBACK_TOKEN", "t" * 10),
|
||||
("JWT_SECRET", "j" * 10),
|
||||
("LANGFLOW_SUPERUSER_PASSWORD", "short"),
|
||||
("LANGFLOW_SECRET_KEY", "s" * 10),
|
||||
("LANGFLOW_API_KEY", "sk-"),
|
||||
("LFX_API_KEY", "lfx-abc"),
|
||||
("FRONTEND_MODE", "dev"),
|
||||
("APP_ENV", "dev"),
|
||||
("LANGFLOW_AUTO_LOGIN", "true"),
|
||||
],
|
||||
)
|
||||
def test_bad_values_fail(key, bad_value):
|
||||
values = _good()
|
||||
values["CALLBACK_TOKEN"] = ""
|
||||
values["LANGFLOW_SUPERUSER_PASSWORD"] = "short"
|
||||
values[key] = bad_value
|
||||
failures, _ = check(values)
|
||||
assert any("CALLBACK_TOKEN" in f for f in failures)
|
||||
assert any("LANGFLOW_SUPERUSER_PASSWORD" in f for f in failures)
|
||||
|
||||
|
||||
def test_placeholders_fail():
|
||||
values = _good()
|
||||
values["LANGFLOW_API_KEY"] = "sk-"
|
||||
values["LFX_API_KEY"] = "lfx-abc"
|
||||
failures, _ = check(values)
|
||||
assert any("LANGFLOW_API_KEY" in f for f in failures)
|
||||
assert any("LFX_API_KEY" in f for f in failures)
|
||||
|
||||
|
||||
def test_insecure_modes_fail():
|
||||
values = _good()
|
||||
values["FRONTEND_MODE"] = "dev"
|
||||
values["APP_ENV"] = "dev"
|
||||
values["LANGFLOW_AUTO_LOGIN"] = "true"
|
||||
failures, _ = check(values)
|
||||
assert len([f for f in failures if "FRONTEND_MODE" in f]) == 1
|
||||
assert len([f for f in failures if "APP_ENV" in f]) == 1
|
||||
assert len([f for f in failures if "AUTO_LOGIN" in f]) == 1
|
||||
wanted = "AUTO_LOGIN" if key == "LANGFLOW_AUTO_LOGIN" else key
|
||||
assert any(wanted in f for f in failures), failures
|
||||
|
||||
|
||||
def test_soft_misconfigurations_warn_only():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue