second commit
This commit is contained in:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user