1use strict;
2use warnings;
3
4use File::Basename qw(dirname);
5
6use lib dirname(__FILE__) . "/lib";
7
8use Test::Nginx::Socket tests => 5;
9use Test::More;
10use Test::Nginx::UploadModule;
11
12no_long_string();
13no_shuffle();
14run_tests();
15
16__DATA__
17=== TEST 1: invalid content-range
18--- config
19location /upload/ {
20    upload_pass @upstream;
21    upload_resumable on;
22    upload_set_form_field "upload_tmp_path" "$upload_tmp_path";
23    upload_cleanup 400 404 499 500-505;
24}
25--- more_headers
26X-Content-Range: bytes 0-3/4
27X-Progress-ID: 0000000001
28Session-ID: 0000000001
29Content-Type: text/plain
30Content-Disposition: form-data; name="file"; filename="test.txt"\r
31--- request eval
32qq{POST /upload/
33testing}
34--- error_code: 416
35--- extra_tests eval
36use Test::File qw(file_not_exists_ok);
37sub {
38    my $block = shift;
39    file_not_exists_ok(
40        "${ENV{TEST_NGINX_UPLOAD_PATH}}/store/1/0000000001", $block->name . '- tmp file deleted');
41}
42
43=== TEST 2: invalid method
44--- config
45location /upload/ {
46    upload_pass @upstream;
47    upload_resumable on;
48    upload_set_form_field "upload_tmp_path" "$upload_tmp_path";
49    upload_cleanup 400 404 499 500-505;
50}
51--- more_headers
52X-Content-Range: bytes 0-3/4
53Session-ID: 2
54Content-Type: text/plain
55Content-Disposition: form-data; name="file"; filename="test.txt"
56--- request
57PUT /upload/
58--- error_code: 405
59--- extra_tests eval
60use Test::File qw(file_not_exists_ok);
61sub {
62    my $block = shift;
63    file_not_exists_ok(
64        "${ENV{TEST_NGINX_UPLOAD_PATH}}/store/2/2", $block->name . '- tmp file deleted');
65}
66