fix(middleware): Correct rate limit header type conversion
This commit is contained in:
@@ -4,10 +4,21 @@ import (
|
||||
"bookhoard/internal/handlers"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"bookhoard/internal/config"
|
||||
"bookhoard/internal/database"
|
||||
"bookhoard/internal/middleware"
|
||||
"bookhoard/internal/router"
|
||||
"bookhoard/internal/services"
|
||||
"bookhoard/internal/sync"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -24,9 +35,25 @@ func TestKoboInitialization(t *testing.T) {
|
||||
_ = getTestUserID(t, db)
|
||||
_ = createTestMediaItemID(t, ts, token)
|
||||
|
||||
log.Printf("[DEBUG] Kobo test setup: creating device and media")
|
||||
|
||||
t.Run("successful initialization", func(t *testing.T) {
|
||||
req, _ := http.NewRequest("GET", ts.URL+"/api/sync/kobo/test-token/v1/initialization", nil)
|
||||
req.Header.Set("Authorization", "Bearer test-auth-token")
|
||||
// Create Kobo device using TestDeviceSetup for proper authentication
|
||||
deviceSetup := setupTestDevice(t, ts, db)
|
||||
koboDevice := deviceSetup.CreateDevice(t, "Test Kobo", "kobo", "kobo-clara-test")
|
||||
|
||||
req, _ := http.NewRequest("GET", ts.URL+"/api/sync/kobo/v1/initialization", nil)
|
||||
req.Header.Set("Authorization", "Bearer "+koboDevice.AuthToken)
|
||||
req.Header.Set("x-kobo-device", fmt.Sprintf(`{"DeviceId":"%s","Model":"Kobo Clara","SerialNumber":"%s"}`,
|
||||
koboDevice.ID.String(), koboDevice.Identifier))
|
||||
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
require.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||
})
|
||||
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
|
||||
Reference in New Issue
Block a user