Files
MindSift/internal/api/bodylimit_test.go
T
sandrodachandClaude Opus 5.5 7801cd13b9
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 1m49s
feat(voice): self-hosted speech recognition via Whisper (STT_*)
- STT_URL switches voice input to an OpenAI-compatible Whisper server
  (e.g. speaches); without it the browser's recognition stays. Configured
  by environment only, with limits for upload size, parallel jobs, hourly
  budget per user and timeout. The demo always uses the browser.
- POST /voice/transcribe forwards recordings and returns the text; nothing
  is stored. On startup MindSift waits for the server and asks it to
  download the model if missing.
- Admin card shows the active mode and server state, with a test recording.
- docker-compose: optional "whisper" service (speaches 0.8.3 CPU, profile
  "whisper", models in ./whisper).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 22:12:57 +01:00

31 lines
1.1 KiB
Go

package api
import (
"net/http"
"strings"
"testing"
)
func TestRequestBodyLimited(t *testing.T) {
srv, _, token := setupTestServer(t)
router := srv.Router()
huge := `{"content":"` + strings.Repeat("x", defaultMaxBody) + `"}`
if rec := sessionCall(router, "POST", "/api/v1/inbox", token, huge, ""); rec.Code != http.StatusBadRequest && rec.Code != http.StatusRequestEntityTooLarge {
t.Fatalf("body over the limit: want 400/413, got %d", rec.Code)
}
if rec := sessionCall(router, "POST", "/api/v1/inbox", token, `{"content":"klein"}`, ""); rec.Code >= 300 {
t.Fatalf("normal body: got %d %s", rec.Code, rec.Body.String())
}
if srv.bodyLimitFor("/api/v1/docs/doc_1/sync") != syncMaxBody || srv.bodyLimitFor("/api/v1/import/obsidian") <= defaultMaxBody {
t.Fatal("sync and import keep their larger limits")
}
}
func TestWebhookTokenInURLOnlyAPIKey(t *testing.T) {
srv, _, token := setupTestServer(t)
rec := sessionCall(srv.Router(), "POST", "/api/v1/webhooks/ingest?token="+token, "", `{"text":"x"}`, "")
if rec.Code != http.StatusUnauthorized {
t.Fatalf("session token in URL: want 401, got %d", rec.Code)
}
}