comparison ssi.t @ 369:4ac3588485f5

Tests: added tests for embedded ssi variable.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 28 Jan 2014 16:18:04 +0400
parents 0726521e42f3
children 847ea345becb
comparison
equal deleted inserted replaced
368:fc6b8270469c 369:4ac3588485f5
21 select STDERR; $| = 1; 21 select STDERR; $| = 1;
22 select STDOUT; $| = 1; 22 select STDOUT; $| = 1;
23 23
24 plan(skip_all => 'win32') if $^O eq 'MSWin32'; 24 plan(skip_all => 'win32') if $^O eq 'MSWin32';
25 25
26 my $t = Test::Nginx->new()->has(qw/http ssi cache proxy rewrite/)->plan(21); 26 my $t = Test::Nginx->new()->has(qw/http ssi cache proxy rewrite/)->plan(27);
27 27
28 $t->write_file_expand('nginx.conf', <<'EOF'); 28 $t->write_file_expand('nginx.conf', <<'EOF');
29 29
30 %%TEST_GLOBALS%% 30 %%TEST_GLOBALS%%
31 31
62 } 62 }
63 location /local/ { 63 location /local/ {
64 ssi off; 64 ssi off;
65 alias %%TESTDIR%%/; 65 alias %%TESTDIR%%/;
66 } 66 }
67 location /var {
68 ssi on;
69 add_header X-Var $date_gmt;
70 }
71 location /var_noformat {
72 ssi on;
73 add_header X-Var $date_gmt;
74 return 200;
75 }
76 location /var_nossi {
77 add_header X-Var $date_gmt;
78 return 200;
79 }
67 } 80 }
68 } 81 }
69 82
70 EOF 83 EOF
71 84
88 'X<!--#include virtual="/tes%741.html?test=test" -->X'); 101 'X<!--#include virtual="/tes%741.html?test=test" -->X');
89 $t->write_file('unescape2.html', 102 $t->write_file('unescape2.html',
90 'X<!--#include virtual="/unescape.html%3f" -->X'); 103 'X<!--#include virtual="/unescape.html%3f" -->X');
91 $t->write_file('unescape3.html', 104 $t->write_file('unescape3.html',
92 'X<!--#include virtual="/test1.html%3ftest=test" -->X'); 105 'X<!--#include virtual="/test1.html%3ftest=test" -->X');
106
107 $t->write_file('var_format.html',
108 'x<!--#if expr="$arg_custom" -->'
109 . '<!--#config timefmt="%A, %H:%M:%S" -->'
110 . '<!--#set var="v" value="$date_gmt" -->'
111 . '<!--#echo var="v" -->'
112 . '<!--#else -->'
113 . '<!--#set var="v" value="$date_gmt" -->'
114 . '<!--#echo var="v" -->'
115 . '<!--#endif -->x');
93 116
94 $t->run(); 117 $t->run();
95 118
96 ############################################################################### 119 ###############################################################################
97 120
140 like(http_get('/unescape3.html'), qr/404 Not Found/, 163 like(http_get('/unescape3.html'), qr/404 Not Found/,
141 'escaped query separator'); 164 'escaped query separator');
142 165
143 } 166 }
144 167
168 # handling of embedded date variables
169
170 TODO: {
171 local $TODO = 'not yet' unless $t->has_version('1.5.10');
172
173 like(http_get('/var_nossi.html'),
174 qr/X-Var: \w+, \d\d-\w{3}-\d{4} \d\d:\d\d:\d\d \w+/, 'no ssi');
175 like(http_get('/var_noformat.html'),
176 qr/X-Var: \w+, \d\d-\w{3}-\d{4} \d\d:\d\d:\d\d \w+/, 'no format');
177
178 like(http_get('/var_format.html?custom=1'),
179 qr/X-Var: \w+, \d\d-\w{3}-\d{4} \d\d:\d\d:\d\d \w+/, 'custom header');
180 like(http_get('/var_format.html'),
181 qr/X-Var: \w+, \d\d-\w{3}-\d{4} \d\d:\d\d:\d\d \w+/, 'default header');
182
183 }
184
185 like(http_get('/var_format.html?custom=1'),
186 qr/x\w+, \d\d:\d\d:\d\dx/, 'custom ssi');
187 like(http_get('/var_format.html'),
188 qr/x\w+, \d\d-\w{3}-\d{4} \d\d:\d\d:\d\d \w+x/, 'default ssi');
189
145 like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts'); 190 like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts');
146 191
147 ############################################################################### 192 ###############################################################################