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 settings:write for ai patrol autonomy update

rcourtman83311cdf8c3b
diff --git a/internal/api/security_regression_test.go b/internal/api/security_regression_test.go
index f85c42f990..acf179f7be 100644
--- a/internal/api/security_regression_test.go
+++ b/internal/api/security_regression_test.go
@@ -846,6 +846,24 @@ func TestAIPatrolAutonomyRequiresSettingsWriteScope(t *testing.T) {
}
}
+func TestAIPatrolAutonomyUpdateRequiresSettingsWriteScope(t *testing.T) {
+ rawToken := "ai-patrol-autonomy-update-token-123.12345678"
+ record := newTokenRecord(t, rawToken, []string{config.ScopeSettingsRead}, nil)
+ cfg := newTestConfigWithTokens(t, record)
+ router := NewRouter(cfg, nil, nil, nil, nil, "1.0.0")
+
+ req := httptest.NewRequest(http.MethodPut, "/api/ai/patrol/autonomy", 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 settings:write scope, got %d", rec.Code)
+ }
+ if !strings.Contains(rec.Body.String(), config.ScopeSettingsWrite) {
+ t.Fatalf("expected missing scope response to mention %q, got %q", config.ScopeSettingsWrite, rec.Body.String())
+ }
+}
+
func TestAIExecuteReadEndpointsRequireAIExecuteScope(t *testing.T) {
rawToken := "ai-exec-read-token-123.12345678"
record := newTokenRecord(t, rawToken, []string{config.ScopeAIChat}, nil)