second commit

This commit is contained in:
Rogee
2026-06-04 15:44:48 +08:00
parent 4db6efb3a7
commit 8ac150bc7b
1275 changed files with 286124 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
package middleware
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert"
"github.com/gochat/gochat/internal/auth"
)
func TestWebhookAuth_NoToken(t *testing.T) {
gin.SetMode(gin.TestMode)
registry := &auth.WebhookTokenRegistry{}
r := gin.New()
r.Use(WebhookAuth(registry))
r.POST("/:channel_type/:identifier/webhook", func(c *gin.Context) { c.JSON(200, gin.H{"ok": true}) })
w := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodPost, "/web_widget/test-inbox/webhook", nil)
r.ServeHTTP(w, req)
assert.Equal(t, 401, w.Code)
}