Mercurial > hg > nginx-tests
changeset 1150:ccf134a800ae
Tests: added Location tests with alias for dav and static modules.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 21 Mar 2017 15:42:21 +0300 |
parents | b1c2857d2e97 |
children | 57673c7257a3 |
files | dav.t http_absolute_redirect.t |
diffstat | 2 files changed, 29 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/dav.t +++ b/dav.t @@ -21,7 +21,7 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http dav/)->plan(15); +my $t = Test::Nginx->new()->has(qw/http dav/)->plan(18); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -42,6 +42,11 @@ http { location / { dav_methods PUT DELETE MKCOL COPY MOVE; } + + location /i/ { + alias %%TESTDIR%%/; + dav_methods PUT DELETE MKCOL COPY MOVE; + } } } @@ -144,4 +149,16 @@ like($r, qr/204 No Content/, 'copy file is(-s $t->testdir() . '/file-moved escape', 10, 'file copied unescaped'); +$r = http(<<EOF . '0123456789'); +PUT /i/alias HTTP/1.1 +Host: localhost +Connection: close +Content-Length: 10 + +EOF + +like($r, qr/201 Created.*(Content-Length|\x0d\0a0\x0d\x0a)/ms, 'put alias'); +like($r, qr!Location: http://localhost:\d+/i/alias\x0d?$!ms, 'location alias'); +is(-s $t->testdir() . '/alias', 10, 'put alias size'); + ###############################################################################
--- a/http_absolute_redirect.t +++ b/http_absolute_redirect.t @@ -52,6 +52,10 @@ http { location /return301 { return 301 /redirect; } + + location /i/ { + alias %%TESTDIR%%/; + } } server { @@ -67,6 +71,10 @@ http { location /return301 { return 301 /redirect; } + + location /i/ { + alias %%TESTDIR%%/; + } } } @@ -74,17 +82,19 @@ EOF mkdir($t->testdir() . '/dir'); -$t->try_run('no absolute_redirect')->plan(6); +$t->try_run('no absolute_redirect')->plan(8); ############################################################################### my $p = port(8080); like(get('on', '/dir'), qr!Location: http://on:$p/dir/!, 'directory'); +like(get('on', '/i/dir'), qr!Location: http://on:$p/i/dir/!, 'directory alias'); like(get('on', '/auto'), qr!Location: http://on:$p/auto/!, 'auto'); like(get('on', '/return301'), qr!Location: http://on:$p/redirect!, 'return'); like(get('off', '/dir'), qr!Location: /dir/!, 'off directory'); +like(get('off', '/i/dir'), qr!Location: /i/dir/!, 'off directory alias'); like(get('off', '/auto'), qr!Location: /auto/!, 'off auto'); like(get('off', '/return301'), qr!Location: /redirect!, 'off return');