fix(api): 400 на битое тело apply, маскирование internal-ошибок, лимит тела

This commit is contained in:
2026-07-03 14:35:43 +07:00
parent fdf90a7c23
commit 05dc586646
2 changed files with 49 additions and 4 deletions
+35
View File
@@ -76,6 +76,41 @@ func TestApplyDefaultsPruneFalse(t *testing.T) {
}
}
func TestApplyEmptyBodyOK(t *testing.T) {
a, m := newTestAPI()
router := NewRouter(a)
did := uuid.New().String()
req := httptest.NewRequest(http.MethodPost,
"/api/v1/projects/00000000-0000-0000-0000-000000000002/domains/"+did+"/apply", nil)
w := httptest.NewRecorder()
router.ServeHTTP(w, req)
if w.Code != http.StatusOK {
t.Fatalf("status %d body %s", w.Code, w.Body.String())
}
if m.lastReq.ApplyPrunes != false {
t.Fatalf("expected ApplyPrunes=false for empty body, got %+v", m.lastReq)
}
}
func TestApplyMalformedBody(t *testing.T) {
a, _ := newTestAPI()
router := NewRouter(a)
did := uuid.New().String()
body := `{"applyUpdates":`
req := httptest.NewRequest(http.MethodPost,
"/api/v1/projects/00000000-0000-0000-0000-000000000002/domains/"+did+"/apply",
strings.NewReader(body))
w := httptest.NewRecorder()
router.ServeHTTP(w, req)
if w.Code != http.StatusBadRequest {
t.Fatalf("expected 400 for malformed body, got %d body %s", w.Code, w.Body.String())
}
}
func TestApplyBadUUID(t *testing.T) {
a, _ := newTestAPI()
router := NewRouter(a)