# HG changeset patch # User Sergey Kandaurov # Date 1390911484 -14400 # Node ID 4ac3588485f5f4f93af571e632f22ca598b564ec # Parent fc6b8270469caa7a65efb069208f989e13741f6e Tests: added tests for embedded ssi variable. diff -r fc6b8270469c -r 4ac3588485f5 ssi.t --- a/ssi.t Mon Jan 20 21:09:58 2014 +0400 +++ b/ssi.t Tue Jan 28 16:18:04 2014 +0400 @@ -23,7 +23,7 @@ plan(skip_all => 'win32') if $^O eq 'MSWin32'; -my $t = Test::Nginx->new()->has(qw/http ssi cache proxy rewrite/)->plan(21); +my $t = Test::Nginx->new()->has(qw/http ssi cache proxy rewrite/)->plan(27); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -64,6 +64,19 @@ ssi off; alias %%TESTDIR%%/; } + location /var { + ssi on; + add_header X-Var $date_gmt; + } + location /var_noformat { + ssi on; + add_header X-Var $date_gmt; + return 200; + } + location /var_nossi { + add_header X-Var $date_gmt; + return 200; + } } } @@ -91,6 +104,16 @@ $t->write_file('unescape3.html', 'XX'); +$t->write_file('var_format.html', + 'x' + . '' + . '' + . '' + . '' + . '' + . '' + . 'x'); + $t->run(); ############################################################################### @@ -142,6 +165,28 @@ } +# handling of embedded date variables + +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.5.10'); + +like(http_get('/var_nossi.html'), + qr/X-Var: \w+, \d\d-\w{3}-\d{4} \d\d:\d\d:\d\d \w+/, 'no ssi'); +like(http_get('/var_noformat.html'), + qr/X-Var: \w+, \d\d-\w{3}-\d{4} \d\d:\d\d:\d\d \w+/, 'no format'); + +like(http_get('/var_format.html?custom=1'), + qr/X-Var: \w+, \d\d-\w{3}-\d{4} \d\d:\d\d:\d\d \w+/, 'custom header'); +like(http_get('/var_format.html'), + qr/X-Var: \w+, \d\d-\w{3}-\d{4} \d\d:\d\d:\d\d \w+/, 'default header'); + +} + +like(http_get('/var_format.html?custom=1'), + qr/x\w+, \d\d:\d\d:\d\dx/, 'custom ssi'); +like(http_get('/var_format.html'), + qr/x\w+, \d\d-\w{3}-\d{4} \d\d:\d\d:\d\d \w+x/, 'default ssi'); + like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts'); ###############################################################################