Mercurial > hg > nginx-tests
comparison http_disable_symlinks.t @ 206:9963da7397cc
Tests: disable_symlinks tests for the "from=" parameter.
author | Valentin Bartenev <ne@vbart.ru> |
---|---|
date | Sun, 26 Feb 2012 21:49:34 +0400 |
parents | 606a4df68952 |
children | 0a9e5d753fb8 |
comparison
equal
deleted
inserted
replaced
205:606a4df68952 | 206:9963da7397cc |
---|---|
103 } | 103 } |
104 | 104 |
105 location /dir { | 105 location /dir { |
106 disable_symlinks on; | 106 disable_symlinks on; |
107 try_files $uri/ =404; | 107 try_files $uri/ =404; |
108 } | |
109 | |
110 location /from { | |
111 disable_symlinks on from=$document_root; | |
112 | |
113 location /from/wo_slash { | |
114 alias %%TESTDIR%%/dirlink; | |
115 } | |
116 location /from/with_slash/ { | |
117 alias %%TESTDIR%%/dirlink/; | |
118 } | |
119 location ~ ^/from/exact/(.+)$ { | |
120 alias %%TESTDIR%%/$1; | |
121 } | |
108 } | 122 } |
109 } | 123 } |
110 | 124 |
111 server { | 125 server { |
112 listen 127.0.0.1:8080; | 126 listen 127.0.0.1:8080; |
154 plan(skip_all => 'no external file found') | 168 plan(skip_all => 'no external file found') |
155 if !defined $extfile; | 169 if !defined $extfile; |
156 | 170 |
157 my $d = $t->testdir(); | 171 my $d = $t->testdir(); |
158 | 172 |
159 plan(skip_all => 'cannot test under symlink') | 173 $t->plan(28); |
160 if $d ne realpath($d); | |
161 | |
162 $t->plan(25); | |
163 | 174 |
164 mkdir("$d/on"); | 175 mkdir("$d/on"); |
165 mkdir("$d/not_owner"); | 176 mkdir("$d/not_owner"); |
166 mkdir("$d/try_on"); | 177 mkdir("$d/try_on"); |
167 mkdir("$d/try_not_owner"); | 178 mkdir("$d/try_not_owner"); |
195 $t->write_file("if_not_owner/empty.html", ""); | 206 $t->write_file("if_not_owner/empty.html", ""); |
196 symlink("empty.html", "$d/if_not_owner/link"); | 207 symlink("empty.html", "$d/if_not_owner/link"); |
197 symlink($extfile, "$d/if_not_owner/link2"); | 208 symlink($extfile, "$d/if_not_owner/link2"); |
198 | 209 |
199 mkdir("$d/dir"); | 210 mkdir("$d/dir"); |
211 $t->write_file("dir/empty.html", ""); | |
200 symlink("dir", "$d/dirlink"); | 212 symlink("dir", "$d/dirlink"); |
201 | 213 |
202 symlink($extfile, "$d/cached/link"); | 214 symlink($extfile, "$d/cached/link"); |
203 | 215 |
204 ############################################################################### | 216 ############################################################################### |
217 | |
218 SKIP: { | |
219 skip 'cannot test under symlink', 25 if $d ne realpath($d); | |
205 | 220 |
206 like(http_get_host('s1', '/link'), qr!200 OK!, 'static (off, same uid)'); | 221 like(http_get_host('s1', '/link'), qr!200 OK!, 'static (off, same uid)'); |
207 like(http_get_host('s1', '/link2'), qr!200 OK!, 'static (off, other uid)'); | 222 like(http_get_host('s1', '/link2'), qr!200 OK!, 'static (off, other uid)'); |
208 | 223 |
209 like(http_get_host('s1', '/on/link'), qr!403 Forbidden!, | 224 like(http_get_host('s1', '/on/link'), qr!403 Forbidden!, |
257 like(http_get('/link/tailoff'), qr!404 !, 'file with trailing /, off'); | 272 like(http_get('/link/tailoff'), qr!404 !, 'file with trailing /, off'); |
258 | 273 |
259 like(http_get('/dirlink'), qr!404 !, 'directory without /'); | 274 like(http_get('/dirlink'), qr!404 !, 'directory without /'); |
260 like(http_get('/dirlink/'), qr!404 !, 'directory with trailing /'); | 275 like(http_get('/dirlink/'), qr!404 !, 'directory with trailing /'); |
261 | 276 |
277 } # SKIP: cannot test under symlink | |
278 | |
279 like(http_get('/from/wo_slash/empty.html'), qr!200 OK!, '"from=" without /'); | |
280 like(http_get('/from/with_slash/empty.html'), qr!200 OK!, '"from=" with /'); | |
281 like(http_get('/from/exact/link'), qr!200 OK!, '"from=" exact match'); | |
282 | |
262 ############################################################################### | 283 ############################################################################### |
263 | 284 |
264 sub http_get_host { | 285 sub http_get_host { |
265 my ($host, $url) = @_; | 286 my ($host, $url) = @_; |
266 return http(<<EOF); | 287 return http(<<EOF); |