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 CheckCSRF valid token test for 100% coverage
rcourtmanbbbeb4597362
diff --git a/internal/api/security_test.go b/internal/api/security_test.goindex 0332ae2766..6134c4287a 100644--- a/internal/api/security_test.go+++ b/internal/api/security_test.go@@ -1333,6 +1333,32 @@ func TestCheckCSRF_InvalidCSRFToken(t *testing.T) {}}+func TestCheckCSRF_ValidCSRFToken(t *testing.T) {+ // Initialize stores with temp directory+ dir := t.TempDir()+ InitCSRFStore(dir)++ // Create a session ID+ sessionID := "valid-session-id-12345678"++ // Generate a valid CSRF token for this session+ validToken := generateCSRFToken(sessionID)++ w := httptest.NewRecorder()+ req := httptest.NewRequest("POST", "/api/test", nil)+ req.AddCookie(&http.Cookie{+ Name: "pulse_session",+ Value: sessionID,+ })+ req.Header.Set("X-CSRF-Token", validToken)++ // Valid CSRF token should pass+ result := CheckCSRF(w, req)+ if !result {+ t.Error("CheckCSRF should return true when CSRF token is valid")+ }+}+func TestCheckCSRF_CSRFTokenFromFormValue(t *testing.T) {w := httptest.NewRecorder()req := httptest.NewRequest("POST", "/api/test?csrf_token=form-token-value", nil)