comparison dav.t @ 141:1e1975cd25ef

Tests: error_page and return related tests, dav tests.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 02 Nov 2010 06:49:42 +0300
parents
children 2644bad81b0b
comparison
equal deleted inserted replaced
140:3f246a1be2b0 141:1e1975cd25ef
1 #!/usr/bin/perl
2
3 # (C) Maxim Dounin
4
5 # Tests for nginx dav module.
6
7 ###############################################################################
8
9 use warnings;
10 use strict;
11
12 use Test::More;
13
14 BEGIN { use FindBin; chdir($FindBin::Bin); }
15
16 use lib 'lib';
17 use Test::Nginx;
18
19 ###############################################################################
20
21 select STDERR; $| = 1;
22 select STDOUT; $| = 1;
23
24 my $t = Test::Nginx->new()->has(qw/http dav/)->plan(11);
25
26 $t->write_file_expand('nginx.conf', <<'EOF');
27
28 %%TEST_GLOBALS%%
29
30 master_process off;
31 daemon off;
32
33 events {
34 }
35
36 http {
37 %%TEST_GLOBALS_HTTP%%
38
39 server {
40 listen 127.0.0.1:8080;
41 server_name localhost;
42
43 location / {
44 dav_methods PUT DELETE MKCOL COPY MOVE;
45 }
46 }
47 }
48
49 EOF
50
51 $t->run();
52
53 ###############################################################################
54
55 my $r;
56
57 $r = http(<<EOF . '0123456789');
58 PUT /file HTTP/1.1
59 Host: localhost
60 Connection: close
61 Content-Length: 10
62
63 EOF
64
65 like($r, qr/201 Created.*(Content-Length|\x0d\0a0\x0d\x0a)/ms, 'put file');
66 is(-s $t->testdir() . '/file', 10, 'put file size');
67
68 $r = http(<<EOF);
69 PUT /file HTTP/1.1
70 Host: localhost
71 Connection: close
72 Content-Length: 0
73
74 EOF
75
76 like($r, qr/204 No Content/, 'put file again');
77 unlike($r, qr/Content-Length|Transfer-Encoding/, 'no length in 204');
78 is(-s $t->testdir() . '/file', 0, 'put file again size');
79
80 $r = http(<<EOF);
81 DELETE /file HTTP/1.1
82 Host: localhost
83 Connection: close
84 Content-Length: 0
85
86 EOF
87
88 like($r, qr/204 No Content/, 'delete file');
89 unlike($r, qr/Content-Length|Transfer-Encoding/, 'no length in 204');
90 ok(!-f $t->testdir() . '/file', 'file deleted');
91
92 TODO: {
93 local $TODO = 'broken in 0.8.32';
94
95 # 201 replies contain body, response should indicate it's empty
96 # before 0.8.32 chunked was explicitly disabled for 201 replies so
97 # connection was just closed (which isn't perfect but worked)
98
99 $r = http(<<EOF);
100 MKCOL /test/ HTTP/1.1
101 Host: localhost
102 Connection: close
103
104 EOF
105
106 like($r, qr/201 Created.*(Content-Length|\x0d\0a0\x0d\x0a)/ms, 'mkcol');
107
108 $r = http(<<EOF);
109 COPY /test/ HTTP/1.1
110 Host: localhost
111 Destination: /test-moved/
112 Connection: close
113
114 EOF
115
116 like($r, qr/201 Created.*(Content-Length|\x0d\0a0\x0d\x0a)/ms, 'copy dir');
117
118 $r = http(<<EOF);
119 MOVE /test/ HTTP/1.1
120 Host: localhost
121 Destination: /test-moved/
122 Connection: close
123
124 EOF
125
126 like($r, qr/201.*(Content-Length|\x0d\0a0\x0d\x0a)/ms, 'move dir');
127 }
128
129 ###############################################################################