Replaces LICENSE (GPLv3 -> AGPLv3) and prepends `SPDX-License-Identifier: AGPL-3.0-or-later` to every source file across decnet/, decnet_web/, tests/, scripts/, and tools/. Rationale: closes the GPLv3 ASP loophole so any party operating a modified DECNET as a network service must offer their modified source. Personal copyright (Samuel Paschuan) + inbound=outbound contributions make a future unilateral relicense infeasible. - LICENSE: full AGPL-3.0 text (gnu.org/licenses/agpl-3.0.txt) - COPYRIGHT: project copyright notice - tools/add_spdx_headers.py: idempotent header injector (shebang- and PEP 263-aware) Touches 1565 source files (.py, .ts, .tsx, .js, .jsx, .css, .sh). No behavior change; comments only.
43 lines
1.8 KiB
Python
43 lines
1.8 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
Shared pytest configuration.
|
|
|
|
Env vars required by decnet.env must be set here, at module level, before
|
|
any test file imports decnet.* — pytest loads conftest.py first.
|
|
"""
|
|
import os
|
|
import tempfile
|
|
|
|
# Redirect log paths to a user-writable tempdir so unprivileged test runs
|
|
# (CI, local sans-sudo) don't try to mkdir /var/log/decnet.
|
|
_TEST_LOG_DIR = os.path.join(tempfile.gettempdir(), "decnet-tests-logs")
|
|
os.makedirs(_TEST_LOG_DIR, exist_ok=True)
|
|
os.environ.setdefault("DECNET_LOG_FILE", os.path.join(_TEST_LOG_DIR, "decnet.log"))
|
|
os.environ.setdefault("DECNET_INGEST_LOG_FILE", os.path.join(_TEST_LOG_DIR, "decnet.log"))
|
|
os.environ.setdefault("DECNET_AGENT_LOG_FILE", os.path.join(_TEST_LOG_DIR, "agent.log"))
|
|
|
|
os.environ["DECNET_JWT_SECRET"] = "stable-test-secret-key-at-least-32-chars-long"
|
|
os.environ["DECNET_ADMIN_PASSWORD"] = "test-password-123"
|
|
os.environ["DECNET_DEVELOPER"] = "true"
|
|
os.environ["DECNET_DEVELOPER_TRACING"] = "false"
|
|
os.environ["DECNET_DB_TYPE"] = "sqlite"
|
|
|
|
# GeoIP enrichment is offline-by-design (RIR delegated-stats) but the
|
|
# first access triggers a background file fetch. Unit tests must never
|
|
# hit the network and don't care about country codes — disable
|
|
# enrichment globally. The geoip-specific tests re-enable it via
|
|
# monkeypatch + a temp DECNET_GEOIP_ROOT.
|
|
os.environ["DECNET_GEOIP_ENABLED"] = "false"
|
|
# Same posture for PTR resolution — tests that cover the resolver
|
|
# re-enable it explicitly via monkeypatch; everyone else gets the
|
|
# short-circuit (returns None without touching socket.gethostbyaddr).
|
|
os.environ["DECNET_PTR_ENABLED"] = "false"
|
|
|
|
import pytest
|
|
from typing import Any
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def standardize_auth_secret(monkeypatch: Any) -> None:
|
|
import decnet.web.auth
|
|
monkeypatch.setattr(decnet.web.auth, "SECRET_KEY", os.environ["DECNET_JWT_SECRET"])
|