Prepare verified laboratory 2 implementation and evidence

This commit is contained in:
rey
2026-11-17 17:31:17 +03:00
parent 65003b6119
commit 62d7c2023c
85 changed files with 9426 additions and 38 deletions
@@ -0,0 +1,9 @@
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)}
}