mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-16 07:33:06 +08:00
28 lines
714 B
Go
28 lines
714 B
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestBindPasskeyFinishRequestRejectsOversizedBody(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
recorder := httptest.NewRecorder()
|
|
context, _ := gin.CreateTestContext(recorder)
|
|
context.Request = httptest.NewRequest(
|
|
http.MethodPost,
|
|
"/api/v1/auth/passkey/login/finish",
|
|
strings.NewReader(`{"credential":"`+strings.Repeat("x", passkeyFinishBodyMaxBytes)+`"}`),
|
|
)
|
|
context.Request.Header.Set("Content-Type", "application/json")
|
|
|
|
_, ok := bindPasskeyFinishRequest(context)
|
|
require.False(t, ok)
|
|
require.Equal(t, http.StatusBadRequest, recorder.Code)
|
|
}
|