Mercurial > hg > nginx-tests
annotate http_disable_symlinks.t @ 201:fc297a64142e
Tests: disable_symlinks directive tests added.
author | Andrey Belov <defan@nginx.com> |
---|---|
date | Mon, 06 Feb 2012 21:45:56 +0400 |
parents | |
children | 067b6cb4793d |
rev | line source |
---|---|
201
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
2 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
3 # (C) Andrey Belov |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
4 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
5 # Tests for disable_symlinks directive. |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
6 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
7 ############################################################################### |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
8 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
9 use warnings; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
10 use strict; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
11 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
12 use Test::More; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
13 use POSIX; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
14 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
16 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
19 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
21 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
24 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http rewrite/) |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
26 ->write_file_expand('nginx.conf', <<'EOF'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
27 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
28 %%TEST_GLOBALS%% |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
29 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
30 daemon off; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
31 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
32 events { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
33 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
34 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
35 http { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
36 %%TEST_GLOBALS_HTTP%% |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
37 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
38 server { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
39 listen 127.0.0.1:8080; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
40 server_name s1; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
41 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
42 location /on/ { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
43 disable_symlinks on; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
44 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
45 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
46 location /not_owner/ { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
47 disable_symlinks if_not_owner; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
48 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
49 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
50 location /try_on/ { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
51 disable_symlinks on; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
52 try_files $uri $uri.html =404; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
53 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
54 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
55 location /try_not_owner/ { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
56 disable_symlinks if_not_owner; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
57 try_files $uri $uri.txt =404; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
58 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
59 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
60 location /if_on/ { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
61 disable_symlinks on; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
62 if (-f $request_filename) { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
63 return 204; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
64 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
65 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
66 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
67 location /if_not_owner/ { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
68 disable_symlinks if_not_owner; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
69 if (-f $request_filename) { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
70 return 204; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
71 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
72 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
73 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
74 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
75 server { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
76 listen 127.0.0.1:8080; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
77 server_name s2; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
78 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
79 open_file_cache max=16 inactive=60s; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
80 open_file_cache_valid 30s; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
81 open_file_cache_min_uses 1; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
82 open_file_cache_errors on; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
83 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
84 location /cached-off/ { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
85 disable_symlinks off; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
86 alias %%TESTDIR%%/cached/; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
87 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
88 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
89 location /cached-on/ { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
90 disable_symlinks on; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
91 alias %%TESTDIR%%/cached/; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
92 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
93 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
94 location /cached-if-not-owner/ { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
95 disable_symlinks if_not_owner; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
96 alias %%TESTDIR%%/cached/; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
97 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
98 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
99 location / { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
100 disable_symlinks off; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
101 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
102 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
103 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
104 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
105 EOF |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
106 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
107 eval { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
108 open OLDERR, ">&", \*STDERR; close STDERR; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
109 $t->run(); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
110 open STDERR, ">&", \*OLDERR; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
111 }; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
112 plan(skip_all => 'no disable_symlinks') if $@; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
113 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
114 my $uid = getuid(); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
115 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
116 my @extfiles = ('/etc/resolv.conf', '/etc/protocols', '/etc/host.conf'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
117 my $extfile = undef; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
118 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
119 foreach (@extfiles) { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
120 if (-f "$_" && $uid != (stat($_))[4]) { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
121 $extfile = $_; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
122 last; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
123 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
124 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
125 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
126 if (defined($extfile)) { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
127 $t->plan(17); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
128 } else { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
129 plan(skip_all => 'external suitable object not found'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
130 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
131 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
132 my $d = $t->testdir(); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
133 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
134 mkdir("$d/on"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
135 mkdir("$d/not_owner"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
136 mkdir("$d/try_on"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
137 mkdir("$d/try_not_owner"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
138 mkdir("$d/if_on"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
139 mkdir("$d/if_not_owner"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
140 mkdir("$d/cached"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
141 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
142 $t->write_file("empty.html", ""); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
143 symlink("empty.html", "$d/link"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
144 symlink($extfile, "$d/link2"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
145 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
146 $t->write_file("on/empty.html", ""); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
147 symlink("empty.html", "$d/on/link"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
148 symlink($extfile, "$d/on/link2"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
149 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
150 $t->write_file("not_owner/empty.html", ""); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
151 symlink("empty.html", "$d/not_owner/link"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
152 symlink($extfile, "$d/not_owner/link2"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
153 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
154 $t->write_file("try_on/try.html", "LOCAL TRY"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
155 symlink($extfile, "$d/try_on/try"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
156 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
157 $t->write_file("try_not_owner/try.html", "LOCAL TRY"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
158 symlink($extfile, "$d/try_not_owner/try"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
159 symlink("try.html", "$d/try_not_owner/try.txt"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
160 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
161 $t->write_file("if_on/empty.html", ""); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
162 symlink("empty.html", "$d/if_on/link"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
163 symlink($extfile, "$d/if_on/link2"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
164 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
165 $t->write_file("if_not_owner/empty.html", ""); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
166 symlink("empty.html", "$d/if_not_owner/link"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
167 symlink($extfile, "$d/if_not_owner/link2"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
168 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
169 symlink($extfile, "$d/cached/link"); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
170 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
171 ############################################################################### |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
172 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
173 like(http_get_host('s1', '/link'), qr!200 OK!, 'static (off, same uid)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
174 like(http_get_host('s1', '/link2'), qr!200 OK!, 'static (off, other uid)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
175 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
176 like(http_get_host('s1', '/on/link'), qr!403 Forbidden!, |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
177 'static (on, same uid)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
178 like(http_get_host('s1', '/on/link2'), qr!403 Forbidden!, |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
179 'static (on, other uid)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
180 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
181 like(http_get_host('s1', '/not_owner/link'), qr!200 OK!, |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
182 'static (if_not_owner, same uid)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
183 like(http_get_host('s1', '/not_owner/link2'), qr!403 Forbidden!, |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
184 'static (if_not_owner, other uid)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
185 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
186 like(http_get_host('s1', '/try_on/try'), qr/LOCAL TRY/, |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
187 'try_files (on)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
188 like(http_get_host('s1', '/try_not_owner/try'), qr/LOCAL TRY/, |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
189 'try_files (if_not_owner)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
190 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
191 like(http_get_host('s1', '/if_on/link'), qr!403 Forbidden!, |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
192 'if (on, same uid)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
193 like(http_get_host('s1', '/if_on/link2'), qr!403 Forbidden!, |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
194 'if (on, other uid)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
195 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
196 like(http_get_host('s1', '/if_not_owner/link'), qr!204 No Content!, |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
197 'if (if_not_owner, same uid)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
198 like(http_get_host('s1', '/if_not_owner/link2'), qr!403 Forbidden!, |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
199 'if (if_not_owner, other uid)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
200 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
201 like(http_get_host('s2', '/cached-off/link'), qr!200 OK!, |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
202 'open_file_cache (pass #1)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
203 like(http_get_host('s2', '/cached-on/link'), qr!403 Forbidden!, |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
204 'open_file_cache (pass #2)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
205 like(http_get_host('s2', '/cached-off/link'), qr!200 OK!, |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
206 'open_file_cache (pass #3)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
207 like(http_get_host('s2', '/cached-if-not-owner/link'), qr!403 Forbidden!, |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
208 'open_file_cache (pass #4)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
209 like(http_get_host('s2', '/cached-off/link'), qr!200 OK!, |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
210 'open_file_cache (pass #5)'); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
211 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
212 ############################################################################### |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
213 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
214 sub http_get_host { |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
215 my ($host, $url) = @_; |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
216 return http(<<EOF); |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
217 GET $url HTTP/1.0 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
218 Host: $host |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
219 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
220 EOF |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
221 } |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
222 |
fc297a64142e
Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff
changeset
|
223 ############################################################################### |