diff --git a/test/integration/apiserver/max_request_body_bytes_test.go b/test/integration/apiserver/max_request_body_bytes_test.go index d5c50b22120..f343a272c0c 100644 --- a/test/integration/apiserver/max_request_body_bytes_test.go +++ b/test/integration/apiserver/max_request_body_bytes_test.go @@ -93,6 +93,14 @@ func TestMaxResourceSize(t *testing.T) { t.Errorf("expected success or bad request err, got %v", err) } }) + t.Run("JSONPatchType should handle a valid patch just under the max limit", func(t *testing.T) { + patchBody := []byte(`[{"op":"add","path":"/foo","value":0` + strings.Repeat(" ", 3*1024*1024-100) + `}]`) + err = rest.Patch(types.JSONPatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")). + Body(patchBody).Do().Error() + if err != nil { + t.Errorf("unexpected error: %v", err) + } + }) t.Run("MergePatchType should handle a patch just under the max limit", func(t *testing.T) { patchBody := []byte(`{"value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}`) err = rest.Patch(types.MergePatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")). @@ -101,6 +109,14 @@ func TestMaxResourceSize(t *testing.T) { t.Errorf("expected success or bad request err, got %v", err) } }) + t.Run("MergePatchType should handle a valid patch just under the max limit", func(t *testing.T) { + patchBody := []byte(`{"value":0` + strings.Repeat(" ", 3*1024*1024-100) + `}`) + err = rest.Patch(types.MergePatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")). + Body(patchBody).Do().Error() + if err != nil { + t.Errorf("unexpected error: %v", err) + } + }) t.Run("StrategicMergePatchType should handle a patch just under the max limit", func(t *testing.T) { patchBody := []byte(`{"value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}`) err = rest.Patch(types.StrategicMergePatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")). @@ -109,6 +125,14 @@ func TestMaxResourceSize(t *testing.T) { t.Errorf("expected success or bad request err, got %v", err) } }) + t.Run("StrategicMergePatchType should handle a valid patch just under the max limit", func(t *testing.T) { + patchBody := []byte(`{"value":0` + strings.Repeat(" ", 3*1024*1024-100) + `}`) + err = rest.Patch(types.StrategicMergePatchType).AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")). + Body(patchBody).Do().Error() + if err != nil { + t.Errorf("unexpected error: %v", err) + } + }) t.Run("ApplyPatchType should handle a patch just under the max limit", func(t *testing.T) { patchBody := []byte(`{"value":` + strings.Repeat("[", 3*1024*1024/2-100) + strings.Repeat("]", 3*1024*1024/2-100) + `}`) err = rest.Patch(types.ApplyPatchType).Param("fieldManager", "test").AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")). @@ -117,6 +141,14 @@ func TestMaxResourceSize(t *testing.T) { t.Errorf("expected success or bad request err, got %#v", err) } }) + t.Run("ApplyPatchType should handle a valid patch just under the max limit", func(t *testing.T) { + patchBody := []byte(`{"apiVersion":"v1","kind":"Secret"` + strings.Repeat(" ", 3*1024*1024-100) + `}`) + err = rest.Patch(types.ApplyPatchType).Param("fieldManager", "test").AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")). + Body(patchBody).Do().Error() + if err != nil { + t.Errorf("unexpected error: %v", err) + } + }) t.Run("Delete should limit the request body size", func(t *testing.T) { err = c.Delete().AbsPath(fmt.Sprintf("/api/v1/namespaces/default/secrets/test")). Body(hugeData).Do().Error()