annotate http_disable_symlinks.t @ 202:067b6cb4793d

Tests: cleanup disable_symlinks tests. In particular, make it correcly skip tests if run under symbolic link.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 13 Feb 2012 23:53:23 +0400
parents fc297a64142e
children b6a4770e47ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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;
202
067b6cb4793d Tests: cleanup disable_symlinks tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 201
diff changeset
14 use Cwd qw/ realpath /;
201
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
15
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
16 BEGIN { use FindBin; chdir($FindBin::Bin); }
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
17
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
18 use lib 'lib';
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
19 use Test::Nginx;
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
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
23 select STDERR; $| = 1;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
24 select STDOUT; $| = 1;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
25
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
26 my $t = Test::Nginx->new()->has(qw/http rewrite/)
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
27 ->write_file_expand('nginx.conf', <<'EOF');
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
28
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
29 %%TEST_GLOBALS%%
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
30
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
31 daemon off;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
32
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
33 events {
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
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
36 http {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
37 %%TEST_GLOBALS_HTTP%%
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
38
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
39 server {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
40 listen 127.0.0.1:8080;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
41 server_name s1;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
42
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
43 location /on/ {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
44 disable_symlinks on;
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
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
47 location /not_owner/ {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
48 disable_symlinks if_not_owner;
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
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
51 location /try_on/ {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
52 disable_symlinks on;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
53 try_files $uri $uri.html =404;
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
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
56 location /try_not_owner/ {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
57 disable_symlinks if_not_owner;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
58 try_files $uri $uri.txt =404;
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
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
61 location /if_on/ {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
62 disable_symlinks on;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
63 if (-f $request_filename) {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
64 return 204;
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
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
68 location /if_not_owner/ {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
69 disable_symlinks if_not_owner;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
70 if (-f $request_filename) {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
71 return 204;
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
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
76 server {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
77 listen 127.0.0.1:8080;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
78 server_name s2;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
79
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
80 open_file_cache max=16 inactive=60s;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
81 open_file_cache_valid 30s;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
82 open_file_cache_min_uses 1;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
83 open_file_cache_errors on;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
84
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
85 location /cached-off/ {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
86 disable_symlinks off;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
87 alias %%TESTDIR%%/cached/;
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
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
90 location /cached-on/ {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
91 disable_symlinks on;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
92 alias %%TESTDIR%%/cached/;
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
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
95 location /cached-if-not-owner/ {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
96 disable_symlinks if_not_owner;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
97 alias %%TESTDIR%%/cached/;
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
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
100 location / {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
101 disable_symlinks off;
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
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
106 EOF
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
107
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
108 eval {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
109 open OLDERR, ">&", \*STDERR; close STDERR;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
110 $t->run();
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
111 open STDERR, ">&", \*OLDERR;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
112 };
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
113 plan(skip_all => 'no disable_symlinks') if $@;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
114
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
115 my $uid = getuid();
202
067b6cb4793d Tests: cleanup disable_symlinks tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 201
diff changeset
116 my ($extfile) = grep { -f "$_" && $uid != (stat($_))[4] }
067b6cb4793d Tests: cleanup disable_symlinks tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 201
diff changeset
117 ('/etc/resolv.conf', '/etc/protocols', '/etc/host.conf');
201
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
118
202
067b6cb4793d Tests: cleanup disable_symlinks tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 201
diff changeset
119 plan(skip_all => 'no external file found')
067b6cb4793d Tests: cleanup disable_symlinks tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 201
diff changeset
120 if !defined $extfile;
201
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
121
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
122 my $d = $t->testdir();
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
123
202
067b6cb4793d Tests: cleanup disable_symlinks tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 201
diff changeset
124 plan(skip_all => 'cannot test under symlink')
067b6cb4793d Tests: cleanup disable_symlinks tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 201
diff changeset
125 if $d ne realpath($d);
067b6cb4793d Tests: cleanup disable_symlinks tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 201
diff changeset
126
067b6cb4793d Tests: cleanup disable_symlinks tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 201
diff changeset
127 $t->plan(17);
067b6cb4793d Tests: cleanup disable_symlinks tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 201
diff changeset
128
201
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
129 mkdir("$d/on");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
130 mkdir("$d/not_owner");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
131 mkdir("$d/try_on");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
132 mkdir("$d/try_not_owner");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
133 mkdir("$d/if_on");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
134 mkdir("$d/if_not_owner");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
135 mkdir("$d/cached");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
136
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
137 $t->write_file("empty.html", "");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
138 symlink("empty.html", "$d/link");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
139 symlink($extfile, "$d/link2");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
140
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
141 $t->write_file("on/empty.html", "");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
142 symlink("empty.html", "$d/on/link");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
143 symlink($extfile, "$d/on/link2");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
144
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
145 $t->write_file("not_owner/empty.html", "");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
146 symlink("empty.html", "$d/not_owner/link");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
147 symlink($extfile, "$d/not_owner/link2");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
148
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
149 $t->write_file("try_on/try.html", "LOCAL TRY");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
150 symlink($extfile, "$d/try_on/try");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
151
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
152 $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
153 symlink($extfile, "$d/try_not_owner/try");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
154 symlink("try.html", "$d/try_not_owner/try.txt");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
155
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
156 $t->write_file("if_on/empty.html", "");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
157 symlink("empty.html", "$d/if_on/link");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
158 symlink($extfile, "$d/if_on/link2");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
159
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
160 $t->write_file("if_not_owner/empty.html", "");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
161 symlink("empty.html", "$d/if_not_owner/link");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
162 symlink($extfile, "$d/if_not_owner/link2");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
163
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
164 symlink($extfile, "$d/cached/link");
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
165
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
166 ###############################################################################
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
167
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
168 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
169 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
170
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
171 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
172 'static (on, same uid)');
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
173 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
174 'static (on, 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', '/not_owner/link'), qr!200 OK!,
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
177 'static (if_not_owner, same uid)');
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
178 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
179 'static (if_not_owner, 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', '/try_on/try'), qr/LOCAL TRY/,
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
182 'try_files (on)');
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
183 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
184 'try_files (if_not_owner)');
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', '/if_on/link'), qr!403 Forbidden!,
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
187 'if (on, same uid)');
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
188 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
189 'if (on, other uid)');
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_not_owner/link'), qr!204 No Content!,
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
192 'if (if_not_owner, same uid)');
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
193 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
194 'if (if_not_owner, 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('s2', '/cached-off/link'), qr!200 OK!,
202
067b6cb4793d Tests: cleanup disable_symlinks tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 201
diff changeset
197 'open_file_cache (pass 1)');
201
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
198 like(http_get_host('s2', '/cached-on/link'), qr!403 Forbidden!,
202
067b6cb4793d Tests: cleanup disable_symlinks tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 201
diff changeset
199 'open_file_cache (pass 2)');
201
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
200 like(http_get_host('s2', '/cached-off/link'), qr!200 OK!,
202
067b6cb4793d Tests: cleanup disable_symlinks tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 201
diff changeset
201 'open_file_cache (pass 3)');
201
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
202 like(http_get_host('s2', '/cached-if-not-owner/link'), qr!403 Forbidden!,
202
067b6cb4793d Tests: cleanup disable_symlinks tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 201
diff changeset
203 'open_file_cache (pass 4)');
201
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
204 like(http_get_host('s2', '/cached-off/link'), qr!200 OK!,
202
067b6cb4793d Tests: cleanup disable_symlinks tests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 201
diff changeset
205 'open_file_cache (pass 5)');
201
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
206
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
207 ###############################################################################
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
208
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
209 sub http_get_host {
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
210 my ($host, $url) = @_;
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
211 return http(<<EOF);
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
212 GET $url HTTP/1.0
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
213 Host: $host
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
214
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
215 EOF
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
216 }
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
217
fc297a64142e Tests: disable_symlinks directive tests added.
Andrey Belov <defan@nginx.com>
parents:
diff changeset
218 ###############################################################################