Skip to content

Commit 8b0792d

Browse files
committed
Add async multipart limit tests
1 parent 76d6749 commit 8b0792d

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

ring-core/test/ring/middleware/test/multipart_params.clj

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,10 @@
188188
"Content-Type: text/plain\r\n\r\n"
189189
"foobar\r\n"
190190
"--XXXX--")
191-
headers {"content-type" (str "multipart/form-data; boundary=XXXX")}
192-
handler (constantly {:status 200, :headers {}, :body "OK"})]
191+
headers {"content-type" (str "multipart/form-data; boundary=XXXX")}
192+
handler (constantly {:status 200, :headers {}, :body "OK"})
193+
handler-async (fn [_ respond _]
194+
(respond {:status 200, :headers {}, :body "OK"}))]
193195
(is (thrown? org.apache.commons.fileupload.FileUploadBase$FileUploadIOException
194196
(multipart-params-request
195197
{:headers headers, :body (string-input-stream form-body)}
@@ -209,4 +211,20 @@
209211
(is (= 413 (:status response))))
210212
(let [response ((wrap-multipart-params handler {:max-file-count 2})
211213
{:headers headers, :body (string-input-stream form-body)})]
212-
(is (= 200 (:status response))))))
214+
(is (= 200 (:status response))))
215+
(let [response (promise)
216+
error (promise)]
217+
((wrap-multipart-params handler-async {:max-file-size 6})
218+
{:headers headers, :body (string-input-stream form-body)}
219+
response
220+
error)
221+
(is (= 413 (:status @response)))
222+
(is (not (realized? error))))
223+
(let [response (promise)
224+
error (promise)]
225+
((wrap-multipart-params handler-async {:max-file-count 1})
226+
{:headers headers, :body (string-input-stream form-body)}
227+
response
228+
error)
229+
(is (= 413 (:status @response)))
230+
(is (not (realized? error))))))

0 commit comments

Comments
 (0)