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 handleValidateBootstrapToken invalid JSON
rcourtmand64e992b8eb2
diff --git a/internal/api/bootstrap_token_test.go b/internal/api/bootstrap_token_test.goindex 889c4c3f26..2d2683f0a2 100644--- a/internal/api/bootstrap_token_test.go+++ b/internal/api/bootstrap_token_test.go@@ -1,9 +1,12 @@package apiimport (+ "net/http"+ "net/http/httptest""os""path/filepath""runtime"+ "strings""testing""github.com/rcourtman/pulse-go-rewrite/internal/config"@@ -388,6 +391,26 @@ func TestBootstrapTokenValid(t *testing.T) {})}+func TestHandleValidateBootstrapToken_InvalidJSON(t *testing.T) {+ tmpDir := t.TempDir()+ cfg := &config.Config{DataPath: tmpDir}+ r := &Router{config: cfg}+ r.initializeBootstrapToken()++ // Test invalid JSON body triggers json.Decode error+ req := httptest.NewRequest(http.MethodPost, "/api/security/validate-bootstrap-token", strings.NewReader("not valid json"))+ rr := httptest.NewRecorder()++ r.handleValidateBootstrapToken(rr, req)++ if rr.Code != http.StatusBadRequest {+ t.Errorf("expected 400 for invalid JSON, got %d", rr.Code)+ }+ if !strings.Contains(rr.Body.String(), "Invalid request payload") {+ t.Errorf("expected 'Invalid request payload' error, got %q", rr.Body.String())+ }+}+func TestClearBootstrapToken(t *testing.T) {t.Run("nil router does not panic", func(t *testing.T) {var r *Router = nil