mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-28 16:58:31 +01:00
Match docs/AUDIT_LOGGING.md to the shipped Audit Log panel filters (User, Event, Outcome, and page-local Verification), note that date-range filters and other event types use the API, point to Settings -> Security -> Audit Webhooks, and align verification badge labels with Check failed and Check error. Remove the stale pre-v6.9.0 HTTP 402 range-entitlement contradiction in docs/METRICS_HISTORY.md so Troubleshooting matches the free-on-every-plan handler (HTTP 400 for invalid or >365d ranges). Point docs/REVERSE_PROXY.md at Settings -> Security -> Security Overview and Settings -> System -> Network -> CORS Allowed Origins, and include the parent Settings groups in docs/AI.md, docs/MSP.md, and docs/PULSE_PRO.md for Settings -> Support -> Data & Reports and Settings -> System -> Plans & Billing. Sync all six shipped frontend-modern/public/docs mirrors and add source-bound regression tests in scripts/tests/. Contract-Neutral: Aligns in-app Help prose and doc tests with existing shipped UI routes, settings navigation, audit verification labels, and free metrics-history behavior with no runtime, API, or permission contract delta. Change-source: pulse-maintainer
85 lines
3.7 KiB
Python
85 lines
3.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Check the copyable HTTPS drop-in without installing or starting any unit."""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
import re
|
|
import shutil
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def https_drop_in():
|
|
guide = (ROOT / "docs/CONFIGURATION.md").read_text(encoding="utf-8")
|
|
_, _, section = guide.partition("### HTTPS with systemd\n")
|
|
section = section.split("\n### ", 1)[0]
|
|
matches = re.findall(r"^\x60\x60\x60ini\n(.*?)^\x60\x60\x60$", section, re.M | re.S)
|
|
if len(matches) != 1:
|
|
raise AssertionError("expected one copyable systemd HTTPS drop-in")
|
|
return matches[0]
|
|
|
|
|
|
class ServerHttpsDocsTest(unittest.TestCase):
|
|
def test_drop_in_contains_all_three_service_environment_assignments(self):
|
|
header, *assignments = https_drop_in().splitlines()
|
|
self.assertEqual(header, "[Service]")
|
|
variables = {}
|
|
for assignment in assignments:
|
|
match = re.fullmatch(r'Environment="([A-Z_]+)=([^"]+)"', assignment)
|
|
self.assertIsNotNone(match, assignment)
|
|
name, value = match.groups()
|
|
self.assertNotIn(name, variables)
|
|
variables[name] = value
|
|
self.assertEqual(set(variables), {"HTTPS_ENABLED", "TLS_CERT_FILE", "TLS_KEY_FILE"})
|
|
self.assertEqual(variables["HTTPS_ENABLED"], "true")
|
|
for key in ("TLS_CERT_FILE", "TLS_KEY_FILE"):
|
|
self.assertTrue(Path(variables[key]).is_absolute(), variables[key])
|
|
|
|
@unittest.skipUnless(shutil.which("systemd-analyze"), "systemd parser unavailable")
|
|
def test_systemd_accepts_the_example_as_a_drop_in(self):
|
|
with tempfile.TemporaryDirectory(prefix="pulse-https-docs-") as directory:
|
|
root = Path(directory)
|
|
unit = root / "pulse-https-example.service"
|
|
unit.write_text(
|
|
"[Unit]\nDefaultDependencies=no\n[Service]\nExecStart=/bin/true\n",
|
|
encoding="utf-8",
|
|
)
|
|
drop_ins = root / (unit.name + ".d")
|
|
drop_ins.mkdir()
|
|
(drop_ins / "override.conf").write_text(https_drop_in(), encoding="utf-8")
|
|
result = subprocess.run(
|
|
["systemd-analyze", "verify", "--man=no", "--generators=no", str(unit)],
|
|
env={**os.environ, "SYSTEMD_UNIT_PATH": directory},
|
|
capture_output=True, text=True, timeout=10,
|
|
)
|
|
self.assertEqual(result.returncode, 0, result.stderr)
|
|
self.assertEqual(result.stderr, "", result.stderr)
|
|
|
|
def test_reverse_proxy_help_matches_security_overview_and_cors_labels(self):
|
|
canonical = ROOT / "docs/REVERSE_PROXY.md"
|
|
shipped = ROOT / "frontend-modern/public/docs/REVERSE_PROXY.md"
|
|
self.assertEqual(canonical.read_bytes(), shipped.read_bytes())
|
|
text = " ".join(canonical.read_text(encoding="utf-8").split())
|
|
self.assertIn(
|
|
"**Security Posture** card under **Settings → Security → Security Overview** (`/settings/security-overview`) shows **HTTPS** as **HTTP only**",
|
|
text,
|
|
)
|
|
self.assertIn(
|
|
"**Settings → System → Network → CORS Allowed Origins** (`/settings/system-network`)",
|
|
text,
|
|
)
|
|
self.assertNotIn("Settings → System → Network → Allowed Origins", text)
|
|
posture = (ROOT / "frontend-modern/src/utils/securityScorePresentation.ts").read_text(encoding="utf-8")
|
|
self.assertIn("label: 'HTTPS'", posture)
|
|
self.assertIn("'HTTP only'", posture)
|
|
network = (ROOT / "frontend-modern/src/components/Settings/NetworkBoundarySettingsSection.tsx").read_text(encoding="utf-8")
|
|
self.assertIn("CORS Allowed Origins", network)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|