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: Add edge case for RequireScope empty scope
rcourtman7a1d3ec2e5a5
diff --git a/internal/api/auth_scope_test.go b/internal/api/auth_scope_test.goindex 84aa705521..e0df09981e 100644--- a/internal/api/auth_scope_test.go+++ b/internal/api/auth_scope_test.go@@ -24,6 +24,25 @@ func TestRequireScopeAllowsSession(t *testing.T) {}}+func TestRequireScopeEmptyScopeAllowsAll(t *testing.T) {+ // Empty scope should allow all requests through without checking token+ handler := RequireScope("", func(w http.ResponseWriter, r *http.Request) {+ w.WriteHeader(http.StatusOK)+ })++ req := httptest.NewRequest(http.MethodGet, "/", nil)+ // Attach a token with no scopes - should still be allowed through+ record := config.APITokenRecord{ID: "token-empty", Scopes: []string{}}+ attachAPITokenRecord(req, &record)++ rr := httptest.NewRecorder()+ handler(rr, req)++ if rr.Code != http.StatusOK {+ t.Fatalf("expected status 200 when scope is empty, got %d", rr.Code)+ }+}+func TestRequireScopeRejectsMissingScope(t *testing.T) {handler := RequireScope(config.ScopeSettingsWrite, func(w http.ResponseWriter, r *http.Request) {w.WriteHeader(http.StatusOK)