From c6ad8c30792252b7766d1e60d07d9736b8c0b703 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Mon, 8 Sep 2008 09:24:45 +0000 Subject: [PATCH] Added tests for rfc1867 post handler --- tests/basic/rfc1867_anonymous_upload.phpt | 58 ++++++++++++ tests/basic/rfc1867_array_upload.phpt | 85 ++++++++++++++++++ tests/basic/rfc1867_boundary_1.phpt | 27 ++++++ tests/basic/rfc1867_boundary_2.phpt | 27 ++++++ tests/basic/rfc1867_empty_upload.phpt | 90 +++++++++++++++++++ tests/basic/rfc1867_file_upload_disabled.phpt | 38 ++++++++ tests/basic/rfc1867_garbled_mime_headers.phpt | 27 ++++++ tests/basic/rfc1867_invalid_boundary.phpt | 26 ++++++ tests/basic/rfc1867_malicious_input.phpt | 27 ++++++ tests/basic/rfc1867_max_file_size.phpt | 90 +++++++++++++++++++ tests/basic/rfc1867_missing_boundary.phpt | 26 ++++++ tests/basic/rfc1867_missing_boundary_2.phpt | 39 ++++++++ tests/basic/rfc1867_post_max_filesize.phpt | 84 +++++++++++++++++ tests/basic/rfc1867_post_max_size.phpt | 26 ++++++ 14 files changed, 670 insertions(+) create mode 100644 tests/basic/rfc1867_anonymous_upload.phpt create mode 100644 tests/basic/rfc1867_array_upload.phpt create mode 100644 tests/basic/rfc1867_boundary_1.phpt create mode 100644 tests/basic/rfc1867_boundary_2.phpt create mode 100644 tests/basic/rfc1867_empty_upload.phpt create mode 100644 tests/basic/rfc1867_file_upload_disabled.phpt create mode 100644 tests/basic/rfc1867_garbled_mime_headers.phpt create mode 100644 tests/basic/rfc1867_invalid_boundary.phpt create mode 100644 tests/basic/rfc1867_malicious_input.phpt create mode 100644 tests/basic/rfc1867_max_file_size.phpt create mode 100644 tests/basic/rfc1867_missing_boundary.phpt create mode 100644 tests/basic/rfc1867_missing_boundary_2.phpt create mode 100644 tests/basic/rfc1867_post_max_filesize.phpt create mode 100644 tests/basic/rfc1867_post_max_size.phpt diff --git a/tests/basic/rfc1867_anonymous_upload.phpt b/tests/basic/rfc1867_anonymous_upload.phpt new file mode 100644 index 0000000000..0f58014a44 --- /dev/null +++ b/tests/basic/rfc1867_anonymous_upload.phpt @@ -0,0 +1,58 @@ +--TEST-- +rfc1867 anonymous upload +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +--SKIPIF-- + +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; filename="file2.txt" +Content-Type: text/plain-file2 + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- + +--EXPECTF-- +array(2) { + [%d]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(16) "text/plain-file1" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%d]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(16) "text/plain-file2" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(0) { +} diff --git a/tests/basic/rfc1867_array_upload.phpt b/tests/basic/rfc1867_array_upload.phpt new file mode 100644 index 0000000000..7af6700060 --- /dev/null +++ b/tests/basic/rfc1867_array_upload.phpt @@ -0,0 +1,85 @@ +--TEST-- +rfc1867 array upload +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +--SKIPIF-- + +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file[]"; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file[2]"; filename="file2.txt" +Content-Type: text/plain-file2 + +2 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file[]"; filename="file3.txt" +Content-Type: text/plain-file3 + +3 +-----------------------------20896060251896012921717172737-- +--FILE-- + +--EXPECTF-- +array(1) { + [%u|b%"file"]=> + array(5) { + [%u|b%"name"]=> + array(3) { + [0]=> + %unicode|string%(9) "file1.txt" + [2]=> + %unicode|string%(9) "file2.txt" + [3]=> + %unicode|string%(9) "file3.txt" + } + [%u|b%"type"]=> + array(3) { + [0]=> + %unicode|string%(16) "text/plain-file1" + [2]=> + %unicode|string%(16) "text/plain-file2" + [3]=> + %unicode|string%(16) "text/plain-file3" + } + [%u|b%"tmp_name"]=> + array(3) { + [0]=> + %unicode|string%(%d) "%s" + [2]=> + %unicode|string%(%d) "%s" + [3]=> + %unicode|string%(%d) "%s" + } + [%u|b%"error"]=> + array(3) { + [0]=> + int(0) + [2]=> + int(0) + [3]=> + int(0) + } + [%u|b%"size"]=> + array(3) { + [0]=> + int(1) + [2]=> + int(1) + [3]=> + int(1) + } + } +} +array(0) { +} diff --git a/tests/basic/rfc1867_boundary_1.phpt b/tests/basic/rfc1867_boundary_1.phpt new file mode 100644 index 0000000000..35fe3a3f6e --- /dev/null +++ b/tests/basic/rfc1867_boundary_1.phpt @@ -0,0 +1,27 @@ +--TEST-- +rfc1867 boundary 1 +--INI-- +post_max_size=1024 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +--SKIPIF-- + +--POST_RAW-- +Content-Type: multipart/form-data; boundary="------------------------------------foobar" +--------------------------------------foobar +Content-Disposition: form-data; name="foobar" + +1 +--------------------------------------foobar-- +--FILE-- + +--EXPECTF-- +array(0) { +} +array(1) { + [%u|b%"foobar"]=> + %unicode|string%(1) "1" +} diff --git a/tests/basic/rfc1867_boundary_2.phpt b/tests/basic/rfc1867_boundary_2.phpt new file mode 100644 index 0000000000..575853bb66 --- /dev/null +++ b/tests/basic/rfc1867_boundary_2.phpt @@ -0,0 +1,27 @@ +--TEST-- +rfc1867 boundary 2 +--INI-- +post_max_size=1024 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +--SKIPIF-- + +--POST_RAW-- +Content-Type: multipart/form-data; boundary=------------------------------------foo, bar +--------------------------------------foo +Content-Disposition: form-data; name="foobar" + +1 +--------------------------------------foo-- +--FILE-- + +--EXPECTF-- +array(0) { +} +array(1) { + [%u|b%"foobar"]=> + %unicode|string%(1) "1" +} diff --git a/tests/basic/rfc1867_empty_upload.phpt b/tests/basic/rfc1867_empty_upload.phpt new file mode 100644 index 0000000000..10ed419d4d --- /dev/null +++ b/tests/basic/rfc1867_empty_upload.phpt @@ -0,0 +1,90 @@ +--TEST-- +rfc1867 empty upload +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +--SKIPIF-- + +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="foo" + + +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="" +Content-Type: text/plain-file2 + + +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file3"; filename="file3.txt" +Content-Type: text/plain-file3 + +3 +-----------------------------20896060251896012921717172737-- +--FILE-- + +--EXPECTF-- +array(3) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(16) "text/plain-file1" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(0) "" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(0) "" + [%u|b%"error"]=> + int(4) + [%u|b%"size"]=> + int(0) + } + [%u|b%"file3"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file3.txt" + [%u|b%"type"]=> + %string|unicode%(16) "text/plain-file3" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(1) { + [%u|b%"foo"]=> + %unicode|string%(0) "" +} +string(1) "1" +string(1) "3" diff --git a/tests/basic/rfc1867_file_upload_disabled.phpt b/tests/basic/rfc1867_file_upload_disabled.phpt new file mode 100644 index 0000000000..a0d5271d9c --- /dev/null +++ b/tests/basic/rfc1867_file_upload_disabled.phpt @@ -0,0 +1,38 @@ +--TEST-- +rfc1867 file_upload disabled +--INI-- +file_uploads=0 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +--SKIPIF-- + +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="foo" + +bar +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="bar" + +foo +-----------------------------20896060251896012921717172737-- +--FILE-- + +--EXPECTF-- +array(0) { +} +array(2) { + [%u|b%"foo"]=> + %unicode|string%(3) "bar" + [%u|b%"bar"]=> + %unicode|string%(3) "foo" +} diff --git a/tests/basic/rfc1867_garbled_mime_headers.phpt b/tests/basic/rfc1867_garbled_mime_headers.phpt new file mode 100644 index 0000000000..9bee926d9b --- /dev/null +++ b/tests/basic/rfc1867_garbled_mime_headers.phpt @@ -0,0 +1,27 @@ +--TEST-- +rfc1867 garbled mime headers +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +--SKIPIF-- + +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data + + +-----------------------------20896060251896012921717172737-- +--FILE-- + +--EXPECTF-- +Warning: File Upload Mime headers garbled in %s +array(0) { +} +array(0) { +} diff --git a/tests/basic/rfc1867_invalid_boundary.phpt b/tests/basic/rfc1867_invalid_boundary.phpt new file mode 100644 index 0000000000..3c66390162 --- /dev/null +++ b/tests/basic/rfc1867_invalid_boundary.phpt @@ -0,0 +1,26 @@ +--TEST-- +rfc1867 invalid boundary +--INI-- +post_max_size=1024 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +--SKIPIF-- + +--POST_RAW-- +Content-Type: multipart/form-data; boundary="foobar +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="foobar" + +1 +-----------------------------20896060251896012921717172737-- +--FILE-- + +--EXPECTF-- +Warning: Invalid boundary in multipart/form-data POST data in %s +array(0) { +} +array(0) { +} diff --git a/tests/basic/rfc1867_malicious_input.phpt b/tests/basic/rfc1867_malicious_input.phpt new file mode 100644 index 0000000000..74c7ad0f7e --- /dev/null +++ b/tests/basic/rfc1867_malicious_input.phpt @@ -0,0 +1,27 @@ +--TEST-- +rfc1867 malicious input +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +--SKIPIF-- + +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="foo[]bar"; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +-----------------------------20896060251896012921717172737-- +--FILE-- + +--EXPECTF-- +array(0) { +} +array(0) { +} diff --git a/tests/basic/rfc1867_max_file_size.phpt b/tests/basic/rfc1867_max_file_size.phpt new file mode 100644 index 0000000000..0671dc5f04 --- /dev/null +++ b/tests/basic/rfc1867_max_file_size.phpt @@ -0,0 +1,90 @@ +--TEST-- +rfc1867 MAX_FILE_SIZE +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +--SKIPIF-- + +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="MAX_FILE_SIZE" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" +Content-Type: text/plain-file2 + +22 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file3"; filename="C:\foo\bar/file3.txt" +Content-Type: text/plain-file3; + +3 +-----------------------------20896060251896012921717172737-- +--FILE-- + +--EXPECTF-- +array(3) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(16) "text/plain-file1" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(0) "" + [%u|b%"error"]=> + int(2) + [%u|b%"size"]=> + int(0) + } + [%u|b%"file3"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file3.txt" + [%u|b%"type"]=> + %string|unicode%(16) "text/plain-file3" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(1) { + [%u|b%"MAX_FILE_SIZE"]=> + %string|unicode%(1) "1" +} +string(1) "1" +string(1) "3" diff --git a/tests/basic/rfc1867_missing_boundary.phpt b/tests/basic/rfc1867_missing_boundary.phpt new file mode 100644 index 0000000000..9c8726cd67 --- /dev/null +++ b/tests/basic/rfc1867_missing_boundary.phpt @@ -0,0 +1,26 @@ +--TEST-- +rfc1867 missing boundary +--INI-- +post_max_size=1024 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +--SKIPIF-- + +--POST_RAW-- +Content-Type: multipart/form-data +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="foobar" + +1 +-----------------------------20896060251896012921717172737-- +--FILE-- + +--EXPECTF-- +Warning: Missing boundary in multipart/form-data POST data in %s +array(0) { +} +array(0) { +} diff --git a/tests/basic/rfc1867_missing_boundary_2.phpt b/tests/basic/rfc1867_missing_boundary_2.phpt new file mode 100644 index 0000000000..cace44383b --- /dev/null +++ b/tests/basic/rfc1867_missing_boundary_2.phpt @@ -0,0 +1,39 @@ +--TEST-- +rfc1867 missing boundary 2 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +--SKIPIF-- + +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +--FILE-- + +--EXPECTF-- +array(1) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(0) "" + [%u|b%"error"]=> + int(3) + [%u|b%"size"]=> + int(0) + } +} +array(0) { +} diff --git a/tests/basic/rfc1867_post_max_filesize.phpt b/tests/basic/rfc1867_post_max_filesize.phpt new file mode 100644 index 0000000000..4276d496ba --- /dev/null +++ b/tests/basic/rfc1867_post_max_filesize.phpt @@ -0,0 +1,84 @@ +--TEST-- +rfc1867 post_max_filesize +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1 +--SKIPIF-- + +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" +Content-Type: text/plain-file1 + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" +Content-Type: text/plain-file2 + +22 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file3"; filename="file3.txt" +Content-Type: text/plain-file3 + +3 +-----------------------------20896060251896012921717172737-- +--FILE-- + +--EXPECTF-- +array(3) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(16) "text/plain-file1" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(0) "" + [%u|b%"error"]=> + int(1) + [%u|b%"size"]=> + int(0) + } + [%u|b%"file3"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file3.txt" + [%u|b%"type"]=> + %string|unicode%(16) "text/plain-file3" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(0) { +} +string(1) "1" +string(1) "3" diff --git a/tests/basic/rfc1867_post_max_size.phpt b/tests/basic/rfc1867_post_max_size.phpt new file mode 100644 index 0000000000..5e40ccaf45 --- /dev/null +++ b/tests/basic/rfc1867_post_max_size.phpt @@ -0,0 +1,26 @@ +--TEST-- +rfc1867 post_max_size +--INI-- +post_max_size=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +--SKIPIF-- + +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="foobar" + +1 +-----------------------------20896060251896012921717172737-- +--FILE-- + +--EXPECTF-- +Warning: POST Content-Length of %d bytes exceeds the limit of 1 bytes in %s +array(0) { +} +array(0) { +} -- 2.40.0