Run backend and web with a shared configurable port, add local webhook and secret-generation helpers with tests, and document current app-auth and fixture workflows.
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
import re
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
SCRIPT = Path(__file__).resolve().parents[1] / "scripts" / "generate_secret.py"
|
|
|
|
|
|
def run_script(*args: str) -> subprocess.CompletedProcess[str]:
|
|
return subprocess.run(
|
|
[sys.executable, str(SCRIPT), *args], capture_output=True, text=True, check=False
|
|
)
|
|
|
|
|
|
def test_generates_named_secret():
|
|
name = "LEAD_SCORING_WEBHOOK_SIGNING_SECRET"
|
|
first = run_script(name)
|
|
second = run_script(name)
|
|
assert first.returncode == second.returncode == 0
|
|
assert first.stderr == second.stderr == ""
|
|
for result in (first, second):
|
|
assert re.fullmatch(rf"{name}=[0-9a-f]{{64}}\n", result.stdout)
|
|
assert first.stdout != second.stdout
|
|
|
|
|
|
@pytest.mark.parametrize("name", ["", "1SECRET", "SECRET=value", "BAD-NAME", "A\nB"])
|
|
def test_rejects_invalid_variable_names(name: str):
|
|
result = run_script(name)
|
|
assert result.returncode == 2
|
|
assert result.stdout == ""
|
|
|
|
|
|
def test_requires_variable_name():
|
|
result = run_script()
|
|
assert result.returncode == 2
|
|
assert result.stdout == ""
|