Files
Pulse/scripts/tests/test_msp_connection_docs.py
pulse-triage[bot] 7cbb774059 Align Audit, History, Reverse Proxy, Reporting, and Plans Help with UI
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
2026-11-26 23:33:23 +00:00

119 lines
6.2 KiB
Python

#!/usr/bin/env python3
"""Keep provider connection help within the chosen network and access boundary.
Source/document consistency only: no setup script, provider call, ACL or guest
operation is executed. The normal documentation shards discover this suite.
"""
from pathlib import Path
import re
import unittest
ROOT = Path(__file__).resolve().parents[2]
HEADING = "## Connecting a client's Proxmox or PBS over your VPN\n"
def connection_help():
text = (ROOT / "docs/MSP.md").read_text(encoding="utf-8")
return text.split(HEADING, 1)[1].split("\n## ", 1)[0]
class MSPConnectionDocsTest(unittest.TestCase):
def test_host_connectivity_is_not_runtime_or_collection_acceptance(self):
text = " ".join(connection_help().split())
for distinction in (
"client workspace's Pulse runtime", "only a preliminary check",
"different routes, DNS and certificate trust",
"neither authenticated collection nor access to every cluster member",
"do not expose it publicly", "ordinary polling for each intended member",
"primary is not proof that all members or optional checks work",
"unavailable readings distinct from measured zero",
):
with self.subTest(distinction=distinction):
self.assertIn(distinction, text)
def test_first_seen_pin_is_not_independent_server_authentication(self):
text = " ".join(connection_help().split())
for boundary in (
"independently trusted client console", "**runtime** needs",
"matching endpoint hostname", "independently verified SHA-256",
"first-seen pinning does not independently authenticate the server",
"solely from the failing connection", "copy one member's pin",
"disable verification",
):
with self.subTest(boundary=boundary):
self.assertIn(boundary, text)
self.assertNotIn("Self-signed certificates are handled automatically", text)
# The docs rest on one rule: the pin is whatever certificate the
# answering candidate presented, so it is first-seen, not independently
# verified. Check that relationship rather than an exact return line;
# TestInstallGrantAutoRegisterStillSelectsReachableFallback covers it
# at runtime.
source = (ROOT / "internal/api/configapi/config_setup_handlers.go").read_text()
selection = source.split("func selectAutoRegisterHost(", 1)[1].split("\nfunc ", 1)[0]
self.assertRegex(selection, r"fingerprint, err := fetchTLSFingerprint\(candidate\)")
self.assertRegex(selection, r"return candidate, fingerprint, true\b")
def test_generated_root_acls_and_optional_reads_are_not_required_baseline(self):
text = " ".join(connection_help().split())
for boundary in (
"`PVEAuditor` provides baseline inventory and metrics",
"intersection of the user and token permissions",
"Keep privilege separation enabled", "do not modify the built-in role",
"administrative change, not a read-only test", "ACLs at `/`",
"`VM.GuestAgent.Audit`", "`VM.GuestAgent.FileRead`", "`VM.Monitor`",
"existing deliberately scoped token can be entered directly",
"never a command line or public report", "Do not rerun setup",
"remain unavailable without granting more access",
):
with self.subTest(boundary=boundary):
self.assertIn(boundary, text)
self.assertNotIn("`PVEAuditor` role is not sufficient on its own", text)
source = (ROOT / "internal/api/configapi/setup_script_render.go").read_text()
for marker in (
"pveum aclmod / -user pulse-monitor@pve -role PVEAuditor",
'pveum aclmod / -token "$PULSE_TOKEN_ID" -role PulseMonitor',
'EXTRA_PRIVS+=("VM.GuestAgent.Audit")',
'EXTRA_PRIVS+=("VM.Monitor")',
):
self.assertIn(marker, source)
self.assertNotIn("VM.GuestAgent.FileRead", source)
def test_existing_help_targets_safety_and_shipped_copy_remain_usable(self):
section = connection_help()
text = " ".join(section.split())
self.assertIn("defer setup, live tests and guest-agent probes", text)
self.assertIn("this connection workflow is not guest recovery", text)
self.assertNotIn("```", section, "reuse existing guidance, not a new secret-bearing command")
links = re.findall(r"\]\(([A-Z_]+\.md)#([a-z0-9-]+)\)", section)
self.assertGreaterEqual(len(links), 4)
for name, anchor in links:
target = (ROOT / "docs" / name).read_text(encoding="utf-8")
headings = re.findall(r"^#+ (.+)$", target, re.MULTILINE)
anchors = [re.sub(r"[^\w -]", "", h).strip().lower().replace(" ", "-") for h in headings]
with self.subTest(link=f"{name}#{anchor}"):
self.assertIn(anchor, anchors)
self.assertEqual(
(ROOT / "docs/MSP.md").read_bytes(),
(ROOT / "frontend-modern/public/docs/MSP.md").read_bytes(),
)
def test_reporting_help_uses_support_settings_group_in_msp_and_ai_guides(self):
for name in ("MSP", "AI"):
with self.subTest(guide=name):
canonical = ROOT / f"docs/{name}.md"
shipped = ROOT / f"frontend-modern/public/docs/{name}.md"
self.assertEqual(canonical.read_bytes(), shipped.read_bytes())
text = " ".join(canonical.read_text(encoding="utf-8").split())
self.assertIn("**Settings → Support → Data & Reports** (`/settings/support/reporting`)", text)
self.assertNotIn("Settings → Data & Reports", text)
catalog = (ROOT / "frontend-modern/src/components/Settings/settingsNavCatalog.ts").read_text(encoding="utf-8")
self.assertIn("id: 'support-reporting'", catalog)
self.assertIn("label: 'Data & Reports'", catalog)
nav = (ROOT / "frontend-modern/src/components/Settings/settingsNavigationModel.ts").read_text(encoding="utf-8")
self.assertIn("const SUPPORT_REPORTING_PREFIX = `${SUPPORT_PREFIX}/reporting`;", nav)
if __name__ == "__main__":
unittest.main()