Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

test: require host:manage for host config patch

rcourtman71440c952113
diff --git a/internal/api/security_regression_test.go b/internal/api/security_regression_test.go
index 2f74ba0c77..a09744cfe5 100644
--- a/internal/api/security_regression_test.go
+++ b/internal/api/security_regression_test.go
@@ -1417,6 +1417,24 @@ func TestHostAgentEndpointsRequireHostReportScope(t *testing.T) {
}
}
+func TestHostAgentConfigPatchRequiresHostManageScope(t *testing.T) {
+ rawToken := "host-config-manage-token-123.12345678"
+ record := newTokenRecord(t, rawToken, []string{config.ScopeHostConfigRead}, nil)
+ cfg := newTestConfigWithTokens(t, record)
+ router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")
+
+ req := httptest.NewRequest(http.MethodPatch, "/api/agents/host/host-1/config", strings.NewReader(`{}`))
+ req.Header.Set("X-API-Token", rawToken)
+ rec := httptest.NewRecorder()
+ router.Handler().ServeHTTP(rec, req)
+ if rec.Code != http.StatusForbidden {
+ t.Fatalf("expected 403 for missing host:manage scope, got %d", rec.Code)
+ }
+ if !strings.Contains(rec.Body.String(), config.ScopeHostManage) {
+ t.Fatalf("expected missing scope response to mention %q, got %q", config.ScopeHostManage, rec.Body.String())
+ }
+}
+
func TestMonitoringReadEndpointsRequireMonitoringReadScope(t *testing.T) {
rawToken := "monitoring-read-token-123.12345678"
record := newTokenRecord(t, rawToken, []string{config.ScopeSettingsRead}, nil)