Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
test: correct installed alert fixture scope contract
pulse-triage[bot]73a7e477aba7
diff --git a/tests/qualification/alert-lifecycle/README.md b/tests/qualification/alert-lifecycle/README.mdindex 70de5530b7..a72902622e 100644--- a/tests/qualification/alert-lifecycle/README.md+++ b/tests/qualification/alert-lifecycle/README.md@@ -27,8 +27,12 @@ The fixture operator must supply:isolated network namespace (for example, both inside a disposable VM with theserver using host networking); the receiver binds only loopback.- A disposable admin API token with agent:report, monitoring:read,- settings:read and settings:write scopes, injected as+ monitoring:write, settings:read and settings:write scopes, injected as`PULSE_ACCEPTANCE_TOKEN` without writing it to evidence or command arguments.+- Alert configuration PUTs require `monitoring:write`; `settings:write` does+ not imply it. A 403 stops the attempt: preserve it, correct the fixture+ credential contract through review, and use a fresh fixture rather than+ switching authentication methods or weakening the server scope check.- An executable restart hook taking no arguments. It must verify the server isstill healthy, gracefully stop/start **only this server** with the same exactimage and volume, and wait for authenticated HTTP readiness. It must fail ondiff --git a/tests/qualification/alert-lifecycle/wire_contract_test.go b/tests/qualification/alert-lifecycle/wire_contract_test.goindex 6c9a4c8e8c..c99201d547 100644--- a/tests/qualification/alert-lifecycle/wire_contract_test.go+++ b/tests/qualification/alert-lifecycle/wire_contract_test.go@@ -3,7 +3,14 @@ package alertlifecycleimport ("bytes""encoding/json"+ "github.com/rcourtman/pulse-go-rewrite/internal/api/apihttp"+ "github.com/rcourtman/pulse-go-rewrite/internal/config"+ internalauth "github.com/rcourtman/pulse-go-rewrite/pkg/auth"+ "net/http"+ "net/http/httptest"+ "os""os/exec"+ "strings""testing""text/template"@@ -56,3 +63,45 @@ func TestExternalDriverWireContract(t *testing.T) {t.Fatalf("invalid receipt: %v", receipt)}}++// Keep the provisioning contract aligned with the real scope guard. This is+// authorization proof only, not permission to replay a rejected installed run.+func TestDocumentedFixtureScopesAdmitAlertConfiguration(t *testing.T) {+ documentation, err := os.ReadFile("README.md")+ if err != nil {+ t.Fatal(err)+ }+ required := []string{+ config.ScopeAgentReport, config.ScopeMonitoringRead,+ config.ScopeMonitoringWrite, config.ScopeSettingsRead, config.ScopeSettingsWrite,+ }+ for _, scope := range required {+ if !strings.Contains(string(documentation), scope) {+ t.Fatalf("fixture instructions omit required scope %q", scope)+ }+ }+ for _, tc := range []struct {+ name string+ scopes []string+ allowed bool+ }{+ {"documented", required, true},+ {"original-missing-monitoring-write", []string{config.ScopeAgentReport, config.ScopeMonitoringRead, config.ScopeSettingsRead, config.ScopeSettingsWrite}, false},+ } {+ t.Run(tc.name, func(t *testing.T) {+ record, err := config.NewAPITokenRecord("synthetic-fixture-contract-token", tc.name, tc.scopes)+ if err != nil {+ t.Fatal(err)+ }+ req := httptest.NewRequest(http.MethodPut, "/api/alerts/config", nil)+ req = req.WithContext(internalauth.WithAPIToken(req.Context(), record))+ response := httptest.NewRecorder()+ if got := apihttp.EnsureScope(response, req, config.ScopeMonitoringWrite); got != tc.allowed {+ t.Fatalf("admitted=%v, want %v", got, tc.allowed)+ }+ if !tc.allowed && response.Code != http.StatusForbidden {+ t.Fatalf("missing scope returned %d, want 403", response.Code)+ }+ })+ }+}