Mercurial > hg > nginx-tests
comparison http_disable_symlinks.t @ 203:b6a4770e47ea
Tests: disable_symlinks tests for complex cases.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 14 Feb 2012 19:41:44 +0400 |
parents | 067b6cb4793d |
children | d838248b643a |
comparison
equal
deleted
inserted
replaced
202:067b6cb4793d | 203:b6a4770e47ea |
---|---|
68 location /if_not_owner/ { | 68 location /if_not_owner/ { |
69 disable_symlinks if_not_owner; | 69 disable_symlinks if_not_owner; |
70 if (-f $request_filename) { | 70 if (-f $request_filename) { |
71 return 204; | 71 return 204; |
72 } | 72 } |
73 } | |
74 | |
75 location /complex/1/ { | |
76 disable_symlinks on; | |
77 alias %%TESTDIR%%/./cached/../; | |
78 } | |
79 | |
80 location /complex/2/ { | |
81 disable_symlinks on; | |
82 alias %%TESTDIR%%//./cached/..//; | |
83 } | |
84 | |
85 location /complex/3/ { | |
86 disable_symlinks on; | |
87 alias ///%%TESTDIR%%//./cached/..//; | |
88 } | |
89 | |
90 location ~ (.+/)tail$ { | |
91 disable_symlinks on; | |
92 alias %%TESTDIR%%/$1; | |
93 } | |
94 | |
95 location /dir { | |
96 disable_symlinks on; | |
97 try_files $uri/ =404; | |
73 } | 98 } |
74 } | 99 } |
75 | 100 |
76 server { | 101 server { |
77 listen 127.0.0.1:8080; | 102 listen 127.0.0.1:8080; |
122 my $d = $t->testdir(); | 147 my $d = $t->testdir(); |
123 | 148 |
124 plan(skip_all => 'cannot test under symlink') | 149 plan(skip_all => 'cannot test under symlink') |
125 if $d ne realpath($d); | 150 if $d ne realpath($d); |
126 | 151 |
127 $t->plan(17); | 152 $t->plan(23); |
128 | 153 |
129 mkdir("$d/on"); | 154 mkdir("$d/on"); |
130 mkdir("$d/not_owner"); | 155 mkdir("$d/not_owner"); |
131 mkdir("$d/try_on"); | 156 mkdir("$d/try_on"); |
132 mkdir("$d/try_not_owner"); | 157 mkdir("$d/try_not_owner"); |
158 symlink($extfile, "$d/if_on/link2"); | 183 symlink($extfile, "$d/if_on/link2"); |
159 | 184 |
160 $t->write_file("if_not_owner/empty.html", ""); | 185 $t->write_file("if_not_owner/empty.html", ""); |
161 symlink("empty.html", "$d/if_not_owner/link"); | 186 symlink("empty.html", "$d/if_not_owner/link"); |
162 symlink($extfile, "$d/if_not_owner/link2"); | 187 symlink($extfile, "$d/if_not_owner/link2"); |
188 | |
189 mkdir("$d/dir"); | |
190 symlink("dir", "$d/dirlink"); | |
163 | 191 |
164 symlink($extfile, "$d/cached/link"); | 192 symlink($extfile, "$d/cached/link"); |
165 | 193 |
166 ############################################################################### | 194 ############################################################################### |
167 | 195 |
202 like(http_get_host('s2', '/cached-if-not-owner/link'), qr!403 Forbidden!, | 230 like(http_get_host('s2', '/cached-if-not-owner/link'), qr!403 Forbidden!, |
203 'open_file_cache (pass 4)'); | 231 'open_file_cache (pass 4)'); |
204 like(http_get_host('s2', '/cached-off/link'), qr!200 OK!, | 232 like(http_get_host('s2', '/cached-off/link'), qr!200 OK!, |
205 'open_file_cache (pass 5)'); | 233 'open_file_cache (pass 5)'); |
206 | 234 |
235 like(http_get('/complex/1/empty.html'), qr!200 OK!, 'complex root 1'); | |
236 like(http_get('/complex/2/empty.html'), qr!200 OK!, 'complex root 2'); | |
237 like(http_get('/complex/3/empty.html'), qr!200 OK!, 'complex root 3'); | |
238 | |
239 like(http_get('/link/tail'), qr!403 !, 'file with trailing /'); | |
240 like(http_get('/dirlink'), qr!404 !, 'directory without /'); | |
241 like(http_get('/dirlink/'), qr!404 !, 'directory with trailing /'); | |
242 | |
207 ############################################################################### | 243 ############################################################################### |
208 | 244 |
209 sub http_get_host { | 245 sub http_get_host { |
210 my ($host, $url) = @_; | 246 my ($host, $url) = @_; |
211 return http(<<EOF); | 247 return http(<<EOF); |