New repo for the Packet Station rebuild (Python 3.12, FastAPI, PostgreSQL 16, React, VisualKit, MFilesKit, Docker Compose on docker-1). Nothing is migrated from the M: install. - CLAUDE.md with the safety rules, README, CHANGELOG, docs (BRIEF, PLAN, SECURITY rewritten for the server with the requirement ID table, DEPLOY, stubs for FEED, POLICY, SCHEMA, GO-LIVE, PAPER-FALLBACK). - packetstation CLI: app, worker (heartbeat stub), migrate, doctor, version, healthcheck. Settings from the environment with secret files. Stack guard (test never points at VISUAL production). Security headers and CSP. Trusted proxy resolved by name. JSON logs with redaction. - Migration runner and 0001_base: settings, append-only audit_events with hash chain, ps_notify, grants for ps_app. - Multi-stage Dockerfile (ODBC Driver 18, PESCO libraries from the Gitea index only), compose base, proxy overlay for npm_default, CI overlay, postgres initdb roles, env examples, NPM proxy host notes, Gitea Actions. - Frontend: Vite, React, TypeScript, the PESCO dark theme ported with self-hosted fonts, placeholder sign-in and home. - Verified on docker-1: image builds, CI stack comes up healthy, doctor database checks pass, 77 server tests pass against PostgreSQL. Co-Authored-By: Claude Fable 5.1 <[email protected]>
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
"""Shared test setup: a clean environment with STACK=ci and no .env files picked up."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from collections.abc import Iterator
|
|
|
|
import pytest
|
|
|
|
_PREFIXES = ("PS_", "PG_", "LDAP_", "SMTP_", "VISUAL_", "MFILES_")
|
|
_NAMES = {
|
|
"STACK",
|
|
"SITE_ID",
|
|
"SITE_TZ",
|
|
"PUBLIC_URL",
|
|
"TRUSTED_PROXY_HOST",
|
|
"ASSETS_DIR",
|
|
"BACKUP_DIR",
|
|
"SESSION_KEY_FILE",
|
|
"SEAL_KEY_FILE",
|
|
"STATIC_DIR",
|
|
"LOG_LEVEL",
|
|
"NOTIFY_DRY_RUN",
|
|
"WORKER_BEAT_FILE",
|
|
}
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def clean_env(monkeypatch: pytest.MonkeyPatch, tmp_path_factory: pytest.TempPathFactory) -> Iterator[None]:
|
|
for key in list(os.environ):
|
|
if key.upper() in _NAMES or key.upper().startswith(_PREFIXES):
|
|
monkeypatch.delenv(key, raising=False)
|
|
nowhere = tmp_path_factory.getbasetemp() / "no-such.env"
|
|
monkeypatch.setenv("VISUAL_ENV_FILE", str(nowhere))
|
|
monkeypatch.setenv("MFILES_ENV_FILE", str(nowhere))
|
|
monkeypatch.setenv("STACK", "ci")
|
|
monkeypatch.setenv("TRUSTED_PROXY_HOST", "")
|
|
from packetstation.settings import clear_settings_cache
|
|
|
|
clear_settings_cache()
|
|
yield
|
|
clear_settings_cache()
|