@@ -93,6 +93,14 @@ func TestMaxResourceSize(t *testing.T) {
93
93
t .Errorf ("expected success or bad request err, got %v" , err )
94
94
}
95
95
})
96
+ t .Run ("JSONPatchType should handle a valid patch just under the max limit" , func (t * testing.T ) {
97
+ patchBody := []byte (`[{"op":"add","path":"/foo","value":0` + strings .Repeat (" " , 3 * 1024 * 1024 - 100 ) + `}]` )
98
+ err = rest .Patch (types .JSONPatchType ).AbsPath (fmt .Sprintf ("/api/v1/namespaces/default/secrets/test" )).
99
+ Body (patchBody ).Do ().Error ()
100
+ if err != nil {
101
+ t .Errorf ("unexpected error: %v" , err )
102
+ }
103
+ })
96
104
t .Run ("MergePatchType should handle a patch just under the max limit" , func (t * testing.T ) {
97
105
patchBody := []byte (`{"value":` + strings .Repeat ("[" , 3 * 1024 * 1024 / 2 - 100 ) + strings .Repeat ("]" , 3 * 1024 * 1024 / 2 - 100 ) + `}` )
98
106
err = rest .Patch (types .MergePatchType ).AbsPath (fmt .Sprintf ("/api/v1/namespaces/default/secrets/test" )).
@@ -101,6 +109,14 @@ func TestMaxResourceSize(t *testing.T) {
101
109
t .Errorf ("expected success or bad request err, got %v" , err )
102
110
}
103
111
})
112
+ t .Run ("MergePatchType should handle a valid patch just under the max limit" , func (t * testing.T ) {
113
+ patchBody := []byte (`{"value":0` + strings .Repeat (" " , 3 * 1024 * 1024 - 100 ) + `}` )
114
+ err = rest .Patch (types .MergePatchType ).AbsPath (fmt .Sprintf ("/api/v1/namespaces/default/secrets/test" )).
115
+ Body (patchBody ).Do ().Error ()
116
+ if err != nil {
117
+ t .Errorf ("unexpected error: %v" , err )
118
+ }
119
+ })
104
120
t .Run ("StrategicMergePatchType should handle a patch just under the max limit" , func (t * testing.T ) {
105
121
patchBody := []byte (`{"value":` + strings .Repeat ("[" , 3 * 1024 * 1024 / 2 - 100 ) + strings .Repeat ("]" , 3 * 1024 * 1024 / 2 - 100 ) + `}` )
106
122
err = rest .Patch (types .StrategicMergePatchType ).AbsPath (fmt .Sprintf ("/api/v1/namespaces/default/secrets/test" )).
@@ -109,6 +125,14 @@ func TestMaxResourceSize(t *testing.T) {
109
125
t .Errorf ("expected success or bad request err, got %v" , err )
110
126
}
111
127
})
128
+ t .Run ("StrategicMergePatchType should handle a valid patch just under the max limit" , func (t * testing.T ) {
129
+ patchBody := []byte (`{"value":0` + strings .Repeat (" " , 3 * 1024 * 1024 - 100 ) + `}` )
130
+ err = rest .Patch (types .StrategicMergePatchType ).AbsPath (fmt .Sprintf ("/api/v1/namespaces/default/secrets/test" )).
131
+ Body (patchBody ).Do ().Error ()
132
+ if err != nil {
133
+ t .Errorf ("unexpected error: %v" , err )
134
+ }
135
+ })
112
136
t .Run ("ApplyPatchType should handle a patch just under the max limit" , func (t * testing.T ) {
113
137
patchBody := []byte (`{"value":` + strings .Repeat ("[" , 3 * 1024 * 1024 / 2 - 100 ) + strings .Repeat ("]" , 3 * 1024 * 1024 / 2 - 100 ) + `}` )
114
138
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) {
117
141
t .Errorf ("expected success or bad request err, got %#v" , err )
118
142
}
119
143
})
144
+ t .Run ("ApplyPatchType should handle a valid patch just under the max limit" , func (t * testing.T ) {
145
+ patchBody := []byte (`{"apiVersion":"v1","kind":"Secret"` + strings .Repeat (" " , 3 * 1024 * 1024 - 100 ) + `}` )
146
+ err = rest .Patch (types .ApplyPatchType ).Param ("fieldManager" , "test" ).AbsPath (fmt .Sprintf ("/api/v1/namespaces/default/secrets/test" )).
147
+ Body (patchBody ).Do ().Error ()
148
+ if err != nil {
149
+ t .Errorf ("unexpected error: %v" , err )
150
+ }
151
+ })
120
152
t .Run ("Delete should limit the request body size" , func (t * testing.T ) {
121
153
err = c .Delete ().AbsPath (fmt .Sprintf ("/api/v1/namespaces/default/secrets/test" )).
122
154
Body (hugeData ).Do ().Error ()
0 commit comments