Prepare verified laboratory 3 implementation and evidence

This commit is contained in:
rey
2026-11-17 17:31:17 +03:00
parent 0ab3a341aa
commit 3d67e677d0
176 changed files with 21076 additions and 38 deletions
@@ -0,0 +1,21 @@
package handler
import (
"bytes"
"net/http"
"net/http/httptest"
"testing"
)
func TestRejectsInvalidUTF8BeforeJSONDecoding(t *testing.T) {
body := append([]byte(`{"display_name":"`), 0xff)
body = append(body, []byte(`"}`)...)
request := httptest.NewRequest(http.MethodPost, "/api/v1/users", bytes.NewReader(body))
response := httptest.NewRecorder()
h := &API{limits: Limits{MaxBodyBytes: 65536}}
called := false
requestID(h.jsonBody(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { called = true; w.WriteHeader(204) }))).ServeHTTP(response, request)
if response.Code != 400 || called {
t.Fatalf("invalid UTF-8 reached decoder: status=%d called=%t", response.Code, called)
}
}