fix: harden notification cache synchronization

This commit is contained in:
naiba committed 2026-09-19 10:44:17 +00:00
1 parent 589f01f562
commit 9dab6a5039
4 files changed
+225 -55

No files matched your search

@@ -0,0 +1,25 @@
package controller
import (
"bytes"
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/gin-gonic/gin"
)
func TestBatchDeleteNotificationCapsRequestBody(t *testing.T) {
body := append(bytes.Repeat([]byte{' '}, notificationBatchDeleteMaxBodyBytes+1), '[', ']')
req := httptest.NewRequest(http.MethodPost, "/api/v1/batch-delete/notification", bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
w := httptest.NewRecorder()
c, _ := gin.CreateTestContext(w)
c.Request = req
_, err := batchDeleteNotification(c)
if err == nil || !strings.Contains(err.Error(), "request body too large") {
t.Fatalf("oversized request body was not rejected by MaxBytesReader: %v", err)
}
}