Files
Pulse/scripts/tests/test_msp_connection_docs.py
pulse-triage[bot] abfe0a6f48 Align Agent Security, Unified Agent, MSP, and Multi-Tenant Help
Align four unclaimed in-app Help guides and their mirrored copies under
frontend-modern/public/docs/ with landed runtime hardening and current
stable release assets:

- AGENT_SECURITY.md and UNIFIED_AGENT.md: document Docker module and
  Windows service monitoring-only ceiling enforcement (rejecting legacy
  update_container and update_all report-response commands and forwarding
  CommandAuthorityProfile, DisableUpdateChecks, and
  DisableRegistryCredentials), signed remote-config enforcement on
  commandsEnabled overrides in report acknowledgements, and Docker/Podman
  oversized report metadata/attachment shedding (2 MiB encoded / 10 MiB
  decoded, 32 KiB -> 4 KiB -> 0 metadata steps, 64 -> 0 port/mount steps)
  plus non-buffered HTTP 413 handling (5590bb7725).
- MSP.md: update the self-service evaluation bundle recipe to the
  published v6.9.0 signed release asset, replace the retired Pulse
  Assistant narrative wording, and document portal membership propagation
  into client workspaces and magic-link owner-seeding limits (70f3b0a3b3).
- MULTI_TENANT.md: document org-bound API token revocation on
  organization deletion and before ID reuse, plus cold non-default
  monitor isolation for requests without an explicit API token
  (f7f5354097).
- Add source-bound doc regression tests in test_stale_reading_help_docs.py,
  test_msp_connection_docs.py, and test_admin_docs.py.

Contract-Neutral: documentation alignment and source-bound doc tests only; no runtime, API, schema, telemetry, or frontend source behavior changes.
Change-source: pulse-maintainer
2026-11-27 20:28:49 +00:00

147 lines
7.7 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)
def test_msp_help_tracks_v690_eval_bundle_and_workspace_membership_sync(self):
doc = (ROOT / "docs/MSP.md").read_text(encoding="utf-8")
self.assertEqual(
(ROOT / "docs/MSP.md").read_bytes(),
(ROOT / "frontend-modern/public/docs/MSP.md").read_bytes(),
)
text = " ".join(doc.split())
for phrase in (
"published with Pulse v6.9.0",
"export PULSE_VERSION=v6.9.0",
"Membership changes in the portal propagate into every client workspace organization record first.",
"Removing a teammate or lowering their role revokes or reduces their workspace authority immediately",
"stored checkout contact email cannot re-seed a removed member through a tenant-bound sign-in link",
"without an AI-generated narrative",
):
with self.subTest(phrase=phrase):
self.assertIn(phrase, text)
self.assertNotIn("export PULSE_VERSION=v6.8.0", doc)
self.assertNotIn("Pulse Assistant narrative", text)
handlers = (ROOT / "internal/cloudcp/account/handlers.go").read_text(encoding="utf-8")
for marker in (
"RevokeWorkspaceAccess(ctx context.Context, accountID, userID string) error",
"LowerWorkspaceAccess(ctx context.Context, accountID, userID string, role registry.MemberRole) error",
"SyncWorkspaceAccess(ctx context.Context, accountID, userID string, role registry.MemberRole) error",
):
self.assertIn(marker, handlers)
if __name__ == "__main__":
unittest.main()